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
79f228a805d447e6342b8144a3a6993e330ed082
208
exs
Elixir
priv/repo/migrations/20180225175943_add_participation_counter_to_workshops.exs
nunopolonia/psc-api
2e358503851cc04cdaa89201a3f56586f8746736
[ "MIT" ]
1
2017-09-10T23:51:40.000Z
2017-09-10T23:51:40.000Z
priv/repo/migrations/20180225175943_add_participation_counter_to_workshops.exs
nunopolonia/psc-api
2e358503851cc04cdaa89201a3f56586f8746736
[ "MIT" ]
24
2018-03-14T18:17:00.000Z
2021-03-01T07:47:53.000Z
priv/repo/migrations/20180225175943_add_participation_counter_to_workshops.exs
portosummerofcode/psc-api
2e358503851cc04cdaa89201a3f56586f8746736
[ "MIT" ]
null
null
null
defmodule Api.Repo.Migrations.AddParticipantsCounterToWorkshops do use Ecto.Migration def change do alter table(:workshops) do add :participants_counter, :integer, default: 0 end end end
20.8
66
0.75
79f2360c98b2e53aee69d3e72091379fad754339
432
ex
Elixir
testData/org/elixir_lang/parser_definition/matched_dot_operator_call_operation/one_argument_parsing_test_case/EmptyBlock.ex
ArtemGordinsky/intellij-elixir
e2d9b4dfc65651b293d499043edeaad606cf5652
[ "Apache-2.0" ]
null
null
null
testData/org/elixir_lang/parser_definition/matched_dot_operator_call_operation/one_argument_parsing_test_case/EmptyBlock.ex
ArtemGordinsky/intellij-elixir
e2d9b4dfc65651b293d499043edeaad606cf5652
[ "Apache-2.0" ]
null
null
null
testData/org/elixir_lang/parser_definition/matched_dot_operator_call_operation/one_argument_parsing_test_case/EmptyBlock.ex
ArtemGordinsky/intellij-elixir
e2d9b4dfc65651b293d499043edeaad606cf5652
[ "Apache-2.0" ]
null
null
null
(;).and positional (;).&& positional (;).|> positional (;).@ positional (;).& positional (;).== positional (;).+ positional (;).^^^ positional (;).<- positional (;).in positional (;).= positional (;)./ positional (;).* positional (;).or positional (;).|| positional (;).| positional (;).<= positional (;).-> positional (;).<> positional (;).^ positional (;).not positional (;).after positional (;).do positional (;).when positional
17.28
20
0.604167
79f2397bc199c9cc6b20ab8db8d5435fdd91f3c7
1,834
ex
Elixir
clients/cloud_tasks/lib/google_api/cloud_tasks/v2beta2/model/list_locations_response.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/cloud_tasks/lib/google_api/cloud_tasks/v2beta2/model/list_locations_response.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/cloud_tasks/lib/google_api/cloud_tasks/v2beta2/model/list_locations_response.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.CloudTasks.V2beta2.Model.ListLocationsResponse do @moduledoc """ The response message for Locations.ListLocations. ## Attributes * `locations` (*type:* `list(GoogleApi.CloudTasks.V2beta2.Model.Location.t)`, *default:* `nil`) - A list of locations that matches the specified filter in the request. * `nextPageToken` (*type:* `String.t`, *default:* `nil`) - The standard List next-page token. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :locations => list(GoogleApi.CloudTasks.V2beta2.Model.Location.t()), :nextPageToken => String.t() } field(:locations, as: GoogleApi.CloudTasks.V2beta2.Model.Location, type: :list) field(:nextPageToken) end defimpl Poison.Decoder, for: GoogleApi.CloudTasks.V2beta2.Model.ListLocationsResponse do def decode(value, options) do GoogleApi.CloudTasks.V2beta2.Model.ListLocationsResponse.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.CloudTasks.V2beta2.Model.ListLocationsResponse do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
36.68
171
0.74482
79f2436086e0a9aaefbdb609f3560de3d3f677ce
637
exs
Elixir
languages/elixir/exercises/concept/stack-underflow/test/test_helper.exs
jwarwick/exercism_v3
db92721b9d62681c51b8f25fb0c6f5f97bfac44b
[ "MIT" ]
200
2019-12-12T13:50:59.000Z
2022-02-20T22:38:42.000Z
languages/elixir/exercises/concept/stack-underflow/test/test_helper.exs
jwarwick/exercism_v3
db92721b9d62681c51b8f25fb0c6f5f97bfac44b
[ "MIT" ]
1,938
2019-12-12T08:07:10.000Z
2021-01-29T12:56:13.000Z
languages/elixir/exercises/concept/stack-underflow/test/test_helper.exs
jwarwick/exercism_v3
db92721b9d62681c51b8f25fb0c6f5f97bfac44b
[ "MIT" ]
239
2019-12-12T14:09:08.000Z
2022-03-18T00:04:07.000Z
options = [ undefined_division_by_zero_error_module: Code.ensure_compiled(RPNCalculator.Exception.DivisionByZeroError) == {:error, :nofile}, undefined_stack_underflow_error_module: Code.ensure_compiled(RPNCalculator.Exception.StackUnderflowError) == {:error, :nofile}, undefined_struct_division_by_zero_error_exception: not function_exported?(RPNCalculator.Exception.DivisionByZeroError, :__struct__, 0), undefined_struct_stack_underflow_error_exception: not function_exported?(RPNCalculator.Exception.StackUnderflowError, :__struct__, 0) ] ExUnit.start(options) ExUnit.configure(exclude: :pending, trace: true)
45.5
91
0.821036
79f26c2de155dd4793ef31a1f0ca5f4be0de8959
568
ex
Elixir
lib/my_acs.ex
Fullrate/my_acs
52b179267eb450b49dcc1c4a368605c62e7f2abe
[ "Unlicense" ]
5
2016-11-24T07:34:29.000Z
2019-09-06T15:55:35.000Z
lib/my_acs.ex
Fullrate/my_acs
52b179267eb450b49dcc1c4a368605c62e7f2abe
[ "Unlicense" ]
null
null
null
lib/my_acs.ex
Fullrate/my_acs
52b179267eb450b49dcc1c4a368605c62e7f2abe
[ "Unlicense" ]
4
2017-11-29T05:07:10.000Z
2021-12-06T10:35:03.000Z
defmodule MyAcs do @moduledoc """ This is the supervisor for acs_ex, and all the other application eventually needed to make something for the real world """ use Application def start(_type, _args) do import Supervisor.Spec, warn: false acs_port = Application.get_env(:acs_ex, :acs_port, 7548) children = [ {ACS, {MyAcs.Session, acs_port: acs_port, acs_ip: {127, 0, 0, 1}, acs_ipv6: {0, 0, 0, 0, 0, 0}}} ] opts = [strategy: :one_for_one, name: MyAcs.Supervisor] Supervisor.start_link(children, opts) end end
21.846154
97
0.661972
79f27f83bd76073ce7f4209cfa2f87ce53ae3f8e
3,573
exs
Elixir
test/hash_conversions_test.exs
adolfosilva/soundcloud
2b1671be3e8cffa8a2d4ec89f87a4b295028fba0
[ "MIT" ]
null
null
null
test/hash_conversions_test.exs
adolfosilva/soundcloud
2b1671be3e8cffa8a2d4ec89f87a4b295028fba0
[ "MIT" ]
null
null
null
test/hash_conversions_test.exs
adolfosilva/soundcloud
2b1671be3e8cffa8a2d4ec89f87a4b295028fba0
[ "MIT" ]
null
null
null
defmodule SoundcloudTest.HashConversionsTest do use ExUnit.Case use Quixir import Soundcloud.HashConversions doctest Soundcloud.HashConversions @tag :skip test "normalize_param pair of strings" do ptest key: string(), value: string() do assert normalize_param(key, value) == %{key => value} end end test "normalize_param(\"foo[bar]\", \"tar\"" do result = normalize_param("foo[bar]", "tar") expected = %{"foo[bar]" => "tar"} assert expected == result end test "normalize_param(\"foo[tracks]\", %{\"a\" => \"b\"})" do result = normalize_param("foo[tracks]", %{"a" => "b"}) expected = %{"foo[tracks][a]" => "b"} assert expected == result end test "normalize_param(\"playlist[tracks]\",[1234,4567])" do result = normalize_param("playlist[tracks]", [1234, 4567]) expected = %{"playlist[tracks][]" => [1234, 4567]} assert expected == result end test "normalize_param list with map inside" do result = normalize_param("foo[bar]", [1, %{"a" => "b"}]) expected = %{"foo[bar][]" => 1, "foo[bar][][a]" => "b"} assert expected == result end test "normalize_param complex" do map = %{"sharing" => "caring", "tracks" => [%{"foo" => 1}, %{"bar" => 2}]} result = normalize_param("playlist", map) expected = %{ "playlist[tracks][][bar]" => 2, "playlist[tracks][][foo]" => 1, "playlist[sharing]" => "caring" } assert expected == result end test "normalize_param complex 2" do map = %{"sharing" => [], "tracks" => [%{"foo" => 1}, %{"bar" => 2}]} result = normalize_param("playlist", map) expected = %{ "playlist[tracks][][bar]" => 2, "playlist[tracks][][foo]" => 1 } assert expected == result end test "normalize_param complex 3" do map = %{"sharing" => [5], "tracks" => [%{"foo" => 1}, %{"bar" => 2}]} result = normalize_param("playlist", map) expected = %{ "playlist[tracks][][bar]" => 2, "playlist[tracks][][foo]" => 1, "playlist[sharing][]" => 5 } assert expected == result end test "normalize_param complex 4" do map = %{"sharing" => [5, 10], "tracks" => [%{"foo" => 1}, %{"bar" => 2}]} result = normalize_param("playlist", map) expected = %{ "playlist[tracks][][bar]" => 2, "playlist[tracks][][foo]" => 1, "playlist[sharing][]" => [5, 10] } assert expected == result end test "to_params empty map" do assert(%{} == to_params(%{})) end test "to_params simple string pair" do assert(%{"foo" => "bar"} == to_params(%{"foo" => "bar"})) end test "to_params empty list as value" do assert(%{} == to_params(%{"foo" => []})) end test "to_params list of integers as value" do result = to_params(%{"foo" => [1, 2]}) expected = %{"foo[]" => [1, 2]} assert expected == result end test "to_params empty map as value" do assert(%{} == to_params(%{"foo" => %{}})) end test "to_params map as value" do result = to_params(%{"foo" => %{"bar" => false, "tar" => 1}}) expected = %{"foo[bar]" => false, "foo[tar]" => 1} assert expected == result end test "to_params map with list value" do result = to_params(%{"foo" => %{"bar" => false, "tar" => [1, 2]}}) expected = %{"foo[bar]" => false, "foo[tar][]" => [1, 2]} assert expected == result end @tag :skip test "to_params complex" do result = to_params(%{"foo" => %{"bar" => %{"a" => 5}, "tar" => [1, 2]}}) expected = %{"foo[tar][]" => [1, 2]} assert expected == result end end
27.274809
78
0.554996
79f2957cd4fccf2cc9dc627437ac39f988b01b7b
989
ex
Elixir
lib/sibt_web/plugs/register_view.ex
amacgregor/sibt
9819a9de4735612ee59de00f71ca1a6dfa275860
[ "MIT" ]
null
null
null
lib/sibt_web/plugs/register_view.ex
amacgregor/sibt
9819a9de4735612ee59de00f71ca1a6dfa275860
[ "MIT" ]
2
2020-07-18T02:22:22.000Z
2021-03-09T15:46:44.000Z
lib/sibt_web/plugs/register_view.ex
amacgregor/shouldibuildthat
572b0ba95f93f6ea0dc7b250baaa1bc90efd521b
[ "MIT" ]
null
null
null
defmodule SibtWeb.Plugs.RegisterView do @moduledoc """ Register the project view against a particular project """ import Plug.Conn require Logger alias Sibt.Operation def init(_params) do end def call(conn, _params) do views_map = conn.assigns[:views] current_page = conn.params["project_code"] if Map.has_key?(views_map, current_page) do current_map = views_map |> Map.take([current_page]) |> Enum.map(fn {code, counter} -> {code, counter + 1} end) |> Enum.into(%{}) views_map = Map.merge(views_map, current_map) conn = conn |> put_session(:views, views_map) |> assign(:views, views_map) else current_map = %{current_page => 1} views_map = Map.merge(views_map, current_map) Operation.increment_project_view_counter(current_page) conn = conn |> put_session(:views, views_map) |> assign(:views, views_map) end end end
21.977778
66
0.625885
79f2a6bb8205815bbbb00e48a014cee0ffb36224
1,371
exs
Elixir
config/dev.exs
gedzubo/pagila_phoenix_api
c72063672a1b09c8d9bcc2814b03a4863a09a7b4
[ "MIT" ]
null
null
null
config/dev.exs
gedzubo/pagila_phoenix_api
c72063672a1b09c8d9bcc2814b03a4863a09a7b4
[ "MIT" ]
null
null
null
config/dev.exs
gedzubo/pagila_phoenix_api
c72063672a1b09c8d9bcc2814b03a4863a09a7b4
[ "MIT" ]
null
null
null
use Mix.Config # For development, we disable any cache and enable # debugging and code reloading. # # The watchers configuration can be used to run external # watchers to your application. For example, we use it # with brunch.io to recompile .js and .css sources. config :pagila_phoenix_api, PagilaPhoenixApi.Endpoint, http: [port: 4000], debug_errors: true, code_reloader: true, check_origin: false, watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin", cd: Path.expand("../", __DIR__)]] # Watch static and templates for browser reloading. config :pagila_phoenix_api, PagilaPhoenixApi.Endpoint, live_reload: [ patterns: [ ~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$}, ~r{priv/gettext/.*(po)$}, ~r{web/views/.*(ex)$}, ~r{web/templates/.*(eex)$} ] ] # Do not include metadata nor timestamps in development logs config :logger, :console, format: "[$level] $message\n" # Set a higher stacktrace during development. Avoid configuring such # in production as building large stacktraces may be expensive. config :phoenix, :stacktrace_depth, 20 # Configure your database config :pagila_phoenix_api, PagilaPhoenixApi.Repo, adapter: Ecto.Adapters.Postgres, username: "postgres", password: "postgres", database: "pagila_phoenix_api_dev", hostname: "localhost", pool_size: 10
31.159091
73
0.709701
79f2bdb7d7527558cab449619ca49fd62396b1b5
553
ex
Elixir
server/web/router.ex
ravivooda/contactCard
5e2e219fc4c146487a5876ce7481b0245bba452d
[ "MIT" ]
null
null
null
server/web/router.ex
ravivooda/contactCard
5e2e219fc4c146487a5876ce7481b0245bba452d
[ "MIT" ]
null
null
null
server/web/router.ex
ravivooda/contactCard
5e2e219fc4c146487a5876ce7481b0245bba452d
[ "MIT" ]
null
null
null
defmodule ContactCardServer.Router do use ContactCardServer.Web, :router pipeline :browser do plug :accepts, ["html"] plug :fetch_session plug :fetch_flash plug :protect_from_forgery plug :put_secure_browser_headers end pipeline :api do plug :accepts, ["json"] end scope "/", ContactCardServer do pipe_through :browser # Use the default browser stack get "/", PageController, :index end # Other scopes may use custom stacks. # scope "/api", ContactCardServer do # pipe_through :api # end end
20.481481
57
0.696203
79f2e6730bec8defbf164382ff0903cc20a37197
2,959
exs
Elixir
apps/nerves_hub_web_core/priv/repo/seeds.exs
tonnenpinguin/nerves_hub_web
9d36921eb7e20d20a3e3bd308cc98ad7b60cfa72
[ "Apache-2.0" ]
111
2018-07-25T01:07:51.000Z
2022-01-25T17:03:01.000Z
apps/nerves_hub_web_core/priv/repo/seeds.exs
tonnenpinguin/nerves_hub_web
9d36921eb7e20d20a3e3bd308cc98ad7b60cfa72
[ "Apache-2.0" ]
361
2018-07-22T12:53:00.000Z
2022-03-31T18:50:34.000Z
apps/nerves_hub_web_core/priv/repo/seeds.exs
tonnenpinguin/nerves_hub_web
9d36921eb7e20d20a3e3bd308cc98ad7b60cfa72
[ "Apache-2.0" ]
54
2018-08-26T02:58:04.000Z
2022-03-09T10:12:19.000Z
# Script for populating the database. You can run it as: # # mix run priv/repo/seeds.exs # # Inside the script, you can read and write to any of your # repositories directly: # # NervesHubWebCore.Repo.insert!(%NervesHubWWW.SomeSchema{}) # # We recommend using the bang functions (`insert!`, `update!` # and so on) as they will fail if something goes wrong. # The seeds are run on every deploy. Therefore, it is important # that first check to see if the data you are trying to insert # has been run yet. alias NervesHubWebCore.{Accounts, Accounts.User, Repo, Firmwares} defmodule NervesHubWebCore.SeedHelpers do alias NervesHubWebCore.Fixtures def seed_product(product_name, user, org) do product = Fixtures.product_fixture(user, org, %{name: product_name}) firmware_versions = ["0.1.0", "0.1.1", "0.1.2", "1.0.0"] org_with_keys_and_users = org |> NervesHubWebCore.Accounts.Org.with_org_keys() |> Repo.preload(:users) org_keys = org_with_keys_and_users |> Map.get(:org_keys) user_names = org_with_keys_and_users |> Map.get(:users) |> Enum.map(fn x -> x.username end) firmwares = for v <- firmware_versions, do: Fixtures.firmware_fixture(Enum.random(org_keys), product, %{ version: v, author: Enum.random(user_names) }) firmwares = firmwares |> List.to_tuple() Fixtures.deployment_fixture(org_with_keys_and_users, firmwares |> elem(2), %{ conditions: %{"version" => "< 1.0.0", "tags" => ["beta"]} }) Firmwares.update_firmware_ttl(elem(firmwares, 2).id) Fixtures.device_fixture(org, product, firmwares |> elem(1), %{last_communication: DateTime.utc_now()}) |> Fixtures.device_certificate_fixture() end def nerves_team_seed(root_user_params) do user = Fixtures.user_fixture(root_user_params) [default_user_org | _] = Accounts.get_user_orgs(user) org = Fixtures.org_fixture(user, %{name: "NervesTeam"}) for _ <- 0..2, do: Fixtures.org_key_fixture(org) for _ <- 0..2, do: Fixtures.org_key_fixture(default_user_org) ["SmartKiosk", "SmartRentHub"] |> Enum.map(fn name -> seed_product(name, user, org) end) ["ToyProject", "ConsultingProject"] |> Enum.map(fn name -> seed_product(name, user, default_user_org) end) end end # Create the root user root_user_name = "nerveshub" root_user_email = "[email protected]" # Add a default user if root_user = Repo.get_by(User, email: root_user_email) do root_user else env = if function_exported?(Mix, :env, 0) do Mix.env() |> to_string() else System.get_env("ENVIRONMENT") end if env == "dev" do NervesHubWebCore.SeedHelpers.nerves_team_seed(%{ email: root_user_email, username: root_user_name, password: root_user_name }) else Accounts.create_user(%{ username: root_user_name, email: root_user_email, password: "nerveshub" }) end end
30.822917
106
0.682325
79f342e01c42e8424f95dd6f952d4cb45cde4a45
2,197
exs
Elixir
test/liblink/cluster/fold_server_test.exs
Xerpa/liblink
7b983431c5b391bb8cf182edd9ca4937601eea35
[ "Apache-2.0" ]
3
2018-10-26T12:55:15.000Z
2019-05-03T22:41:34.000Z
test/liblink/cluster/fold_server_test.exs
Xerpa/liblink
7b983431c5b391bb8cf182edd9ca4937601eea35
[ "Apache-2.0" ]
4
2018-08-26T14:43:57.000Z
2020-09-23T21:14:56.000Z
test/liblink/cluster/fold_server_test.exs
Xerpa/liblink
7b983431c5b391bb8cf182edd9ca4937601eea35
[ "Apache-2.0" ]
null
null
null
# Copyright (C) 2018 Xerpa # 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 Liblink.Cluster.FoldServerTest do use ExUnit.Case, async: true alias Liblink.Cluster.FoldServer setup do pid = self() proc = %{ exec: fn {:cont, x} -> send(pid, {:cont, x + 1}) end, halt: fn {:cont, x} -> send(pid, {:halt, x}) end, data: {:cont, 0} } {:ok, [proc: proc]} end test "invokes init hook in the init context", %{proc: proc} do pid = self() {:ok, pid} = FoldServer.start_link( proc: proc, init_hook: fn -> send(pid, {:init, self()}) end, interval_in_ms: 10_000 ) assert_receive {:init, ^pid} end test "invokes exec before first timer", %{proc: proc} do {:ok, _pid} = FoldServer.start_link(proc: proc, interval_in_ms: 10_000) assert_receive {:cont, 1} end test "accumulates data on exec", %{proc: proc} do {:ok, _pid} = FoldServer.start_link(proc: proc, interval_in_ms: 10) assert_receive {:cont, 1} assert_receive {:cont, 2} end test "invokes halt on termination", %{proc: proc} do {:ok, pid} = FoldServer.start_link(proc: proc, interval_in_ms: 10_000) tag = Process.monitor(pid) Process.exit(pid, :normal) assert_receive {:cont, 1} assert_receive {:halt, 1} assert_receive {:DOWN, ^tag, :process, ^pid, :normal} end test "halt message terminates the server", %{proc: proc} do {:ok, pid} = FoldServer.start_link(proc: proc, interval_in_ms: 10_000) tag = Process.monitor(pid) FoldServer.halt(pid) assert_receive {:cont, 1} assert_receive {:halt, 1} assert_receive {:DOWN, ^tag, :process, ^pid, :normal} end end
27.4625
75
0.656805
79f34faa6742c1031080b18d446097208fa898ef
1,468
exs
Elixir
apps/rig_auth/mix.exs
maxglassie/reactive-interaction-gateway
36b68fc75c71b9b4c3b6bd70fb11900c67172137
[ "Apache-2.0" ]
null
null
null
apps/rig_auth/mix.exs
maxglassie/reactive-interaction-gateway
36b68fc75c71b9b4c3b6bd70fb11900c67172137
[ "Apache-2.0" ]
null
null
null
apps/rig_auth/mix.exs
maxglassie/reactive-interaction-gateway
36b68fc75c71b9b4c3b6bd70fb11900c67172137
[ "Apache-2.0" ]
null
null
null
defmodule RigAuth.Mixfile do @moduledoc false use Mix.Project def project do %{rig: rig_version, elixir: elixir_version} = versions() [ app: :rig_auth, version: rig_version, build_path: "../../_build", config_path: "../../config/config.exs", deps_path: "../../deps", lockfile: "../../mix.lock", elixir: elixir_version, elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, deps: deps(), test_coverage: [tool: ExCoveralls] ] end # Run "mix help compile.app" to learn about applications. def application do [ mod: {RigAuth.Application, []}, extra_applications: [:logger] ] end defp versions do {map, []} = Code.eval_file("version", "../..") map end # Specifies which paths to compile per environment. defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] # Run "mix help deps" to learn about dependencies. defp deps do [ {:rig, in_umbrella: true}, {:confex, "~> 3.3"}, {:cowboy, "~> 1.0"}, {:httpoison, "~> 1.3"}, {:joken, "~> 1.5"}, {:phoenix, "~> 1.3.0"}, {:plug, "~> 1.4"}, {:poison, "~> 2.0 or ~> 3.0"}, {:stubr, "~> 1.5.0", only: :test}, {:timex, "~> 3.4"}, # JSON Pointer (RFC 6901) implementation for extracting the session name from JWTs: {:odgn_json_pointer, "~> 2.3"} ] end end
25.310345
89
0.55654
79f37180e02419b42ee93887afeaaa666361c136
990
ex
Elixir
lib/gaga/application.ex
madvoidhq/gaga
1a539edc327135c7910a51bffd6824bddcba5f7d
[ "MIT" ]
13
2020-11-22T18:43:21.000Z
2022-02-12T00:57:45.000Z
lib/gaga/application.ex
madvoidhq/gaga
1a539edc327135c7910a51bffd6824bddcba5f7d
[ "MIT" ]
2
2020-11-25T16:58:15.000Z
2021-06-21T12:02:41.000Z
lib/gaga/application.ex
madvoidhq/gaga
1a539edc327135c7910a51bffd6824bddcba5f7d
[ "MIT" ]
4
2020-11-23T08:14:03.000Z
2022-01-25T08:18:41.000Z
defmodule Gaga.Application do # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications @moduledoc false use Application def start(_type, _args) do children = [ # Start the Telemetry supervisor GagaWeb.Telemetry, # Start the PubSub system {Phoenix.PubSub, name: Gaga.PubSub}, # Start the Endpoint (http/https) GagaWeb.Endpoint, # Start the Presence system GagaWeb.Presence # Start a worker by calling: Gaga.Worker.start_link(arg) # {Gaga.Worker, arg} ] # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: Gaga.Supervisor] Supervisor.start_link(children, opts) end # Tell Phoenix to update the endpoint configuration # whenever the application is updated. def config_change(changed, _new, removed) do GagaWeb.Endpoint.config_change(changed, removed) :ok end end
28.285714
62
0.69596
79f388c9f5bd2fdcb360af1ffcd4cf316954d77d
1,861
exs
Elixir
apps/ehealth/test/web/controllers/service_controller_test.exs
ehealth-ua/ehealth.api
4ffe26a464fe40c95fb841a4aa2e147068f65ca2
[ "Apache-2.0" ]
8
2019-06-14T11:34:49.000Z
2021-08-05T19:14:24.000Z
apps/ehealth/test/web/controllers/service_controller_test.exs
edenlabllc/ehealth.api.public
4ffe26a464fe40c95fb841a4aa2e147068f65ca2
[ "Apache-2.0" ]
1
2019-07-08T15:20:22.000Z
2019-07-08T15:20:22.000Z
apps/ehealth/test/web/controllers/service_controller_test.exs
ehealth-ua/ehealth.api
4ffe26a464fe40c95fb841a4aa2e147068f65ca2
[ "Apache-2.0" ]
6
2018-05-11T13:59:32.000Z
2022-01-19T20:15:22.000Z
defmodule EHealth.Web.ServiceControllerTest do @moduledoc false use EHealth.Web.ConnCase describe "get services" do test "success get services", %{conn: conn} do group1 = insert(:prm, :service_group, code: "G1") group2 = insert(:prm, :service_group, code: "G2") group3 = insert(:prm, :service_group, parent_id: group1.id, code: "G3") group4 = insert(:prm, :service_group, parent_id: group2.id, code: "G4") group5 = insert(:prm, :service_group, parent_id: group3.id, code: "G5") group6 = insert(:prm, :service_group, parent_id: group2.id, code: "G6") service1 = insert(:prm, :service) service2 = insert(:prm, :service) insert(:prm, :service_inclusion, service: service1, service_group: group5, alias: "УЗД1") insert(:prm, :service_inclusion, service: service2, service_group: group5) insert(:prm, :service_inclusion, service: service1, service_group: group4, alias: "УЗД2") insert(:prm, :service_inclusion, service: service1, service_group: group6, alias: "УЗД3") conn = get(conn, service_path(conn, :index)) data = json_response(conn, 200)["data"] assert Enum.map(data, &Map.get(&1, "id")) -- [group1.id, group2.id] == [] group1_response = Enum.find(data, fn v -> v["id"] == group1.id end) assert group1_response |> Map.get("groups") |> hd() |> Map.get("id") == group3.id assert group1_response |> Map.get("groups") |> hd() |> Map.get("groups") |> hd() |> Map.get("id") == group5.id services = group1_response |> Map.get("groups") |> hd() |> Map.get("groups") |> hd() |> Map.get("services") assert Enum.map(services, &Map.get(&1, "id")) -- [service1.id, service2.id] == [] assert Enum.map(services, &Map.get(&1, "name")) -- ["УЗД1", service2.name] == [] end end end
45.390244
116
0.618485
79f3aaba5167a9d5c87974b860259eadb61df6c9
1,298
ex
Elixir
installer/phoenix/templates/test_helpers.ex
elixircnx/sanction
5b270fd6eef980d37c06429271f64ec14e0f622d
[ "BSD-3-Clause" ]
130
2016-06-21T07:58:46.000Z
2022-01-01T21:45:23.000Z
installer/phoenix/templates/test_helpers.ex
elixircnx/sanction
5b270fd6eef980d37c06429271f64ec14e0f622d
[ "BSD-3-Clause" ]
50
2016-06-29T16:01:42.000Z
2019-08-07T21:33:49.000Z
installer/phoenix/templates/test_helpers.ex
elixircnx/sanction
5b270fd6eef980d37c06429271f64ec14e0f622d
[ "BSD-3-Clause" ]
20
2016-07-02T11:37:33.000Z
2018-10-26T19:12:41.000Z
defmodule <%= base %>.TestHelpers do<%= if api do %> use Phoenix.ConnTest<% end %> <%= if confirm do %> import Ecto.Changeset <% end %> alias <%= base %>.{Repo, User} def add_user(username) do user = %{username: username, email: "#{username}@mail.com", password: "mangoes&g0oseberries"}<%= if confirm do %> key = "pu9-VNdgE8V9qZo19rlcg3KUNjpxuixg"<% end %> %User{}<%= if confirm do %> |> User.auth_changeset(user, key)<% else %> |> User.auth_changeset(user)<% end %> |> Repo.insert! end<%= if confirm do %> def add_user_confirmed(username) do add_user(username) Repo.get_by(User, %{username: username}) |> change(%{confirmed_at: Ecto.DateTime.utc}) |> Repo.update! end def add_reset(username) do user = %{username: username, email: "#{username}@mail.com", password: "mangoes&g0oseberries"} key = "pu9-VNdgE8V9qZo19rlcg3KUNjpxuixg" %User{} |> User.auth_changeset(user, key) |> User.reset_changeset(user, key) |> Repo.insert! end<% end %> <%= if api do %> def add_token_conn(conn, user) do user_token = Phoenix.Token.sign(<%= base %>.Endpoint, "user token", user.id) conn |> put_req_header("accept", "application/json") |> put_req_header("authorization", user_token) end <% end %> end
30.186047
80
0.633282
79f3bb0b75e79effa784ab4677fafb5d4cac5e32
14,953
ex
Elixir
clients/cloud_private_catalog_producer/lib/google_api/cloud_private_catalog_producer/v1beta1/api/operations.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/cloud_private_catalog_producer/lib/google_api/cloud_private_catalog_producer/v1beta1/api/operations.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/cloud_private_catalog_producer/lib/google_api/cloud_private_catalog_producer/v1beta1/api/operations.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "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.CloudPrivateCatalogProducer.V1beta1.Api.Operations do @moduledoc """ API calls for all endpoints tagged `Operations`. """ alias GoogleApi.CloudPrivateCatalogProducer.V1beta1.Connection alias GoogleApi.Gax.{Request, Response} @library_version Mix.Project.config() |> Keyword.get(:version, "") @doc """ Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`. ## Parameters * `connection` (*type:* `GoogleApi.CloudPrivateCatalogProducer.V1beta1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - The name of the operation resource to be cancelled. * `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.CloudPrivateCatalogProducer.V1beta1.Model.GoogleLongrunningCancelOperationRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.CloudPrivateCatalogProducer.V1beta1.Model.GoogleProtobufEmpty{}}` on success * `{:error, info}` on failure """ @spec cloudprivatecatalogproducer_operations_cancel( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.CloudPrivateCatalogProducer.V1beta1.Model.GoogleProtobufEmpty.t()} | {:ok, Tesla.Env.t()} | {:error, Tesla.Env.t()} def cloudprivatecatalogproducer_operations_cancel( connection, name, 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("/v1beta1/{+name}:cancel", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.CloudPrivateCatalogProducer.V1beta1.Model.GoogleProtobufEmpty{}] ) end @doc """ Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. ## Parameters * `connection` (*type:* `GoogleApi.CloudPrivateCatalogProducer.V1beta1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - The name of the operation resource to be deleted. * `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.CloudPrivateCatalogProducer.V1beta1.Model.GoogleProtobufEmpty{}}` on success * `{:error, info}` on failure """ @spec cloudprivatecatalogproducer_operations_delete( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.CloudPrivateCatalogProducer.V1beta1.Model.GoogleProtobufEmpty.t()} | {:ok, Tesla.Env.t()} | {:error, Tesla.Env.t()} def cloudprivatecatalogproducer_operations_delete( connection, name, 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("/v1beta1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.CloudPrivateCatalogProducer.V1beta1.Model.GoogleProtobufEmpty{}] ) end @doc """ Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. ## Parameters * `connection` (*type:* `GoogleApi.CloudPrivateCatalogProducer.V1beta1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - The name of the operation resource. * `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.CloudPrivateCatalogProducer.V1beta1.Model.GoogleLongrunningOperation{}}` on success * `{:error, info}` on failure """ @spec cloudprivatecatalogproducer_operations_get( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.CloudPrivateCatalogProducer.V1beta1.Model.GoogleLongrunningOperation.t()} | {:ok, Tesla.Env.t()} | {:error, Tesla.Env.t()} def cloudprivatecatalogproducer_operations_get( connection, name, 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("/v1beta1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [ struct: %GoogleApi.CloudPrivateCatalogProducer.V1beta1.Model.GoogleLongrunningOperation{} ] ) end @doc """ Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding allows API services to override the binding to use different resource name schemes, such as `users/*/operations`. To override the binding, API services can add a binding such as `"/v1/{name=users/*}/operations"` to their service configuration. For backwards compatibility, the default name includes the operations collection id, however overriding users must ensure the name binding is the parent resource, without the operations collection id. ## Parameters * `connection` (*type:* `GoogleApi.CloudPrivateCatalogProducer.V1beta1.Connection.t`) - Connection to server * `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`) - The standard list filter. * `:name` (*type:* `String.t`) - The name of the operation's parent resource. * `:pageSize` (*type:* `integer()`) - The standard list page size. * `:pageToken` (*type:* `String.t`) - The standard list page token. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.CloudPrivateCatalogProducer.V1beta1.Model.GoogleLongrunningListOperationsResponse{}}` on success * `{:error, info}` on failure """ @spec cloudprivatecatalogproducer_operations_list(Tesla.Env.client(), keyword(), keyword()) :: {:ok, GoogleApi.CloudPrivateCatalogProducer.V1beta1.Model.GoogleLongrunningListOperationsResponse.t()} | {:ok, Tesla.Env.t()} | {:error, Tesla.Env.t()} def cloudprivatecatalogproducer_operations_list(connection, 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, :name => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1beta1/operations", %{}) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [ struct: %GoogleApi.CloudPrivateCatalogProducer.V1beta1.Model.GoogleLongrunningListOperationsResponse{} ] ) end end
43.722222
196
0.638802
79f3c1d9f487b8c17f47a95d27e3dfbe5a273e93
1,447
exs
Elixir
config/config.exs
gnucifer/open-food-hub
24632b6e8a01253c716db976d78a313746d5e38f
[ "BSD-3-Clause" ]
null
null
null
config/config.exs
gnucifer/open-food-hub
24632b6e8a01253c716db976d78a313746d5e38f
[ "BSD-3-Clause" ]
null
null
null
config/config.exs
gnucifer/open-food-hub
24632b6e8a01253c716db976d78a313746d5e38f
[ "BSD-3-Clause" ]
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 # General application configuration config :ofh, [ ecto_repos: [Ofh.Repo], generators: [binary_id: true] ] # Configures the endpoint config :ofh, OfhWeb.Endpoint, [ url: [host: "localhost"], secret_key_base: "YOh4lRVp2/Ofyo7pKmuSQ4b/Z1l0+zcc/a5LKQCszUEpFkn44iv638dBiD3uw6tT", render_errors: [view: OfhWeb.ErrorView, accepts: ~w(json)], pubsub: [name: Ofh.PubSub, adapter: Phoenix.PubSub.PG2] ] # Configures Elixir's Logger config :logger, :console, [ format: "$time $metadata[$level] $message\n", metadata: [:request_id] ] config :ofh, Ofh.UserAuthTokens, [ issuer: "ofh", secret_key: "T2y4/ZS0f/19uQm4otUVzVewfSZIa9DyMr8Bcg02q+S5yZgAI8of3RPeb9XnEYlZ" ] config :ofh, OfhWeb.AuthAccessPipeline, [ module: Ofh.UserAuthTokens, error_handler: OfhWeb.AuthErrorHandler ] config :ueberauth, Ueberauth, [ base_path: "/auth", providers: [ google: {Ueberauth.Strategy.Google, []} ] ] config :phoenix, :format_encoders, [ "json-api": Poison ] config :plug, :mimes, %{ "application/vnd.api+json" => ["json-api"] } # 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"
25.839286
86
0.734623
79f3d34479c890c7aeed4c9ce9c46bdbfef54595
1,148
ex
Elixir
lib/team_budget/accounts/core/guardian.ex
AkioCode/elxpro4-teambudget
a7e67d5e1ec538df6cc369cc4f385d005bf60eda
[ "MIT" ]
null
null
null
lib/team_budget/accounts/core/guardian.ex
AkioCode/elxpro4-teambudget
a7e67d5e1ec538df6cc369cc4f385d005bf60eda
[ "MIT" ]
null
null
null
lib/team_budget/accounts/core/guardian.ex
AkioCode/elxpro4-teambudget
a7e67d5e1ec538df6cc369cc4f385d005bf60eda
[ "MIT" ]
null
null
null
defmodule TeamBudget.Accounts.Core.Guardian do use Guardian, otp_app: :team_budget def subject_for_token(resource, _claims) do # You can use any value for the subject of your token but # it should be useful in retrieving the resource later, see # how it being used on `resource_from_claims/1` function. # A unique `id` is a good subject, a non-unique email address # is a poor subject. sub = to_string(resource.id) {:ok, sub} end def subject_for_token(_, _) do {:error, :reason_for_error} end def resource_from_claims(%{"sub" => id}) do # Here we'll look up our resource from the claims, the subject can be # found in the `"sub"` key. In `above subject_for_token/2` we returned # the resource id so here we'll rely on that to look it up. resource = TeamBudget.Accounts.Core.UserRepo.get_user!(id) {:ok, resource} end def resource_from_claims(_claims) do {:error, :reason_for_error} end def sign_in(%TeamBudget.Accounts.Data.User{} = user), do: Guardian.encode_and_sign(__MODULE__, user) def verify(token), do: Guardian.decode_and_verify(__MODULE__, token) end
32.8
74
0.707317
79f3dffcc4cd42c1780ce3f45cb521d32d735f6c
20,487
exs
Elixir
test/livebook/live_markdown/import_test.exs
doyobi/livebook
136d5039c42b406dd0b31aea188deb4fce3b1328
[ "Apache-2.0" ]
1
2022-02-16T09:13:27.000Z
2022-02-16T09:13:27.000Z
test/livebook/live_markdown/import_test.exs
doyobi/livebook
136d5039c42b406dd0b31aea188deb4fce3b1328
[ "Apache-2.0" ]
null
null
null
test/livebook/live_markdown/import_test.exs
doyobi/livebook
136d5039c42b406dd0b31aea188deb4fce3b1328
[ "Apache-2.0" ]
null
null
null
defmodule Livebook.LiveMarkdown.ImportTest do use ExUnit.Case, async: true alias Livebook.LiveMarkdown.Import alias Livebook.Notebook alias Livebook.Notebook.Cell test "acceptance" do markdown = """ # My Notebook ## Section 1 Make sure to install: * Erlang * Elixir * PostgreSQL $x_{i} + y_{i}$ <!-- livebook:{"disable_formatting":true,"reevaluate_automatically":true} --> ```elixir Enum.to_list(1..10) ``` This is it for this section. ## Section 2 ```elixir IO.gets("length: ") ``` <!-- livebook:{"branch_parent_index":1} --> ## Section 3 ```elixir Process.info() ``` """ {notebook, []} = Import.notebook_from_livemd(markdown) # Match only on the relevant fields as some may be generated (ids). assert %Notebook{ name: "My Notebook", sections: [ %Notebook.Section{ name: "Section 1", cells: [ %Cell.Markdown{ source: """ Make sure to install: * Erlang * Elixir * PostgreSQL $x_{i} + y_{i}$\ """ }, %Cell.Elixir{ disable_formatting: true, reevaluate_automatically: true, source: """ Enum.to_list(1..10)\ """ }, %Cell.Markdown{ source: """ This is it for this section.\ """ } ] }, %Notebook.Section{ id: section2_id, name: "Section 2", cells: [ %Cell.Elixir{ source: """ IO.gets("length: ")\ """ } ] }, %Notebook.Section{ name: "Section 3", parent_id: section2_id, cells: [ %Cell.Elixir{ source: """ Process.info()\ """ } ] } ] } = notebook end test "reformats markdown cells" do markdown = """ # My Notebook ## Section 1 |State|Abbrev|Capital| | --: | :-: | --- | | Texas | TX | Austin | | Maine | ME | Augusta | """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", sections: [ %Notebook.Section{ name: "Section 1", cells: [ %Cell.Markdown{ source: """ | State | Abbrev | Capital | | ----: | :----: | ------- | | Texas | TX | Austin | | Maine | ME | Augusta |\ """ } ] } ] } = notebook end test "uses default name if there is no primary heading" do markdown = """ ## Section 1 Some markdown. """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "Untitled notebook", sections: [ %Notebook.Section{ name: "Section 1" } ] } = notebook end test "given multiple primary heading, downgrades all headings" do markdown = """ # Probably section 1 ## Heading Some markdown. # Probably section 2 ###### Tiny heading """ {notebook, messages} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "Untitled notebook", sections: [ %Notebook.Section{ name: "Probably section 1", cells: [ %Cell.Markdown{ source: """ ### Heading Some markdown.\ """ } ] }, %Notebook.Section{ name: "Probably section 2", cells: [ %Cell.Markdown{ source: """ **Tiny heading**\ """ } ] } ] } = notebook assert ["Downgrading all headings, because 2 instances of heading 1 were found"] == messages end test "preserves markdown modifiers in notebok/section names" do markdown = """ # My *Notebook* ## [Section 1](https://example.com) ## --- ## # Section """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My *Notebook*", sections: [ %Notebook.Section{name: "[Section 1](https://example.com)"}, %Notebook.Section{name: "---"}, %Notebook.Section{name: "# Section"} ] } = notebook end test "adds a default section if there is some section-less content" do markdown = """ # My Notebook Some markdown. ## Actual section """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", sections: [ %Notebook.Section{ name: "Section", cells: [ %Cell.Markdown{ source: """ Some markdown.\ """ } ] }, %Notebook.Section{ name: "Actual section" } ] } = notebook end test "uses defaults if there are no headings" do markdown = """ ```elixir Enum.to_list(1..10) ``` """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "Untitled notebook", sections: [ %Notebook.Section{ name: "Section", cells: [ %Cell.Elixir{ source: """ Enum.to_list(1..10)\ """ } ] } ] } = notebook end test "moves the primary heading and preceding comments to the top" do markdown = """ Cool notebook. <!-- livebook:{"author":"Sherlock Holmes"} --> # My Notebook Some markdown. """ {notebook, messages} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", sections: [ %Notebook.Section{ name: "Section", cells: [ %Cell.Markdown{ source: """ Cool notebook. Some markdown.\ """ } ] } ] } = notebook assert ["Moving heading 1 to the top of the notebook"] == messages end test "includes parsing warnings in the returned message list" do markdown = """ # My notebook ` Some markdown. """ {_notebook, messages} = Import.notebook_from_livemd(markdown) assert ["Line 3: Closing unclosed backquotes ` at end of input"] == messages end test "imports non-elixir code snippets as part of markdown cells" do markdown = """ # My Notebook ## Section 1 ```shell mix deps.get ``` ```elixir Enum.to_list(1..10) ``` <!-- livebook:{"force_markdown":true} --> ```erlang spawn_link(fun() -> io:format("Hiya") end). ``` """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", sections: [ %Notebook.Section{ name: "Section 1", cells: [ %Cell.Markdown{ source: """ ```shell mix deps.get ```\ """ }, %Cell.Elixir{ source: """ Enum.to_list(1..10)\ """ }, %Cell.Markdown{ source: """ ```erlang spawn_link(fun() -> io:format("Hiya") end). ```\ """ } ] } ] } = notebook end test "imports elixir snippets as part of markdown cells if marked as such" do markdown = """ # My Notebook ## Section 1 <!-- livebook:{"force_markdown":true} --> ```elixir [1, 2, 3] ``` ## Section 2 Some markdown. <!-- livebook:{"force_markdown":true} --> ```elixir [1, 2, 3] ``` """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", sections: [ %Notebook.Section{ name: "Section 1", cells: [ %Cell.Markdown{ source: """ ```elixir [1, 2, 3] ```\ """ } ] }, %Notebook.Section{ name: "Section 2", cells: [ %Cell.Markdown{ source: """ Some markdown. ```elixir [1, 2, 3] ```\ """ } ] } ] } = notebook end test "imports markdown content into separate cells when a break annotation is encountered" do markdown = """ # My Notebook ## Section 1 Cell 1 <!-- livebook:{"break_markdown":true} --> Cell 2 """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", sections: [ %Notebook.Section{ name: "Section 1", cells: [ %Cell.Markdown{ source: """ Cell 1\ """ }, %Cell.Markdown{ source: """ Cell 2\ """ } ] } ] } = notebook end test "imports comments preceding the notebook title" do markdown = """ <!-- vim: set syntax=markdown: --> <!--nowhitespace--> <!-- Multi line --> <!-- livebook:{"persist_outputs":true} --> # My Notebook ## Section 1 Cell 1 """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", persist_outputs: true, leading_comments: [ ["vim: set syntax=markdown:"], ["nowhitespace"], [" Multi", " line"] ], sections: [ %Notebook.Section{ name: "Section 1", cells: [ %Cell.Markdown{ source: """ Cell 1\ """ } ] } ] } = notebook end test "warns when custom comments are mixed with notebook metadata" do markdown = """ <!-- livebook:{"persist_outputs":true} --> <!-- vim: set syntax=markdown: --> # My Notebook ## Section 1 Cell 1 """ {notebook, [ "found an invalid sequence of comments at the beginning, make sure custom comments are at the very top" ]} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", persist_outputs: false, leading_comments: [], sections: [ %Notebook.Section{ name: "Section 1", cells: [ %Cell.Markdown{ source: """ Cell 1\ """ } ] } ] } = notebook end describe "outputs" do test "imports output snippets as cell textual outputs" do markdown = """ # My Notebook ## Section 1 ```elixir IO.puts("hey") ``` <!-- livebook:{"output":true} --> ``` hey ``` <!-- livebook:{"output":true} --> ``` :ok ``` """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", sections: [ %Notebook.Section{ name: "Section 1", cells: [ %Cell.Elixir{ source: """ IO.puts("hey")\ """, outputs: [{0, {:text, ":ok"}}, {1, {:text, "hey"}}] } ] } ], output_counter: 2 } = notebook end test "discards other output snippets" do markdown = """ # My Notebook ## Section 1 ```elixir IO.puts("hey") ``` ```elixir plot() ``` <!-- livebook:{"output":true} --> ```vega-lite {} ``` ```elixir :ok ``` """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", sections: [ %Notebook.Section{ name: "Section 1", cells: [ %Cell.Elixir{ source: """ IO.puts("hey")\ """, outputs: [] }, %Cell.Elixir{ source: """ plot()\ """, outputs: [] }, %Cell.Elixir{ source: """ :ok\ """, outputs: [] } ] } ] } = notebook end test "imports notebook :persist_outputs attribute" do markdown = """ <!-- livebook:{"persist_outputs":true} --> # My Notebook """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{name: "My Notebook", persist_outputs: true} = notebook end end test "imports notebook :autosave_interval_s attribute" do markdown = """ <!-- livebook:{"autosave_interval_s":10} --> # My Notebook """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{name: "My Notebook", autosave_interval_s: 10} = notebook end describe "backward compatibility" do test "warns if the imported notebook includes an input" do markdown = """ # My Notebook ## Section 1 <!-- livebook:{"livebook_object":"cell_input","name":"length","type":"text","value":"100"} --> """ {_notebook, messages} = Import.notebook_from_livemd(markdown) assert [ "found an input cell, but those are no longer supported, please use Kino.Input instead" ] == messages end test "warns if the imported notebook includes a reactive input" do markdown = """ # My Notebook ## Section 1 <!-- livebook:{"livebook_object":"cell_input","name":"length","reactive":true,"type":"text","value":"100"} --> """ {_notebook, messages} = Import.notebook_from_livemd(markdown) assert [ "found an input cell, but those are no longer supported, please use Kino.Input instead." <> " Also, to make the input reactive you can use an automatically reevaluating cell" ] == messages end test "imports snippets with output info string" do # We now explicitly mark every output sinppet with <!-- livebook:{"output":true} --> # and use empty snippets for textual outputs, however previously # we supported ```output too, so let's ensure they still work markdown = """ # My Notebook ## Section 1 ```elixir IO.puts("hey") ``` ```output hey ``` ```output :ok ``` """ {notebook, []} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", sections: [ %Notebook.Section{ name: "Section 1", cells: [ %Cell.Elixir{ source: """ IO.puts("hey")\ """, outputs: [{0, {:text, ":ok"}}, {1, {:text, "hey"}}] } ] } ], output_counter: 2 } = notebook end end test "import notebook with invalid parent section produces a warning" do markdown = """ # My Notebook <!-- livebook:{"branch_parent_index":4} --> ## Section 1 ```elixir Process.info() ``` ## Section 2 ```elixir Process.info() ``` """ assert {notebook, [ "ignoring the parent section of \"Section 1\", because it comes later in the notebook" ]} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", sections: [ %Notebook.Section{ parent_id: nil }, %Notebook.Section{ parent_id: nil } ] } = notebook end test "import notebook with parent section pointing to the section itself produces a warning" do markdown = """ # My Notebook <!-- livebook:{"branch_parent_index":0} --> ## Section 1 ```elixir Process.info() ``` """ assert {notebook, [ "ignoring the parent section of \"Section 1\", because it comes later in the notebook" ]} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", sections: [ %Notebook.Section{ parent_id: nil } ] } = notebook end test "import notebook with parent section being a branching section itself produces a warning" do markdown = """ # My Notebook ## Section 1 ```elixir Process.info() ``` <!-- livebook:{"branch_parent_index":0} --> ## Section 2 ```elixir Process.info() ``` <!-- livebook:{"branch_parent_index":1} --> ## Section 3 ```elixir Process.info() ``` """ assert {notebook, [ "ignoring the parent section of \"Section 3\", because it is itself a branching section" ]} = Import.notebook_from_livemd(markdown) assert %Notebook{ name: "My Notebook", sections: [ %Notebook.Section{ name: "Section 1", parent_id: nil }, %Notebook.Section{ name: "Section 2", parent_id: _ }, %Notebook.Section{ name: "Section 3", parent_id: nil } ] } = notebook end end
23.123025
116
0.409674
79f3e95e7c6bd257ef761c04bba362ec2f9d37d5
2,199
ex
Elixir
lib/discovergy/client.ex
adriankumpf/discovergy
9424bc00e31e097ef07c70fd19722a12db0c6508
[ "MIT" ]
null
null
null
lib/discovergy/client.ex
adriankumpf/discovergy
9424bc00e31e097ef07c70fd19722a12db0c6508
[ "MIT" ]
22
2020-07-11T12:57:25.000Z
2022-03-04T09:22:52.000Z
lib/discovergy/client.ex
adriankumpf/discovergy
9424bc00e31e097ef07c70fd19722a12db0c6508
[ "MIT" ]
null
null
null
defmodule Discovergy.Client do @moduledoc """ A Discovergy API Client """ alias Discovergy.{OAuth, Error} @opaque t :: %__MODULE__{} @enforce_keys [:tesla_client, :base_url] defstruct [:tesla_client, :base_url, :consumer, :token] @base_url "https://api.discovergy.com/public/v1" @adapter {Tesla.Adapter.Hackney, pool: :default} @doc """ Creates a new Discovergy API client. ## Options * `:consumer` - a custom consumer token (see `Discovergy.OAuth.Consumer`) * `:token` - a custom access token (see `Discovergyee.OAuth.Token`) * `:base_url` - the base URL for all endpoints (default: `#{@base_url}`) * `:adapter` - the [Tesla adapter](https://hexdoks.pm/tesla/readme.html) for the API client (default: `#{inspect(@adapter)}`) ## Examples iex> client = Discovergy.Client.new() %Discovergy.Client{} """ @spec new(Keyword.t()) :: t def new(opts \\ []) do base_url = opts[:base_url] || @base_url adapter = opts[:adapter] || @adapter consumer = opts[:consumer] token = opts[:token] middlewares = [ {Tesla.Middleware.BaseUrl, base_url}, {Tesla.Middleware.Headers, [{"user-agent", "github.com/adriankumpf/discovergy"}]}, Discovergy.OAuth.Middleware, Tesla.Middleware.FormUrlencoded, Tesla.Middleware.JSON ] tesla_client = Tesla.client(middlewares, adapter) %__MODULE__{ tesla_client: tesla_client, base_url: base_url, consumer: consumer, token: token } end @doc """ Authenticate with the Discovergy API using the email address and password of the user. ## Examples iex> {:ok, client} = Discovergy.Client.new() ...> |> Discovergy.Client.login(email, password) {:ok, %Discovergy.Client{}} """ @spec login(t, String.t(), String.t()) :: {:ok, t} | {:error, Error.t()} def login(%__MODULE__{} = client, email, password) when is_binary(email) and is_binary(password) do with client = %__MODULE__{client | token: nil}, {:ok, {consumer, token}} <- OAuth.login(client, email, password) do {:ok, %__MODULE__{client | token: token, consumer: consumer}} end end end
28.192308
88
0.635744
79f40410a76b7d9c36958b0c1cefd5c7cac68f30
3,013
exs
Elixir
test/teslamate_web/controllers/drive_controller_test.exs
kuma/teslamate
ea175fddb49cc08070182455e0073c3dcfcb3b4c
[ "MIT" ]
2,602
2019-07-24T23:19:12.000Z
2022-03-31T15:03:48.000Z
test/teslamate_web/controllers/drive_controller_test.exs
kuma/teslamate
ea175fddb49cc08070182455e0073c3dcfcb3b4c
[ "MIT" ]
1,547
2019-07-26T22:02:09.000Z
2022-03-31T15:39:41.000Z
test/teslamate_web/controllers/drive_controller_test.exs
kuma/teslamate
ea175fddb49cc08070182455e0073c3dcfcb3b4c
[ "MIT" ]
524
2019-07-26T17:31:33.000Z
2022-03-29T15:16:36.000Z
defmodule TeslaMateWeb.DriveControllerTest do use TeslaMateWeb.ConnCase alias TeslaMate.Log alias TeslaMate.Repo def car_fixture(attrs \\ %{}) do {:ok, car} = attrs |> Enum.into(%{efficiency: 0.153, eid: 42, model: "M3", vid: 42, vin: "xxxxx"}) |> Log.create_car() car end defp drive_fixture(car) do {:ok, drive} = Log.start_drive(car) Log.insert_position(drive, %{ date: DateTime.utc_now(), latitude: 5.0, longitude: 5.0, elevation: 100 }) Log.insert_position(drive, %{ date: DateTime.utc_now(), latitude: 10.0, longitude: 10.0, elevation: 200 }) Log.insert_position(drive, %{ date: DateTime.utc_now() |> DateTime.add(-3600, :second), latitude: 0.0, longitude: 0.0, elevation: 50 }) drive |> Repo.preload(:positions) end describe "GET /drive/:id/gpx" do test "sets xml and content-disposition headers", %{conn: conn} do drive = drive_fixture(car_fixture()) assert conn = get(conn, Routes.drive_path(conn, :gpx, drive.id)) headers = Enum.into(conn.resp_headers, %{}) assert headers["content-disposition"] == ~s(attachment; filename="#{drive.start_date}.gpx") assert response_content_type(conn, :xml) =~ "charset=utf-8" end test "renders gpx", %{conn: conn} do drive = drive_fixture(car_fixture()) assert conn = get(conn, Routes.drive_path(conn, :gpx, drive.id)) xml = response(conn, 200) assert xml =~ ~s(<gpx version="1.1") document = Floki.parse_document!(xml) xml_trackpoints = get_trackpoints(document) drive_trackpoints = drive_trackpoints_to_trackpoints(drive) |> Enum.sort_by(& &1.time) assert xml_trackpoints == drive_trackpoints track_name = document |> Floki.find("name") |> Floki.text() assert track_name == DateTime.to_iso8601(drive.start_date) end test "returns 404 on drive not found", %{conn: conn} do assert conn = get(conn, Routes.drive_path(conn, :gpx, "4")) assert conn.status == 404 end defp drive_trackpoints_to_trackpoints(drive) do Enum.map(drive.positions, fn pos -> %{ latitude: pos.latitude |> Decimal.to_string(), longitude: pos.longitude |> Decimal.to_string(), time: pos.date |> DateTime.to_iso8601(), elevation: pos.elevation |> Integer.to_string() } end) end defp get_trackpoints(document) do document |> Floki.find("gpx trk trkseg trkpt") |> Enum.map(&parse_trackpoint/1) end defp parse_trackpoint(trkpt) do latitude = Floki.attribute(trkpt, "lat") longitude = Floki.attribute(trkpt, "lon") time = Floki.find(trkpt, "time") |> Floki.text() elevation = Floki.find(trkpt, "ele") |> Floki.text() %{ latitude: Enum.at(latitude, 0), longitude: Enum.at(longitude, 0), time: time, elevation: elevation } end end end
28.158879
97
0.618321
79f41a1ce1a71bc8d4c9e236508b071f7cf6c9ec
444
ex
Elixir
web/models/deliveryservice_server.ex
rob05c/tox
f54847ca058ad24b909341ad65d595a4069d2471
[ "Apache-2.0" ]
2
2016-11-16T17:24:21.000Z
2019-02-15T05:38:27.000Z
web/models/deliveryservice_server.ex
rob05c/tox
f54847ca058ad24b909341ad65d595a4069d2471
[ "Apache-2.0" ]
null
null
null
web/models/deliveryservice_server.ex
rob05c/tox
f54847ca058ad24b909341ad65d595a4069d2471
[ "Apache-2.0" ]
null
null
null
defmodule Tox.DeliveryserviceServer do use Tox.Web, :model schema "deliveryserviceservers" do field :deliveryservice, :integer field :server_host, :integer timestamps() end @doc """ Builds a changeset based on the `struct` and `params`. """ def changeset(struct, params \\ %{}) do struct |> cast(params, [:deliveryservice, :server_host]) |> validate_required([:deliveryservice, :server_host]) end end
22.2
58
0.682432
79f464f9f92776fdea60f0ce0b7b557f550e5dad
6,833
ex
Elixir
lib/helpers.ex
bonfire-networks/grumble
4f3ea815a51a9ef045fd49a44bb54e488a2083c9
[ "Apache-2.0" ]
1
2020-03-30T11:34:07.000Z
2020-03-30T11:34:07.000Z
lib/helpers.ex
bonfire-networks/grumble
4f3ea815a51a9ef045fd49a44bb54e488a2083c9
[ "Apache-2.0" ]
null
null
null
lib/helpers.ex
bonfire-networks/grumble
4f3ea815a51a9ef045fd49a44bb54e488a2083c9
[ "Apache-2.0" ]
null
null
null
# Grumble - a DSL for building GraphQL queries as data structures. # # Copyright (c) 2020 James Laver # # 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 Grumble.Helpers do # Directive, FragmentDef, FragmentSpread, FragmentItem alias Grumble.{Arg, Field, Query, Param, Type, Var} @type predicate :: (term -> boolean) @spec field_case(atom | binary) :: binary def field_case(name) when is_binary(name), do: name def field_case(name) when is_atom(name), do: Recase.to_camel(Atom.to_string(name)) @spec type_case(atom | binary) :: binary def type_case(:id), do: "ID" def type_case(name) when is_binary(name), do: name def type_case(name) when is_atom(name), do: Recase.to_pascal(Atom.to_string(name)) @spec string_literal(binary) :: iolist def string_literal(string), do: ["\"", escape_string(string, []), "\""] @spec validate(test :: predicate, subject :: term, error_tag :: term) :: term def validate(pred, val, error) when is_function(pred) do if pred.(val), do: val, else: throw({error, val}) end @spec operation?(term) :: boolean def operation?(:query), do: true def operation?(:mutation), do: true def operation?(:subscription), do: true def operation?(_), do: false @spec name?(term) :: boolean def name?(""), do: false def name?(name) when is_atom(name), do: name?(Atom.to_string(name)) def name?(<<start::utf8, rest::binary>>), do: name_start?(start) and every?(&name_continue?/1, rest) def name?(_), do: false @spec value?(term) :: boolean def value?(nil), do: true def value?(x) when is_number(x) or is_boolean(x) or is_binary(x), do: true def value?(x) when is_list(x), do: Enum.all?(x, &value?/1) def value?(%{__struct__: Var}), do: true def value?(%{__struct__: Arg}), do: false # def value?(%{__struct__: Directive}), do: false def value?(%{__struct__: Field}), do: false # def value?(%{__struct__: FragmentDef}), do: false # def value?(%{__struct__: FragmentSpread}), do: false # def value?(%{__struct__: InlineFragment}), do: false def value?(%{__struct__: Query}), do: false def value?(%{__struct__: Param}), do: false def value?(%{__struct__: Type}), do: false def value?(%{} = fields), do: Enum.all?(Map.delete(fields, :__struct__), fn {k, v} -> name?(k) and value?(v) end) def value?(_), do: false @spec const_value?(term) :: boolean def const_value?(nil), do: true def const_value?(x) when is_number(x) or is_boolean(x) or is_binary(x), do: true def const_value?(x) when is_list(x), do: Enum.all?(x, &const_value?/1) def const_value?(%{__struct__: Arg}), do: false # def const_value?(%{__struct__: Directive}), do: false def const_value?(%{__struct__: Field}), do: false # def const_value?(%{__struct__: FragmentDef}), do: false # def const_value?(%{__struct__: FragmentSpread}), do: false # def const_value?(%{__struct__: InlineFragment}), do: false def const_value?(%{__struct__: Query}), do: false def const_value?(%{__struct__: Param}), do: false def const_value?(%{__struct__: Var}), do: false def const_value?(%{__struct__: Type}), do: false def const_value?(%{} = x), do: Enum.all?(Map.delete(x, :__struct__), fn {k, v} -> name?(k) and const_value?(v) end) def const_value?(_), do: false @spec fragment_name?(term) :: boolean def fragment_name?(:on), do: false def fragment_name?("on"), do: false def fragment_name?(name), do: name?(name) ## impl: basic parsers # does every char in a binary match a predicate? defp every?(_pred, ""), do: true defp every?(pred, <<char::utf8, rest::binary>>), do: pred.(char) and every?(pred, rest) # find the first character that matches a predicate, get it and its byte offset and size defp first(str, pred), do: first(str, pred, 0) defp first("", _pred, _idx), do: :error defp first(<<ch::utf8, rest::binary>> = all, pred, idx) do # jesus size = byte_size(all) - byte_size(rest) if pred.(ch) do {:ok, idx, ch, size} else first(rest, pred, idx + size) end end ### impl: character tests # defp source_character?(x) when x in [9,10,13] or (x >= 20 and x <= 65535) defp name_start?(x), do: x == ?_ or letter?(x) defp name_continue?(x), do: name_start?(x) or digit?(x) defp lower_case_letter?(x), do: x >= ?a and x <= ?z defp upper_case_letter?(x), do: x >= ?A and x <= ?Z defp letter?(x), do: lower_case_letter?(x) or upper_case_letter?(x) defp digit?(x), do: x >= ?0 and x <= ?9 ### impl: string escaping # fast path for no items defp escape_string("", []), do: "" # fast path for one item defp escape_string("", [acc]), do: acc defp escape_string("", acc), do: acc defp escape_string(str, acc) do case first(str, &escape_char?/1) do :error -> [acc, str] {:ok, 0, ch, size} -> ch = escape_char(ch) escape_string(:binary.part(str, size, byte_size(str) - size), [acc, ch]) {:ok, index, ch, size} -> pre = :binary.part(str, 0, index) ch = escape_char(ch) escape_string(:binary.part(str, size, byte_size(str) - (size + index)), [acc, pre, ch]) end end # defp source_character?(x) when x in [9,10,13] or (x >= 20 and x <= 65535) # should we escape this character in a string literal? defp escape_char?(x), do: x <= 31 or x >= 127 or x in [?", ?\\] ## escape translation # special common cases # double quote defp escape_char(?"), do: "\\\"" # backslash defp escape_char(?\\), do: "\\\\" # bell defp escape_char(?\b), do: "\\b" # form feed defp escape_char(?\f), do: "\\f" # line feed defp escape_char(?\n), do: "\\n" # carriage return defp escape_char(?\r), do: "\\r" # horizontal tab defp escape_char(?\t), do: "\\t" # printable, narrowly avoiding ascii del defp escape_char(ch) when ch >= 31 and ch <= 126, do: ch # by digits # 1 digit defp escape_char(ch) when ch <= 15, do: ["\\u000", Integer.to_string(ch, 16)] # 2 digits defp escape_char(ch) when ch <= 255, do: ["\\u00", Integer.to_string(ch, 16)] # 3 digits defp escape_char(ch) when ch <= 4095, do: ["\\u0", Integer.to_string(ch, 16)] # 4 byte defp escape_char(ch) when ch <= 65535, do: ["\\u", Integer.to_string(ch, 16)] defp escape_char(ch) when ch > 65535, do: throw({:char_out_of_range, ch}) end
34.336683
95
0.646129
79f4bc1b4d89a8a0f0d45ce1c304c65f44a78d1f
342
exs
Elixir
priv/repo/seeds.exs
sighmin/chatter
af1d07690e7f46cd8a066537a74b7ae13e2d044a
[ "MIT" ]
null
null
null
priv/repo/seeds.exs
sighmin/chatter
af1d07690e7f46cd8a066537a74b7ae13e2d044a
[ "MIT" ]
null
null
null
priv/repo/seeds.exs
sighmin/chatter
af1d07690e7f46cd8a066537a74b7ae13e2d044a
[ "MIT" ]
null
null
null
# Script for populating the database. You can run it as: # # mix run priv/repo/seeds.exs # # Inside the script, you can read and write to any of your # repositories directly: # # Chatter.Repo.insert!(%SomeModel{}) # # We recommend using the bang functions (`insert!`, `update!` # and so on) as they will fail if something goes wrong.
28.5
61
0.701754
79f4f782bbe78011799e53e4105cde515dd7555b
244
ex
Elixir
lib/api/repo.ex
nunopolonia/psc-api
2e358503851cc04cdaa89201a3f56586f8746736
[ "MIT" ]
1
2017-09-10T23:51:40.000Z
2017-09-10T23:51:40.000Z
lib/api/repo.ex
nunopolonia/psc-api
2e358503851cc04cdaa89201a3f56586f8746736
[ "MIT" ]
24
2018-03-14T18:17:00.000Z
2021-03-01T07:47:53.000Z
lib/api/repo.ex
portosummerofcode/psc-api
2e358503851cc04cdaa89201a3f56586f8746736
[ "MIT" ]
null
null
null
defmodule Api.Repo do use Ecto.Repo, otp_app: :api @doc """ Dynamically loads the repository url from the DB_URL environment variable. """ def init(_, opts) do {:ok, Keyword.put(opts, :url, System.get_env("DB_URL"))} end end
20.333333
60
0.672131
79f5104bd40fdc51a5e86fa363f6264a47c9cb33
137,087
ex
Elixir
clients/managed_identities/lib/google_api/managed_identities/v1/api/projects.ex
MMore/elixir-google-api
0574ec1439d9bbfe22d63965be1681b0f45a94c9
[ "Apache-2.0" ]
null
null
null
clients/managed_identities/lib/google_api/managed_identities/v1/api/projects.ex
MMore/elixir-google-api
0574ec1439d9bbfe22d63965be1681b0f45a94c9
[ "Apache-2.0" ]
null
null
null
clients/managed_identities/lib/google_api/managed_identities/v1/api/projects.ex
MMore/elixir-google-api
0574ec1439d9bbfe22d63965be1681b0f45a94c9
[ "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.ManagedIdentities.V1.Api.Projects do @moduledoc """ API calls for all endpoints tagged `Projects`. """ alias GoogleApi.ManagedIdentities.V1.Connection alias GoogleApi.Gax.{Request, Response} @library_version Mix.Project.config() |> Keyword.get(:version, "") @doc """ Gets information about a location. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Resource name for the location. * `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.ManagedIdentities.V1.Model.Location{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_get( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Location.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_get( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Location{}]) end @doc """ Lists information about the supported locations for this service. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - The resource that owns the locations collection, if applicable. * `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`) - A filter to narrow down results to a preferred subset. The filtering language accepts strings like "displayName=tokyo", and is documented in more detail in [AIP-160](https://google.aip.dev/160). * `:pageSize` (*type:* `integer()`) - The maximum number of results to return. If not set, the service selects a default. * `:pageToken` (*type:* `String.t`) - A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.ListLocationsResponse{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.ListLocationsResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_list( connection, name, 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("/v1/{+name}/locations", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.ListLocationsResponse{}] ) end @doc """ Adds an AD trust to a domain. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The resource domain name, project name and location using the form: `projects/{project_id}/locations/global/domains/{domain_name}` * `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.ManagedIdentities.V1.Model.AttachTrustRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_attach_trust( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_attach_trust( connection, name, 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("/v1/{+name}:attachTrust", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Creates a Microsoft AD domain. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The resource project name and location using the form: `projects/{project_id}/locations/global` * `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"). * `:domainName` (*type:* `String.t`) - Required. The fully qualified domain name. e.g. mydomain.myorganization.com, with the following restrictions: * Must contain only lowercase letters, numbers, periods and hyphens. * Must start with a letter. * Must contain between 2-64 characters. * Must end with a number or a letter. * Must not start with period. * First segment length (mydomain for example above) shouldn't exceed 15 chars. * The last segment cannot be fully numeric. * Must be unique within the customer project. * `:body` (*type:* `GoogleApi.ManagedIdentities.V1.Model.Domain.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_create( connection, parent, 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, :domainName => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/{+parent}/domains", %{ "parent" => URI.encode(parent, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Deletes a domain. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` * `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.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_delete( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_delete( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Removes an AD trust. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The resource domain name, project name, and location using the form: `projects/{project_id}/locations/global/domains/{domain_name}` * `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.ManagedIdentities.V1.Model.DetachTrustRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_detach_trust( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_detach_trust( connection, name, 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("/v1/{+name}:detachTrust", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Gets information about a domain. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` * `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.ManagedIdentities.V1.Model.Domain{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_get( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Domain.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_get( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Domain{}]) end @doc """ Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. * `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"). * `:"options.requestedPolicyVersion"` (*type:* `integer()`) - Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_get_iam_policy( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_get_iam_policy( connection, resource, 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, :"options.requestedPolicyVersion" => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/{+resource}:getIamPolicy", %{ "resource" => URI.encode(resource, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Policy{}]) end @doc """ Gets the domain ldaps settings. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` * `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.ManagedIdentities.V1.Model.LDAPSSettings{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_get_ldapssettings( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.LDAPSSettings.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_get_ldapssettings( connection, name, 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("/v1/{+name}/ldapssettings", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.LDAPSSettings{}]) end @doc """ Lists domains in a project. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The resource name of the domain location using the form: `projects/{project_id}/locations/global` * `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`) - Optional. A filter specifying constraints of a list operation. For example, `Domain.fqdn="mydomain.myorginization"`. * `:orderBy` (*type:* `String.t`) - Optional. Specifies the ordering of results. See [Sorting order](https://cloud.google.com/apis/design/design_patterns#sorting_order) for more information. * `:pageSize` (*type:* `integer()`) - Optional. The maximum number of items to return. If not specified, a default value of 1000 will be used. Regardless of the page_size value, the response may include a partial list. Callers should rely on a response's next_page_token to determine if there are additional results to list. * `:pageToken` (*type:* `String.t`) - Optional. The `next_page_token` value returned from a previous ListDomainsRequest request, if any. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.ListDomainsResponse{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.ListDomainsResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_list( connection, parent, 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("/v1/{+parent}/domains", %{ "parent" => URI.encode(parent, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.ListDomainsResponse{}] ) end @doc """ Updates the metadata and configuration of a domain. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The unique name of the domain using the form: `projects/{project_id}/locations/global/domains/{domain_name}`. * `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`) - Required. Mask of fields to update. At least one path must be supplied in this field. The elements of the repeated paths field may only include fields from Domain: * `labels` * `locations` * `authorized_networks` * `audit_logs_enabled` * `:body` (*type:* `GoogleApi.ManagedIdentities.V1.Model.Domain.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_patch( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_patch( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Updates the DNS conditional forwarder. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The resource domain name, project name and location using the form: `projects/{project_id}/locations/global/domains/{domain_name}` * `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.ManagedIdentities.V1.Model.ReconfigureTrustRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_reconfigure_trust( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_reconfigure_trust( connection, name, 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("/v1/{+name}:reconfigureTrust", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Resets a domain's administrator password. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` * `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.ManagedIdentities.V1.Model.ResetAdminPasswordRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.ResetAdminPasswordResponse{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_reset_admin_password( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.ResetAdminPasswordResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_reset_admin_password( connection, name, 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("/v1/{+name}:resetAdminPassword", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.ResetAdminPasswordResponse{}] ) end @doc """ RestoreDomain restores domain backup mentioned in the RestoreDomainRequest ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. Resource name for the domain to which the backup belongs * `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.ManagedIdentities.V1.Model.RestoreDomainRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_restore( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_restore( connection, name, 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("/v1/{+name}:restore", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. * `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.ManagedIdentities.V1.Model.SetIamPolicyRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_set_iam_policy( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_set_iam_policy( connection, resource, 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("/v1/{+resource}:setIamPolicy", %{ "resource" => URI.encode(resource, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Policy{}]) end @doc """ Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. * `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.ManagedIdentities.V1.Model.TestIamPermissionsRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.TestIamPermissionsResponse{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_test_iam_permissions( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.TestIamPermissionsResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_test_iam_permissions( connection, resource, 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("/v1/{+resource}:testIamPermissions", %{ "resource" => URI.encode(resource, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.TestIamPermissionsResponse{}] ) end @doc """ Patches a single ldaps settings. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - The resource name of the LDAPS settings. Uses the form: `projects/{project}/locations/{location}/domains/{domain}`. * `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`) - Required. Mask of fields to update. At least one path must be supplied in this field. For the `FieldMask` definition, see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask * `:body` (*type:* `GoogleApi.ManagedIdentities.V1.Model.LDAPSSettings.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_update_ldapssettings( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_update_ldapssettings( connection, name, 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("/v1/{+name}/ldapssettings", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Validates a trust state, that the target domain is reachable, and that the target domain is able to accept incoming trust requests. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The resource domain name, project name, and location using the form: `projects/{project_id}/locations/global/domains/{domain_name}` * `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.ManagedIdentities.V1.Model.ValidateTrustRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_validate_trust( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_validate_trust( connection, name, 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("/v1/{+name}:validateTrust", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Creates a Backup for a domain. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` * `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"). * `:backupId` (*type:* `String.t`) - Required. Backup Id, unique name to identify the backups with the following restrictions: * Must be lowercase letters, numbers, and hyphens * Must start with a letter. * Must contain between 1-63 characters. * Must end with a number or a letter. * Must be unique within the domain. * `:body` (*type:* `GoogleApi.ManagedIdentities.V1.Model.Backup.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_backups_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_backups_create( connection, parent, 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, :backupId => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/{+parent}/backups", %{ "parent" => URI.encode(parent, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Deletes identified Backup. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The backup resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}/backups/{backup_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"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_backups_delete( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_backups_delete( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Gets details of a single Backup. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The backup resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}/backups/{backup_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"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Backup{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_backups_get( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Backup.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_backups_get( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Backup{}]) end @doc """ Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. * `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"). * `:"options.requestedPolicyVersion"` (*type:* `integer()`) - Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_backups_get_iam_policy( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_backups_get_iam_policy( connection, resource, 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, :"options.requestedPolicyVersion" => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/{+resource}:getIamPolicy", %{ "resource" => URI.encode(resource, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Policy{}]) end @doc """ Lists Backup in a given project. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` * `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`) - Optional. Filter specifying constraints of a list operation. * `:orderBy` (*type:* `String.t`) - Optional. Specifies the ordering of results following syntax at https://cloud.google.com/apis/design/design_patterns#sorting_order. * `:pageSize` (*type:* `integer()`) - Optional. The maximum number of items to return. If not specified, a default value of 1000 will be used by the service. Regardless of the page_size value, the response may include a partial list and a caller should only rely on response's next_page_token to determine if there are more instances left to be queried. * `:pageToken` (*type:* `String.t`) - Optional. The `next_page_token` value returned from a previous List request, if any. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.ListBackupsResponse{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_backups_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.ListBackupsResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_backups_list( connection, parent, 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("/v1/{+parent}/backups", %{ "parent" => URI.encode(parent, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.ListBackupsResponse{}] ) end @doc """ Updates the labels for specified Backup. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Output only. The unique name of the Backup in the form of `projects/{project_id}/locations/global/domains/{domain_name}/backups/{name}` * `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`) - Required. Mask of fields to update. At least one path must be supplied in this field. The elements of the repeated paths field may only include these fields from Backup: * `labels` * `:body` (*type:* `GoogleApi.ManagedIdentities.V1.Model.Backup.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_backups_patch( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_backups_patch( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. * `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.ManagedIdentities.V1.Model.SetIamPolicyRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_backups_set_iam_policy( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_backups_set_iam_policy( connection, resource, 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("/v1/{+resource}:setIamPolicy", %{ "resource" => URI.encode(resource, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Policy{}]) end @doc """ Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. * `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.ManagedIdentities.V1.Model.TestIamPermissionsRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.TestIamPermissionsResponse{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_backups_test_iam_permissions( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.TestIamPermissionsResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_backups_test_iam_permissions( connection, resource, 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("/v1/{+resource}:testIamPermissions", %{ "resource" => URI.encode(resource, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.TestIamPermissionsResponse{}] ) end @doc """ Gets details of a single sqlIntegration. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. SQLIntegration resource name using the form: `projects/{project_id}/locations/global/domains/{domain}/sqlIntegrations/{name}` * `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.ManagedIdentities.V1.Model.SqlIntegration{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_sql_integrations_get( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.SqlIntegration.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_sql_integrations_get( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.SqlIntegration{}]) end @doc """ Lists SqlIntegrations in a given domain. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The resource name of the SqlIntegrations using the form: `projects/{project_id}/locations/global/domains/*` * `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`) - Optional. Filter specifying constraints of a list operation. For example, `SqlIntegration.name="sql"`. * `:orderBy` (*type:* `String.t`) - Optional. Specifies the ordering of results following syntax at https://cloud.google.com/apis/design/design_patterns#sorting_order. * `:pageSize` (*type:* `integer()`) - Optional. The maximum number of items to return. If not specified, a default value of 1000 will be used by the service. Regardless of the page_size value, the response may include a partial list and a caller should only rely on response'ANIZATIONs next_page_token to determine if there are more instances left to be queried. * `:pageToken` (*type:* `String.t`) - Optional. The next_page_token value returned from a previous List request, if any. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.ListSqlIntegrationsResponse{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_domains_sql_integrations_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.ListSqlIntegrationsResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_domains_sql_integrations_list( connection, parent, 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("/v1/{+parent}/sqlIntegrations", %{ "parent" => URI.encode(parent, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.ListSqlIntegrationsResponse{}] ) end @doc """ Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - The name of the operation resource to be cancelled. * `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.ManagedIdentities.V1.Model.CancelOperationRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_operations_cancel( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Empty.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_operations_cancel( connection, name, 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("/v1/{+name}:cancel", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Empty{}]) end @doc """ Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - The name of the operation resource to be deleted. * `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.ManagedIdentities.V1.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_operations_delete( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Empty.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_operations_delete( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Empty{}]) end @doc """ Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - The name of the operation resource. * `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.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_operations_get( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_operations_get( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding allows API services to override the binding to use different resource name schemes, such as `users/*/operations`. To override the binding, API services can add a binding such as `"/v1/{name=users/*}/operations"` to their service configuration. For backwards compatibility, the default name includes the operations collection id, however overriding users must ensure the name binding is the parent resource, without the operations collection id. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - The name of the operation's parent resource. * `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`) - The standard list filter. * `:pageSize` (*type:* `integer()`) - The standard list page size. * `:pageToken` (*type:* `String.t`) - The standard list page token. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.ListOperationsResponse{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_operations_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.ListOperationsResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_operations_list( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.ListOperationsResponse{}] ) end @doc """ Creates a Peering for Managed AD instance. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. Resource project name and location using the form: `projects/{project_id}/locations/global` * `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"). * `:peeringId` (*type:* `String.t`) - Required. Peering Id, unique name to identify peering. It should follow the regex format "^(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)$" * `:body` (*type:* `GoogleApi.ManagedIdentities.V1.Model.Peering.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_peerings_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_peerings_create( connection, parent, 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, :peeringId => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/{+parent}/peerings", %{ "parent" => URI.encode(parent, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Deletes identified Peering. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. Peering resource name using the form: `projects/{project_id}/locations/global/peerings/{peering_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"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_peerings_delete( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_peerings_delete( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Gets details of a single Peering. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. Peering resource name using the form: `projects/{project_id}/locations/global/peerings/{peering_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"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Peering{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_peerings_get( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Peering.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_peerings_get( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Peering{}]) end @doc """ Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. * `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"). * `:"options.requestedPolicyVersion"` (*type:* `integer()`) - Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_peerings_get_iam_policy( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_peerings_get_iam_policy( connection, resource, 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, :"options.requestedPolicyVersion" => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/{+resource}:getIamPolicy", %{ "resource" => URI.encode(resource, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Policy{}]) end @doc """ Lists Peerings in a given project. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The resource name of the peering location using the form: `projects/{project_id}/locations/global` * `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`) - Optional. Filter specifying constraints of a list operation. For example, `peering.authorized_network="projects/myprojectid/global/networks/mynetwork"`. * `:orderBy` (*type:* `String.t`) - Optional. Specifies the ordering of results following syntax at https://cloud.google.com/apis/design/design_patterns#sorting_order. * `:pageSize` (*type:* `integer()`) - Optional. The maximum number of items to return. If not specified, a default value of 1000 will be used by the service. Regardless of the page_size value, the response may include a partial list and a caller should only rely on response's next_page_token to determine if there are more instances left to be queried. * `:pageToken` (*type:* `String.t`) - Optional. The next_page_token value returned from a previous List request, if any. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.ListPeeringsResponse{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_peerings_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.ListPeeringsResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_peerings_list( connection, parent, 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("/v1/{+parent}/peerings", %{ "parent" => URI.encode(parent, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.ListPeeringsResponse{}] ) end @doc """ Updates the labels for specified Peering. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Output only. Unique name of the peering in this scope including projects and location using the form: `projects/{project_id}/locations/global/peerings/{peering_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"). * `:updateMask` (*type:* `String.t`) - Required. Mask of fields to update. At least one path must be supplied in this field. The elements of the repeated paths field may only include these fields from Peering: * `labels` * `:body` (*type:* `GoogleApi.ManagedIdentities.V1.Model.Peering.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_peerings_patch( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_peerings_patch( connection, name, 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("/v1/{+name}", %{ "name" => URI.encode(name, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Operation{}]) end @doc """ Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. * `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.ManagedIdentities.V1.Model.SetIamPolicyRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_peerings_set_iam_policy( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_peerings_set_iam_policy( connection, resource, 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("/v1/{+resource}:setIamPolicy", %{ "resource" => URI.encode(resource, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.Policy{}]) end @doc """ Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. ## Parameters * `connection` (*type:* `GoogleApi.ManagedIdentities.V1.Connection.t`) - Connection to server * `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. * `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.ManagedIdentities.V1.Model.TestIamPermissionsRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.ManagedIdentities.V1.Model.TestIamPermissionsResponse{}}` on success * `{:error, info}` on failure """ @spec managedidentities_projects_locations_global_peerings_test_iam_permissions( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.ManagedIdentities.V1.Model.TestIamPermissionsResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def managedidentities_projects_locations_global_peerings_test_iam_permissions( connection, resource, 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("/v1/{+resource}:testIamPermissions", %{ "resource" => URI.encode(resource, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.ManagedIdentities.V1.Model.TestIamPermissionsResponse{}] ) end end
46.438686
802
0.620518
79f512f860c41787bdbb001109374102aeb4b68a
4,068
ex
Elixir
lib/phoenix/endpoint/cowboy_handler.ex
misfo/phoenix
04464429d9b958e331b2ffe0f0f5926690ab3b56
[ "MIT" ]
1
2021-03-14T17:50:24.000Z
2021-03-14T17:50:24.000Z
lib/phoenix/endpoint/cowboy_handler.ex
misfo/phoenix
04464429d9b958e331b2ffe0f0f5926690ab3b56
[ "MIT" ]
null
null
null
lib/phoenix/endpoint/cowboy_handler.ex
misfo/phoenix
04464429d9b958e331b2ffe0f0f5926690ab3b56
[ "MIT" ]
2
2020-08-02T04:00:17.000Z
2020-10-07T16:07:37.000Z
defmodule Phoenix.Endpoint.CowboyHandler do @moduledoc """ The Cowboy adapter for Phoenix. It implements the required `child_spec/3` function as well as the handler for the WebSocket transport. ## Custom dispatch options *NOTE*: This feature depends on the internals of Cowboy 1.0 API and how it integrates with Phoenix. Those may change *any time*, without backwards compatibility, specially when Cowboy 2.0 is out. We document this for clarity and for those with very special needs. You can provide custom dispatch options in order to use Phoenix's builtin Cowboy server with custom handlers. For example, to handle raw WebSockets [as shown in Cowboy's docs](https://github.com/ninenines/cowboy/tree/1.0.x/examples)). The options are passed to both `:http` and `:https` keys in the endpoint configuration. However, once you pass your custom dispatch options, you will need to manually wire all Phoenix endpoints, including the socket transports. You will need the following rules: * Per websocket transport: {"/socket/websocket", Phoenix.Endpoint.CowboyWebSocket, {Phoenix.Transports.WebSocket, {MyApp.Endpoint, MyApp.UserSocket, :websocket}}} * Per longpoll transport: {"/socket/long_poll", Plug.Adapters.Cowboy.Handler, {Phoenix.Transports.LongPoll, {MyApp.Endpoint, MyApp.UserSocket, :longpoll}}} * For the endpoint: {:_, Plug.Adapters.Cowboy.Handler, {MyApp.Endpoint, []}} For example: config :myapp, MyApp.Endpoint, http: [dispatch: [ {:_, [ {"/foo", MyApp.CustomHandler, []}, {"/bar", MyApp.AnotherHandler, []}, {:_, Plug.Adapters.Cowboy.Handler, {MyApp.Endpoint, []}} ]}]] It is also important to specify your handlers first, otherwise Phoenix will intercept the requests before they get to your handler. """ @behaviour Phoenix.Endpoint.Handler require Logger @doc """ Generates a childspec to be used in the supervision tree. """ def child_spec(scheme, endpoint, config) do if scheme == :https do Application.ensure_all_started(:ssl) end dispatches = for {path, socket} <- endpoint.__sockets__, {transport, {module, config}} <- socket.__transports__, # Allow handlers to be configured at the transport level handler = config[:cowboy] || default_for(module), do: {Path.join(path, Atom.to_string(transport)), handler, {module, {endpoint, socket, transport}}} dispatches = dispatches ++ [{:_, Plug.Adapters.Cowboy.Handler, {endpoint, []}}] # Use put_new to allow custom dispatches config = Keyword.put_new(config, :dispatch, [{:_, dispatches}]) {ref, mfa, type, timeout, kind, modules} = Plug.Adapters.Cowboy.child_spec(scheme, endpoint, [], config) # Rewrite MFA for proper error reporting mfa = {__MODULE__, :start_link, [scheme, endpoint, mfa]} {ref, mfa, type, timeout, kind, modules} end defp default_for(Phoenix.Transports.LongPoll), do: Plug.Adapters.Cowboy.Handler defp default_for(Phoenix.Transports.WebSocket), do: Phoenix.Endpoint.CowboyWebSocket defp default_for(_), do: nil @doc """ Callback to start the Cowboy endpoint. """ def start_link(scheme, endpoint, {m, f, [ref | _] = a}) do # ref is used by Ranch to identify its listeners, defaulting # to plug.HTTP and plug.HTTPS and overridable by users. case apply(m, f, a) do {:ok, pid} -> Logger.info info(scheme, endpoint, ref) {:ok, pid} {:error, {:shutdown, {_, _, {{_, {:error, :eaddrinuse}}, _}}}} = error -> Logger.error [info(scheme, endpoint, ref), " failed, port already in use"] error {:error, _} = error -> error end end defp info(scheme, endpoint, ref) do port = :ranch.get_port(ref) "Running #{inspect endpoint} with Cowboy using #{scheme} on port #{port}" end end
34.474576
103
0.652655
79f535cb756629341dd01113bae041da92e2f191
120
exs
Elixir
test/test_helper.exs
workpathco/firebase-admin-ex
83305a4bfcc5b1cc7b692eee9d4c93fa080759f2
[ "MIT" ]
38
2018-05-29T14:22:03.000Z
2021-11-16T11:33:05.000Z
test/test_helper.exs
workpathco/firebase-admin-ex
83305a4bfcc5b1cc7b692eee9d4c93fa080759f2
[ "MIT" ]
8
2018-12-05T02:41:12.000Z
2020-06-24T18:41:21.000Z
test/test_helper.exs
workpathco/firebase-admin-ex
83305a4bfcc5b1cc7b692eee9d4c93fa080759f2
[ "MIT" ]
22
2018-11-21T03:10:07.000Z
2022-02-18T01:45:14.000Z
ExUnit.start() files = Path.wildcard("./test/support/*.ex") Enum.each(files, fn file -> Code.require_file(file) end)
17.142857
44
0.691667
79f53f7e4f7ef9e3541ff3797f6c618df7b1f057
292
exs
Elixir
book-material/modules/private-type-functions.exs
AdnanCodes/Elixir-Learning
6fbab6092384566aff92bccf64b1af90c68ecb6c
[ "MIT" ]
null
null
null
book-material/modules/private-type-functions.exs
AdnanCodes/Elixir-Learning
6fbab6092384566aff92bccf64b1af90c68ecb6c
[ "MIT" ]
null
null
null
book-material/modules/private-type-functions.exs
AdnanCodes/Elixir-Learning
6fbab6092384566aff92bccf64b1af90c68ecb6c
[ "MIT" ]
null
null
null
defmodule Fun do def fun(a) when is_list(a) do true end defp fun(a) do false end end # This code is invalid due to some heads cannot be private and others public such as fun(a) # The purpose of private functions is allow them to be called only from their respective Modules
22.461538
96
0.729452
79f57e73207e2b5fe2aa074bc54ab5ba1379be0b
383
exs
Elixir
allergies/allergies.exs
nickpellant/xelixir
6e27dc7083ef3e423a1615f5151910672e6397a8
[ "MIT" ]
null
null
null
allergies/allergies.exs
nickpellant/xelixir
6e27dc7083ef3e423a1615f5151910672e6397a8
[ "MIT" ]
null
null
null
allergies/allergies.exs
nickpellant/xelixir
6e27dc7083ef3e423a1615f5151910672e6397a8
[ "MIT" ]
null
null
null
defmodule Allergies do @doc """ List the allergies for which the corresponding flag bit is true. """ @spec list(non_neg_integer) :: [String.t] def list(flags) do end @doc """ Returns whether the corresponding flag bit in 'flags' is set for the item. """ @spec allergic_to?(non_neg_integer, String.t) :: boolean def allergic_to?(flags, item) do end end
21.277778
76
0.678851
79f5d197a19cfd23acfc32d29ba453429a1e514d
742
exs
Elixir
test/shopiex/meta_test.exs
byjpr/Shopiex
360dc00e6ffd21a822f32d83af15948e77f6e11c
[ "MIT" ]
1
2019-03-07T11:30:09.000Z
2019-03-07T11:30:09.000Z
test/shopiex/meta_test.exs
byjpr/Shopiex
360dc00e6ffd21a822f32d83af15948e77f6e11c
[ "MIT" ]
28
2020-06-28T19:35:02.000Z
2021-07-11T13:15:06.000Z
test/shopiex/meta_test.exs
byjpr/Shopiex
360dc00e6ffd21a822f32d83af15948e77f6e11c
[ "MIT" ]
null
null
null
defmodule Shopiex.MetaTest do use ExUnit.Case, async: true import Shopiex.Meta test "shop_details" do {_client, object} = Shopiex.client("test-store", "token") |> shop_details assert(object == "/admin/shop.json") end describe "Testing Options on `shop_metafields`" do test "single" do {_client, object} = Shopiex.client("test-store", "token") |> shop_metafields([limit: 10_000]) assert(object == "/admin/metafields.json?limit=10000") end test "multiple" do {_client, object} = Shopiex.client("test-store", "token") |> shop_metafields([limit: 10_000, since_id: 123_421_043]) assert(object == "/admin/metafields.json?limit=10000&since_id=123421043") end end end
26.5
79
0.663073
79f636ad1d28627716eaf4e4036cc95786d3c8dc
760
ex
Elixir
test/support/sim508a.ex
bcdevices/atecc508a
934652947ac1de2022f1da556adffa3e8cba31e3
[ "Apache-2.0" ]
6
2018-12-13T16:33:09.000Z
2022-03-02T08:57:20.000Z
test/support/sim508a.ex
bcdevices/atecc508a
934652947ac1de2022f1da556adffa3e8cba31e3
[ "Apache-2.0" ]
10
2019-01-30T19:33:48.000Z
2022-03-03T21:07:37.000Z
test/support/sim508a.ex
bcdevices/atecc508a
934652947ac1de2022f1da556adffa3e8cba31e3
[ "Apache-2.0" ]
9
2019-08-22T06:26:45.000Z
2022-03-01T18:05:01.000Z
defmodule ATECC508A.Sim508A do @moduledoc """ This is a simulated ATECC508A for creating things normally created on the ATECC508A """ @slot0_private_key ATECC508A.Certificate.curve() |> X509.PrivateKey.new_ec() @slot0_public_key X509.PublicKey.derive(@slot0_private_key) @doc """ Our simulated ECC508A has an easy-to-remember serial number """ def serial_number() do <<1, 2, 3, 4, 5, 6, 7, 8, 9>> end @doc """ "Create" a public/private key pair; return the public key in OTP record format. """ @spec otp_genkey() :: :public_key.ec_public_key() def otp_genkey() do @slot0_public_key end @doc """ "Create" a public/private key pair, but return the public key as bytes """ def genkey() do nil end end
23.030303
78
0.681579
79f63d04e353d94862d0eea447cdd80574369a94
204
ex
Elixir
lib/geef/odb.ex
kjg/geef
9e9aa23af7614cb398e99fb06019884af2cbcd79
[ "MIT" ]
107
2015-01-08T12:05:20.000Z
2022-03-21T20:36:43.000Z
lib/geef/odb.ex
kjg/geef
9e9aa23af7614cb398e99fb06019884af2cbcd79
[ "MIT" ]
9
2015-03-11T18:32:24.000Z
2020-03-29T21:08:55.000Z
lib/geef/odb.ex
kjg/geef
9e9aa23af7614cb398e99fb06019884af2cbcd79
[ "MIT" ]
28
2015-03-03T16:01:26.000Z
2022-02-20T19:18:03.000Z
defmodule Geef.Odb do def exists?(pid, id) do :geef_odb.exists(pid, id) end def write(pid, content, type), do: :geef_odb.write(pid, content, type) def stop(pid), do: :geef_odb.stop(pid) end
20.4
72
0.671569
79f64d4a1d24e930864a46d7c92ab9d015e7dd3d
499
ex
Elixir
lib/page_handlers/chargers_page_handler.ex
Sebi55/ocpp-backend
e2c4920aa3d2986934a17e904d7836d4f2a91945
[ "MIT" ]
11
2019-03-06T12:44:46.000Z
2022-01-20T10:41:30.000Z
lib/page_handlers/chargers_page_handler.ex
Sebi55/ocpp-backend
e2c4920aa3d2986934a17e904d7836d4f2a91945
[ "MIT" ]
3
2019-03-06T13:29:36.000Z
2020-03-21T15:40:47.000Z
lib/page_handlers/chargers_page_handler.ex
Sebi55/ocpp-backend
e2c4920aa3d2986934a17e904d7836d4f2a91945
[ "MIT" ]
4
2019-03-06T13:24:13.000Z
2021-12-22T09:17:56.000Z
defmodule PageHandlers.Chargers do @moduledoc """ Render the Chargers page """ def init(req, state) do handle(req, state) end def handle(request, state) do req = :cowboy_req.reply( 200, %{"content-type" => "text/html"}, build_body(request), request ) {:ok, req, state} end defp build_body(_request) do {:ok, chargers} = Chargepoints.subscribers PageUtils.renderPage("chargers_page.html", "Chargers", [chargers: chargers]) end end
19.96
79
0.637275
79f66f7c59724a086d08f46390c012fd1cf19b2f
2,575
exs
Elixir
apps/ewallet/test/ewallet/schedulers/transaction_request_scheduler_test.exs
AndonMitev/EWallet
898cde38933d6f134734528b3e594eedf5fa50f3
[ "Apache-2.0" ]
322
2018-02-28T07:38:44.000Z
2020-05-27T23:09:55.000Z
apps/ewallet/test/ewallet/schedulers/transaction_request_scheduler_test.exs
AndonMitev/EWallet
898cde38933d6f134734528b3e594eedf5fa50f3
[ "Apache-2.0" ]
643
2018-02-28T12:05:20.000Z
2020-05-22T08:34:38.000Z
apps/ewallet/test/ewallet/schedulers/transaction_request_scheduler_test.exs
AndonMitev/EWallet
898cde38933d6f134734528b3e594eedf5fa50f3
[ "Apache-2.0" ]
63
2018-02-28T10:57:06.000Z
2020-05-27T23:10:38.000Z
# Copyright 2018-2019 OmiseGO Pte Ltd # # 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 EWallet.TransactionRequestSchedulerTest do use EWallet.DBCase, async: true import EWalletDB.Factory alias EWallet.TransactionRequestScheduler alias EWalletDB.TransactionRequest describe "expire_all/0" do test "expires all requests past their expiration date" do now = NaiveDateTime.utc_now() # t1 and t2 have expiration dates in the past t1 = insert(:transaction_request, expiration_date: NaiveDateTime.add(now, -60, :second)) t2 = insert(:transaction_request, expiration_date: NaiveDateTime.add(now, -600, :second)) t3 = insert(:transaction_request, expiration_date: NaiveDateTime.add(now, 600, :second)) t4 = insert(:transaction_request, expiration_date: NaiveDateTime.add(now, 160, :second)) # They are still valid since we haven't made them expired yet assert TransactionRequest.expired?(t1) == false assert TransactionRequest.expired?(t2) == false assert TransactionRequest.expired?(t3) == false assert TransactionRequest.expired?(t4) == false TransactionRequestScheduler.expire_all() # Reload all the records t1 = TransactionRequest.get(t1.id) t2 = TransactionRequest.get(t2.id) t3 = TransactionRequest.get(t3.id) t4 = TransactionRequest.get(t4.id) # Now t1 and t2 are expired assert TransactionRequest.expired?(t1) == true assert TransactionRequest.expired?(t2) == true assert TransactionRequest.expired?(t3) == false assert TransactionRequest.expired?(t4) == false end test "sets the expiration reason" do now = NaiveDateTime.utc_now() t = insert(:transaction_request, expiration_date: NaiveDateTime.add(now, -60, :second)) TransactionRequestScheduler.expire_all() t = TransactionRequest.get(t.id) assert TransactionRequest.expired?(t) == true assert t.expired_at != nil assert t.expiration_reason == TransactionRequest.expired_transaction_request() end end end
40.234375
95
0.726602
79f6938c363f1194984579a0d59bdf9cf756bc1a
1,654
ex
Elixir
lib/codenamex_web.ex
bernardoamc/codenamex
6e3219569e4d9b8f4fe9273145b372ba182ab945
[ "MIT" ]
null
null
null
lib/codenamex_web.ex
bernardoamc/codenamex
6e3219569e4d9b8f4fe9273145b372ba182ab945
[ "MIT" ]
2
2020-07-20T14:23:21.000Z
2020-08-01T21:18:45.000Z
lib/codenamex_web.ex
bernardoamc/codenamex
6e3219569e4d9b8f4fe9273145b372ba182ab945
[ "MIT" ]
null
null
null
defmodule CodenamexWeb do @moduledoc """ The entrypoint for defining your web interface, such as controllers, views, channels and so on. This can be used in your application as: use CodenamexWeb, :controller use CodenamexWeb, :view The definitions below will be executed for every view, controller, etc, so keep them short and clean, focused on imports, uses and aliases. Do NOT define functions inside the quoted expressions below. Instead, define any helper function in modules and import those modules here. """ def controller do quote do use Phoenix.Controller, namespace: CodenamexWeb import Plug.Conn import CodenamexWeb.Gettext alias CodenamexWeb.Router.Helpers, as: Routes end end def view do quote do use Phoenix.View, root: "lib/codenamex_web/templates", namespace: CodenamexWeb # Import convenience functions from controllers import Phoenix.Controller, only: [get_flash: 1, get_flash: 2, view_module: 1] # Use all HTML functionality (forms, tags, etc) use Phoenix.HTML import CodenamexWeb.ErrorHelpers import CodenamexWeb.Gettext alias CodenamexWeb.Router.Helpers, as: Routes end end def router do quote do use Phoenix.Router import Plug.Conn import Phoenix.Controller end end def channel do quote do use Phoenix.Channel import CodenamexWeb.Gettext end end @doc """ When used, dispatch to the appropriate controller/view/etc. """ defmacro __using__(which) when is_atom(which) do apply(__MODULE__, which, []) end end
23.628571
83
0.69347
79f6b5f3e39531b74939db2cb80ca24f0443ec3f
2,231
ex
Elixir
lib/crawly/engine.ex
harlantwood/crawly
d57a1b97e4a909d20f03f063a27157c8209367c4
[ "Apache-2.0" ]
null
null
null
lib/crawly/engine.ex
harlantwood/crawly
d57a1b97e4a909d20f03f063a27157c8209367c4
[ "Apache-2.0" ]
null
null
null
lib/crawly/engine.ex
harlantwood/crawly
d57a1b97e4a909d20f03f063a27157c8209367c4
[ "Apache-2.0" ]
null
null
null
defmodule Crawly.Engine do @moduledoc """ Crawly Engine - process responsible for starting and stopping spiders. Stores all currently running spiders. """ require Logger use GenServer @type t :: %__MODULE__{started_spiders: started_spiders()} @type started_spiders() :: %{optional(module()) => identifier()} defstruct started_spiders: %{} @spec start_spider(module()) :: :ok | {:error, :spider_already_started} | {:error, :atom} def start_spider(spider_name) do GenServer.call(__MODULE__, {:start_spider, spider_name}) end @spec stop_spider(module()) :: :ok | {:error, :spider_not_running} def stop_spider(spider_name) do GenServer.call(__MODULE__, {:stop_spider, spider_name}) end @spec running_spiders() :: started_spiders() def running_spiders() do GenServer.call(__MODULE__, :running_spiders) end def start_link() do GenServer.start_link(__MODULE__, [], name: __MODULE__) end @spec init(any) :: {:ok, __MODULE__.t()} def init(_args) do {:ok, %Crawly.Engine{}} end def handle_call(:running_spiders, _from, state) do {:reply, state.started_spiders, state} end def handle_call({:start_spider, spider_name}, _form, state) do result = case Map.get(state.started_spiders, spider_name) do nil -> Crawly.EngineSup.start_spider(spider_name) _ -> {:error, :spider_already_started} end {msg, new_started_spiders} = case result do {:ok, pid} -> {:ok, Map.put(state.started_spiders, spider_name, pid)} {:error, _} = err -> {err, state.started_spiders} end {:reply, msg, %Crawly.Engine{state | started_spiders: new_started_spiders}} end def handle_call({:stop_spider, spider_name}, _form, state) do {msg, new_started_spiders} = case Map.pop(state.started_spiders, spider_name) do {nil, _} -> {{:error, :spider_not_running}, state.started_spiders} {pid, new_started_spiders} -> Crawly.EngineSup.stop_spider(pid) {:ok, new_started_spiders} end {:reply, msg, %Crawly.Engine{state | started_spiders: new_started_spiders}} end end
26.247059
79
0.650381
79f6d3ea3aefb37646a84d0f8b181f850552c182
1,127
ex
Elixir
backend/lib/backend_web/controllers/goal_controller.ex
silver-panda/budgetr
d8cad5c1401677947444add24c8d41f2450c8cc3
[ "MIT" ]
null
null
null
backend/lib/backend_web/controllers/goal_controller.ex
silver-panda/budgetr
d8cad5c1401677947444add24c8d41f2450c8cc3
[ "MIT" ]
null
null
null
backend/lib/backend_web/controllers/goal_controller.ex
silver-panda/budgetr
d8cad5c1401677947444add24c8d41f2450c8cc3
[ "MIT" ]
null
null
null
defmodule BackendWeb.GoalController do use BackendWeb, :controller alias Backend.Budgets alias Backend.Budgets.Goal action_fallback BackendWeb.FallbackController def index(conn, _params) do user_goals = Budgets.list_user_goals() render(conn, "index.json", user_goals: user_goals) end def create(conn, %{"goal" => goal_params}) do with {:ok, %Goal{} = goal} <- Budgets.create_goal(goal_params) do conn |> put_status(:created) |> put_resp_header("location", Routes.goal_path(conn, :show, goal)) |> render("show.json", goal: goal) end end def show(conn, %{"id" => id}) do goal = Budgets.get_goal!(id) render(conn, "show.json", goal: goal) end def update(conn, %{"id" => id, "goal" => goal_params}) do goal = Budgets.get_goal!(id) with {:ok, %Goal{} = goal} <- Budgets.update_goal(goal, goal_params) do render(conn, "show.json", goal: goal) end end def delete(conn, %{"id" => id}) do goal = Budgets.get_goal!(id) with {:ok, %Goal{}} <- Budgets.delete_goal(goal) do send_resp(conn, :no_content, "") end end end
25.613636
75
0.639752
79f6ed80347cbb11db196e501863e9d229fa3336
574
ex
Elixir
Microsoft.Azure.Management.Authorization/lib/microsoft/azure/management/authorization/model/role_definition_filter.ex
chgeuer/ex_microsoft_azure_management
99cd9f7f2ff1fdbe69ca5bac55b6e2af91ba3603
[ "Apache-2.0" ]
4
2018-09-29T03:43:15.000Z
2021-04-01T18:30:46.000Z
Microsoft.Azure.Management.Authorization/lib/microsoft/azure/management/authorization/model/role_definition_filter.ex
chgeuer/ex_microsoft_azure_management
99cd9f7f2ff1fdbe69ca5bac55b6e2af91ba3603
[ "Apache-2.0" ]
null
null
null
Microsoft.Azure.Management.Authorization/lib/microsoft/azure/management/authorization/model/role_definition_filter.ex
chgeuer/ex_microsoft_azure_management
99cd9f7f2ff1fdbe69ca5bac55b6e2af91ba3603
[ "Apache-2.0" ]
null
null
null
# 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 Microsoft.Azure.Management.Authorization.Model.RoleDefinitionFilter do @moduledoc """ Role Definitions filter """ @derive [Poison.Encoder] defstruct [ :"roleName" ] @type t :: %__MODULE__{ :"roleName" => String.t } end defimpl Poison.Decoder, for: Microsoft.Azure.Management.Authorization.Model.RoleDefinitionFilter do def decode(value, _options) do value end end
22.076923
99
0.731707
79f721d60177a524c784a23c278597559a3475c0
3,317
ex
Elixir
clients/safe_browsing/lib/google_api/safe_browsing/v4/api/threat_lists.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/safe_browsing/lib/google_api/safe_browsing/v4/api/threat_lists.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/safe_browsing/lib/google_api/safe_browsing/v4/api/threat_lists.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
1
2018-07-28T20:50:50.000Z
2018-07-28T20:50:50.000Z
# 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.SafeBrowsing.V4.Api.ThreatLists do @moduledoc """ API calls for all endpoints tagged `ThreatLists`. """ alias GoogleApi.SafeBrowsing.V4.Connection import GoogleApi.SafeBrowsing.V4.RequestBuilder @doc """ Lists the Safe Browsing threat lists available for download. ## Parameters - connection (GoogleApi.SafeBrowsing.V4.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :upload_protocol (String): Upload protocol for media (e.g. \&quot;raw\&quot;, \&quot;multipart\&quot;). - :pretty_print (Boolean): Returns response with indentations and line breaks. - :upload_type (String): Legacy upload protocol for media (e.g. \&quot;media\&quot;, \&quot;multipart\&quot;). - :fields (String): Selector specifying which fields to include in a partial response. - :callback (String): JSONP - :__/xgafv (String): V1 error format. - :alt (String): Data format for response. - :access_token (String): OAuth access token. - :key (String): 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. - :quota_user (String): 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. - :pp (Boolean): Pretty-print response. - :oauth_token (String): OAuth 2.0 token for the current user. - :bearer_token (String): OAuth bearer token. ## Returns {:ok, %GoogleApi.SafeBrowsing.V4.Model.ListThreatListsResponse{}} on success {:error, info} on failure """ @spec safebrowsing_threat_lists_list(Tesla.Env.client, keyword()) :: {:ok, GoogleApi.SafeBrowsing.V4.Model.ListThreatListsResponse.t} | {:error, Tesla.Env.t} def safebrowsing_threat_lists_list(connection, opts \\ []) do optional_params = %{ :"upload_protocol" => :query, :"prettyPrint" => :query, :"uploadType" => :query, :"fields" => :query, :"callback" => :query, :"$.xgafv" => :query, :"alt" => :query, :"access_token" => :query, :"key" => :query, :"quotaUser" => :query, :"pp" => :query, :"oauth_token" => :query, :"bearer_token" => :query } %{} |> method(:get) |> url("/v4/threatLists") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%GoogleApi.SafeBrowsing.V4.Model.ListThreatListsResponse{}) end end
40.950617
178
0.69189
79f72fbf294a91be0c8a1b36b1fbf82ebd6649b3
158
ex
Elixir
web/controllers/page_controller.ex
Project-ShangriLa/sana_server_phoenix
d2ea4cc023d02e7249ae9267bb2b41a212b79ce7
[ "Apache-2.0" ]
5
2015-11-07T11:27:08.000Z
2017-06-23T00:54:20.000Z
web/controllers/page_controller.ex
Project-ShangriLa/sana_server_phoenix
d2ea4cc023d02e7249ae9267bb2b41a212b79ce7
[ "Apache-2.0" ]
null
null
null
web/controllers/page_controller.ex
Project-ShangriLa/sana_server_phoenix
d2ea4cc023d02e7249ae9267bb2b41a212b79ce7
[ "Apache-2.0" ]
null
null
null
defmodule SanaServerPhoenix.PageController do use SanaServerPhoenix.Web, :controller def index(conn, _params) do render conn, "index.html" end end
19.75
45
0.765823
79f7471fdd4395516dc9ae8d271b0106d8e72b11
6,270
exs
Elixir
test/api_classes/api_base_test.exs
InfiniteSoul/proxer_ex
df60ca5d4b9222d77ff685b7c1897781a738abc1
[ "MIT" ]
null
null
null
test/api_classes/api_base_test.exs
InfiniteSoul/proxer_ex
df60ca5d4b9222d77ff685b7c1897781a738abc1
[ "MIT" ]
null
null
null
test/api_classes/api_base_test.exs
InfiniteSoul/proxer_ex
df60ca5d4b9222d77ff685b7c1897781a738abc1
[ "MIT" ]
null
null
null
defmodule ProxerEx.Test.Api.Base do use ExUnit.Case, async: true defmodule TestApi do use ProxerEx.Api.Base, api_class: "test_api" api_func "test_func_without_params" do api_doc("DOC_TEXT") end api_func "test_func_with_params" do api_doc("DOC_TEXT") parameter("test_param_1", :get) parameter("test_param_2", :post) end api_func "test_func_with_authorization", authorization: true do parameter("test_param", :get) end api_func "test_func_with_extra_header", extra_header: [test_header: "header value"] do parameter("test_param", :post) end api_func "TESTFuncTo Escape" do api_doc("DOC_TEXT") end api_func "test_func_optional_parameter" do parameter("test_param_1", :post) parameter("test_param_2", :get, optional: true) end api_func "test_func_parameter_mutually_exclusive" do parameter("test_param_1", :get, not_with: ["test_param_2"]) parameter("test_param_2", :post, not_with: ["test_param_1"]) end api_func "test_func_with_paging_parameter" do paging_parameters() end @doc false def test_processing(%ProxerEx.Request{get_args: get_args} = request, _name, _value) do get_args = get_args |> Map.put("1", "value 1") |> Map.put("key 2", "value of key 2") {:ok, %{request | get_args: get_args}} end api_func "test_func_custom_processing" do parameter("test_param", :get, process: :test_processing) end end test "all functions are defined" do assert function_exported?(TestApi, :test_func_without_params, 0) assert function_exported?(TestApi, :test_func_with_params, 1) assert function_exported?(TestApi, :test_func_with_authorization, 1) assert function_exported?(TestApi, :test_func_with_extra_header, 1) assert function_exported?(TestApi, :test_func_optional_parameter, 1) assert function_exported?(TestApi, :test_func_parameter_mutually_exclusive, 1) assert function_exported?(TestApi, :test_func_custom_processing, 1) end test "function names are correctly escaped" do assert function_exported?(TestApi, :test_func_to_escape, 0) {:ok, request} = TestApi.test_func_to_escape() assert request == %ProxerEx.Request{ method: :get, api_class: "test_api", api_func: "TESTFuncTo Escape" } end test "documentation exists where given" do # Currently not working due to limitations of Code.get_docs/2 end test "correct request is returned without parameter" do {:ok, request} = TestApi.test_func_without_params() assert request == %ProxerEx.Request{ method: :get, api_class: "test_api", api_func: "test_func_without_params" } end test "correct request is returned with parameters" do {:ok, request} = TestApi.test_func_with_params(test_param_1: "value1", test_param_2: "value 2") assert request == %ProxerEx.Request{ method: :post, api_class: "test_api", api_func: "test_func_with_params", get_args: %{test_param_1: "value1"}, post_args: [test_param_2: "value 2"] } end test "authorization option is passed through to the request" do {:ok, request} = TestApi.test_func_with_authorization(test_param: "value string") assert request == %ProxerEx.Request{ method: :get, api_class: "test_api", api_func: "test_func_with_authorization", get_args: %{test_param: "value string"}, authorization: true } end test "extra headers are passed through to the request" do {:ok, request} = TestApi.test_func_with_extra_header(test_param: "post value string") assert request == %ProxerEx.Request{ method: :post, api_class: "test_api", api_func: "test_func_with_extra_header", post_args: [test_param: "post value string"], extra_header: [test_header: "header value"] } end describe "optional parameter are optional" do test "optional parameter must not be given" do {:ok, request} = TestApi.test_func_optional_parameter(test_param_1: "value1") assert request == %ProxerEx.Request{ method: :post, api_class: "test_api", api_func: "test_func_optional_parameter", post_args: [test_param_1: "value1"] } end test "optional parameter are included in the request if given" do {:ok, request} = TestApi.test_func_optional_parameter(test_param_1: "value1", test_param_2: "value 2") assert request == %ProxerEx.Request{ method: :post, api_class: "test_api", api_func: "test_func_optional_parameter", get_args: %{test_param_2: "value 2"}, post_args: [test_param_1: "value1"] } end end describe "mutually exclusive parameter are mutually exclusive" do test "mutually exclusive parameters cannot be given at the same time" do {:error, _} = TestApi.test_func_parameter_mutually_exclusive( test_param_1: "value", test_param_2: "asfzas" ) end test "if only one of the mutually exclusive parameters are given, then processing should succeed" do {:ok, _} = TestApi.test_func_parameter_mutually_exclusive(test_param_1: "value") end end test "custom processing function is called" do {:ok, request} = TestApi.test_func_custom_processing(test_param: "val") assert request == %ProxerEx.Request{ method: :get, api_class: "test_api", api_func: "test_func_custom_processing", get_args: %{"1" => "value 1", "key 2" => "value of key 2"} } end test "paged parameter are added" do {:ok, request} = TestApi.test_func_with_paging_parameter(p: 1, limit: 200) assert request == %ProxerEx.Request{ method: :get, api_class: "test_api", api_func: "test_func_with_paging_parameter", get_args: %{p: 1, limit: 200} } end end
32.65625
104
0.643222
79f778b634ad6a6fdb9484a4f267c60e32d473b6
16,249
exs
Elixir
test/arrow/disruption_test.exs
paulswartz/arrow
c1ba1ce52107c0ed94ce9bca2fef2bfeb606b8f9
[ "MIT" ]
null
null
null
test/arrow/disruption_test.exs
paulswartz/arrow
c1ba1ce52107c0ed94ce9bca2fef2bfeb606b8f9
[ "MIT" ]
null
null
null
test/arrow/disruption_test.exs
paulswartz/arrow
c1ba1ce52107c0ed94ce9bca2fef2bfeb606b8f9
[ "MIT" ]
null
null
null
defmodule Arrow.DisruptionTest do @moduledoc false use Arrow.DataCase alias Arrow.Disruption alias Arrow.DisruptionRevision alias Arrow.Repo describe "database" do test "defaults to no disruptions" do assert [] = Repo.all(Disruption) end end describe "create/2" do test "inserts a new disruption and revision" do adj = insert(:adjustment) attrs = %{ "start_date" => "2021-01-01", "end_date" => "2021-12-31", "days_of_week" => [%{"day_name" => "monday", "start_time" => "20:00:00"}], "exceptions" => [%{"excluded_date" => "2021-01-11"}], "trip_short_names" => [%{"trip_short_name" => "777"}] } assert {:ok, _dr} = Arrow.Disruption.create(attrs, [adj]) [d] = Repo.all(Arrow.Disruption) [dr] = DisruptionRevision |> Repo.all() |> Repo.preload(DisruptionRevision.associations()) assert dr.disruption_id == d.id assert dr.start_date == ~D[2021-01-01] assert dr.end_date == ~D[2021-12-31] assert [ %Arrow.Disruption.DayOfWeek{ day_name: "monday", start_time: ~T[20:00:00], end_time: nil } ] = dr.days_of_week assert [%Arrow.Disruption.Exception{excluded_date: ~D[2021-01-11]}] = dr.exceptions assert [%Arrow.Disruption.TripShortName{trip_short_name: "777"}] = dr.trip_short_names end test "can't create disruption with start date after end date" do adj = insert(:adjustment) attrs = %{ "start_date" => "2020-12-31", "end_date" => "2020-01-01", "days_of_week" => [%{"day_name" => "monday"}] } assert {:error, e} = Arrow.Disruption.create(attrs, [adj]) assert [ %{detail: "Start date can't be after end date."} ] = ArrowWeb.Utilities.format_errors(e) end test "can't create disruption with day of week outside date range" do adj = insert(:adjustment) attrs = %{ "start_date" => "2020-08-17", "end_date" => "2020-08-21", "days_of_week" => [%{"day_name" => "sunday"}] } assert {:error, e} = Arrow.Disruption.create(attrs, [adj]) assert [ %{detail: "Days of week should fall between start and end dates"} ] = ArrowWeb.Utilities.format_errors(e) end test "can't create disruption with exception date outside date range" do adj = insert(:adjustment) attrs = %{ "start_date" => "2020-08-17", "end_date" => "2020-08-21", "days_of_week" => [%{"day_name" => "tuesday"}], "exceptions" => [%{"excluded_date" => "2020-09-01"}] } assert {:error, e} = Arrow.Disruption.create(attrs, [adj]) assert [ %{detail: "Exceptions should fall between start and end dates"} ] = ArrowWeb.Utilities.format_errors(e) end test "can't create disruption with duplicate exception dates" do adj = insert(:adjustment) attrs = %{ "start_date" => "2020-08-17", "end_date" => "2020-08-21", "days_of_week" => [%{"day_name" => "tuesday"}], "exceptions" => [%{"excluded_date" => "2020-08-18"}, %{"excluded_date" => "2020-08-18"}] } assert {:error, e} = Arrow.Disruption.create(attrs, [adj]) assert [ %{detail: "Exceptions should be unique"} ] = ArrowWeb.Utilities.format_errors(e) end test "can't create disruption with exception dates that don't apply to day of week" do adj = insert(:adjustment) attrs = %{ "start_date" => "2020-08-17", "end_date" => "2020-08-21", "days_of_week" => [%{"day_name" => "tuesday"}], "exceptions" => [%{"excluded_date" => "2020-08-19"}] } assert {:error, e} = Arrow.Disruption.create(attrs, [adj]) assert [ %{detail: "Exceptions should be applicable to days of week"} ] = ArrowWeb.Utilities.format_errors(e) end test "can't create disruption without days of week" do adj = insert(:adjustment) attrs = %{ "start_date" => "2020-08-17", "end_date" => "2020-08-21" } assert {:error, e} = Arrow.Disruption.create(attrs, [adj]) assert [ %{detail: "Days of week should have at least 1 item(s)"} ] = ArrowWeb.Utilities.format_errors(e) end test "can't create disruption without adjustments" do attrs = %{ "start_date" => "2020-08-17", "end_date" => "2020-08-21", "days_of_week" => [%{"day_name" => "tuesday"}] } assert {:error, e} = Arrow.Disruption.create(attrs, []) assert [ %{detail: "Adjustments should have at least 1 item(s)"} ] = ArrowWeb.Utilities.format_errors(e) end end describe "update/2" do test "creates a new disruption revision" do d = insert(:disruption) dr = insert(:disruption_revision, %{ disruption: d, start_date: ~D[2021-01-01], end_date: ~D[2021-12-31], days_of_week: [build(:day_of_week, %{day_name: "monday"})], exceptions: [build(:exception, %{excluded_date: ~D[2021-01-11]})], trip_short_names: [build(:trip_short_name, %{trip_short_name: "777"})] }) Repo.update!(Ecto.Changeset.change(d, %{ready_revision_id: dr.id})) dr_id = dr.id new_attrs = %{ "start_date" => "2021-01-01", "end_date" => "2021-11-30", "days_of_week" => [%{"day_name" => "monday", "start_time" => "20:45:00"}], "exceptions" => [%{"excluded_date" => "2021-01-11"}, %{"excluded_date" => "2021-01-18"}], "trip_short_names" => [%{"trip_short_name" => "777"}, %{"trip_short_name" => "888"}] } assert {:ok, _dr} = Arrow.Disruption.update(dr_id, new_attrs) dr_ids = Repo.all(Ecto.Query.from(dr in DisruptionRevision, select: dr.id)) assert length(dr_ids) == 2 new_dr_id = Enum.find(dr_ids, &(&1 != dr_id)) new_dr = DisruptionRevision |> Repo.get!(new_dr_id) |> Repo.preload(DisruptionRevision.associations()) d = Repo.get!(Arrow.Disruption, new_dr.disruption_id) assert new_dr.disruption_id == d.id assert d.ready_revision_id == dr_id assert new_dr.start_date == ~D[2021-01-01] assert new_dr.end_date == ~D[2021-11-30] assert [ %Arrow.Disruption.DayOfWeek{ day_name: "monday", start_time: ~T[20:45:00], end_time: nil } ] = new_dr.days_of_week assert Enum.find(new_dr.exceptions, &(&1.excluded_date == ~D[2021-01-11])) assert Enum.find(new_dr.exceptions, &(&1.excluded_date == ~D[2021-01-18])) assert Enum.find(new_dr.trip_short_names, &(&1.trip_short_name == "777")) assert Enum.find(new_dr.trip_short_names, &(&1.trip_short_name == "888")) end test "can't update disruption with start date after end date" do d = insert(:disruption) dr = insert(:disruption_revision, %{ disruption: d, start_date: ~D[2020-08-17], end_date: ~D[2020-08-21], days_of_week: [build(:day_of_week, %{day_name: "tuesday"})] }) Repo.update!(Ecto.Changeset.change(d, %{ready_revision_id: dr.id})) attrs = %{ "start_date" => "2020-12-31", "end_date" => "2020-01-01", "days_of_week" => [%{"day_name" => "tuesday"}] } assert {:error, e} = Arrow.Disruption.update(dr.id, attrs) assert [ %{detail: "Start date can't be after end date."} ] = ArrowWeb.Utilities.format_errors(e) end test "can't update disruption with day of week outside date range" do d = insert(:disruption) dr = insert(:disruption_revision, %{ disruption: d, start_date: ~D[2020-08-17], end_date: ~D[2020-08-21], days_of_week: [build(:day_of_week, %{day_name: "tuesday"})] }) Repo.update!(Ecto.Changeset.change(d, %{ready_revision_id: dr.id})) attrs = %{ "start_date" => "2020-08-17", "end_date" => "2020-08-21", "days_of_week" => [%{"day_name" => "sunday"}] } assert {:error, e} = Arrow.Disruption.update(dr.id, attrs) assert Repo.all(from(dr in DisruptionRevision, select: count(dr.id))) == [1] assert [ %{detail: "Days of week should fall between start and end dates"} ] = ArrowWeb.Utilities.format_errors(e) end test "can't update disruption with exception date outside date range" do d = insert(:disruption) dr = insert(:disruption_revision, %{ disruption: d, start_date: ~D[2020-08-17], end_date: ~D[2020-08-21], days_of_week: [build(:day_of_week, %{day_name: "tuesday"})] }) Repo.update!(Ecto.Changeset.change(d, %{ready_revision_id: dr.id})) attrs = %{ "start_date" => "2020-08-17", "end_date" => "2020-08-21", "days_of_week" => [%{"day_name" => "tuesday"}], "exceptions" => [%{"excluded_date" => "2020-09-01"}] } assert {:error, e} = Arrow.Disruption.update(dr.id, attrs) assert Repo.all(from(dr in DisruptionRevision, select: count(dr.id))) == [1] assert [ %{detail: "Exceptions should fall between start and end dates"} ] = ArrowWeb.Utilities.format_errors(e) end test "can't update disruption with duplicate exception dates" do d = insert(:disruption) dr = insert(:disruption_revision, %{ disruption: d, start_date: ~D[2020-08-17], end_date: ~D[2020-08-21], days_of_week: [build(:day_of_week, %{day_name: "tuesday"})] }) Repo.update!(Ecto.Changeset.change(d, %{ready_revision_id: dr.id})) attrs = %{ "start_date" => "2020-08-17", "end_date" => "2020-08-21", "days_of_week" => [%{"day_name" => "tuesday"}], "exceptions" => [%{"excluded_date" => "2020-08-18"}, %{"excluded_date" => "2020-08-18"}] } assert {:error, e} = Arrow.Disruption.update(dr.id, attrs) assert Repo.all(from(dr in DisruptionRevision, select: count(dr.id))) == [1] assert [ %{detail: "Exceptions should be unique"} ] = ArrowWeb.Utilities.format_errors(e) end test "can't update disruption with exception dates that don't apply to day of week" do d = insert(:disruption) dr = insert(:disruption_revision, %{ disruption: d, start_date: ~D[2020-08-17], end_date: ~D[2020-08-21], days_of_week: [build(:day_of_week, %{day_name: "tuesday"})] }) Repo.update!(Ecto.Changeset.change(d, %{ready_revision_id: dr.id})) attrs = %{ "start_date" => "2020-08-17", "end_date" => "2020-08-21", "days_of_week" => [%{"day_name" => "tuesday"}], "exceptions" => [%{"excluded_date" => "2020-08-19"}] } assert {:error, e} = Arrow.Disruption.update(dr.id, attrs) assert Repo.all(from(dr in DisruptionRevision, select: count(dr.id))) == [1] assert [ %{detail: "Exceptions should be applicable to days of week"} ] = ArrowWeb.Utilities.format_errors(e) end test "can't update disruption to remove all days of week" do d = insert(:disruption) dr = insert(:disruption_revision, %{ disruption: d, start_date: ~D[2020-08-17], end_date: ~D[2020-08-21], days_of_week: [build(:day_of_week, %{day_name: "tuesday"})] }) Repo.update!(Ecto.Changeset.change(d, %{ready_revision_id: dr.id})) attrs = %{ "start_date" => "2020-08-17", "end_date" => "2020-08-21", "days_of_week" => [] } assert {:error, e} = Arrow.Disruption.update(dr.id, attrs) assert Repo.all(from(dr in DisruptionRevision, select: count(dr.id))) == [1] assert [ %{detail: "Days of week should have at least 1 item(s)"} ] = ArrowWeb.Utilities.format_errors(e) end end describe "delete/1" do test "creates a new revision which isn't active" do d = insert(:disruption) dr1 = insert(:disruption_revision, %{ disruption: d, start_date: ~D[2020-08-17], end_date: ~D[2020-08-21], days_of_week: [build(:day_of_week, %{day_name: "tuesday"})] }) Repo.update!(Ecto.Changeset.change(d, %{ready_revision_id: dr1.id})) assert {:ok, dr2} = Arrow.Disruption.delete(dr1.id) d = Repo.get(Arrow.Disruption, d.id) assert Repo.all(from(dr in DisruptionRevision, select: count(dr.id))) == [2] assert dr2.is_active == false assert d.ready_revision_id == dr1.id end end describe "draft_vs_ready" do test "returns all revisions between draft and ready" do d = insert(:disruption) _dr1 = insert(:disruption_revision, %{disruption: d}) dr2 = insert(:disruption_revision, %{disruption: d}) dr3 = insert(:disruption_revision, %{disruption: d}) dr4 = insert(:disruption_revision, %{disruption: d}) Repo.update!(Ecto.Changeset.change(d, %{ready_revision_id: dr2.id})) dr2_id = dr2.id dr3_id = dr3.id dr4_id = dr4.id assert {[queried_d], []} = Arrow.Disruption.draft_vs_ready() assert queried_d.id == d.id assert [ %DisruptionRevision{id: ^dr2_id}, %DisruptionRevision{id: ^dr3_id}, %DisruptionRevision{id: ^dr4_id} ] = queried_d.revisions end test "does not return a disruption without a different draft" do d = insert(:disruption) _dr1 = insert(:disruption_revision, %{disruption: d}) dr2 = insert(:disruption_revision, %{disruption: d}) Repo.update!(Ecto.Changeset.change(d, %{ready_revision_id: dr2.id})) assert Arrow.Disruption.draft_vs_ready() == {[], []} end test "returns a newly created disruption" do d = insert(:disruption) dr1 = insert(:disruption_revision, %{disruption: d}) dr2 = insert(:disruption_revision, %{disruption: d}) dr1_id = dr1.id dr2_id = dr2.id assert {[], [queried_d]} = Arrow.Disruption.draft_vs_ready() assert [%DisruptionRevision{id: ^dr1_id}, %DisruptionRevision{id: ^dr2_id}] = queried_d.revisions end end describe "diff_revisions/1" do test "calculates diffs from revision to revision" do d = insert(:disruption) _dr1 = insert(:disruption_revision, %{ disruption: d }) _dr2 = insert(:disruption_revision, %{ disruption: d, exceptions: [build(:exception, %{excluded_date: ~D[2020-01-01]})] }) _dr3 = insert(:disruption_revision, %{ disruption: d, exceptions: [ build(:exception, %{excluded_date: ~D[2020-01-01]}), build(:exception, %{excluded_date: ~D[2020-02-01]}) ] }) disruption = Arrow.Repo.get(Arrow.Disruption, d.id) |> Repo.preload(revisions: DisruptionRevision.associations()) assert [ ["The following exception dates were added: 2020-01-01"], ["The following exception dates were added: 2020-02-01"] ] = Disruption.diff_revisions(disruption) end test "returns no diffs if only one revision, or no revisions" do d1 = insert(:disruption) d2 = insert(:disruption) _dr1 = insert(:disruption_revision, %{disruption: d2}) disruption1 = Arrow.Repo.get(Disruption, d1.id) |> Repo.preload(revisions: DisruptionRevision.associations()) disruption2 = Arrow.Repo.get(Disruption, d2.id) |> Repo.preload(revisions: DisruptionRevision.associations()) assert Disruption.diff_revisions(disruption1) == [] assert Disruption.diff_revisions(disruption2) == [] end end end
31.798434
97
0.572404
79f77bca8e48aa54a8a1e40177001bd0d637b3e6
590
ex
Elixir
test/support/local_cluster_helper.ex
pdgonzalez872/horde
1b274eaa07b02c38c2490e79051548ec476b4a11
[ "MIT" ]
null
null
null
test/support/local_cluster_helper.ex
pdgonzalez872/horde
1b274eaa07b02c38c2490e79051548ec476b4a11
[ "MIT" ]
null
null
null
test/support/local_cluster_helper.ex
pdgonzalez872/horde
1b274eaa07b02c38c2490e79051548ec476b4a11
[ "MIT" ]
null
null
null
defmodule LocalClusterHelper do def start(m, f, a) do :erlang.apply(m, f, a) receive do end end def send_msg(pid, msg) do fn -> send(pid, msg) end end end defmodule EchoServer do def start_link(pid) do GenServer.start_link(__MODULE__, pid) end # def via_tuple do # {:via, Horde.Registry, {:horde_registry, "echo"}} # end def init(pid) do send(self(), :do_send) {:ok, pid} end def handle_info(:do_send, pid) do send(pid, {node, :hello_echo_server}) Process.send_after(self(), :do_send, 1_000) {:noreply, pid} end end
17.352941
55
0.633898
79f7869ef6a9ae4924436b09944a5d3085740bf4
238
ex
Elixir
lib/easypost/customs_item.ex
winestyr/ex_easypost
a8563ccbff429ad181280c438efeea65383ff852
[ "MIT" ]
6
2017-09-21T13:19:56.000Z
2021-01-07T18:31:42.000Z
lib/easypost/customs_item.ex
winestyr/ex_easypost
a8563ccbff429ad181280c438efeea65383ff852
[ "MIT" ]
null
null
null
lib/easypost/customs_item.ex
winestyr/ex_easypost
a8563ccbff429ad181280c438efeea65383ff852
[ "MIT" ]
2
2018-07-11T07:12:08.000Z
2020-06-29T02:04:48.000Z
defmodule EasyPost.CustomsItem do @doc """ Create a `Customsitem`. """ @spec create(map) :: EasyPost.Operation.t() def create(params) do %EasyPost.Operation{ method: :post, params: params, path: "/customs_items" } end end
23.8
80
0.676471
79f7a35784617949d4da11551193dd1236304708
1,423
ex
Elixir
test/support/data_case.ex
SparkPost/elixir-webhook-sample
22d367b63f4995eb0ddb4b0aaf484790987b8491
[ "Apache-2.0" ]
1
2021-12-08T18:15:33.000Z
2021-12-08T18:15:33.000Z
test/support/data_case.ex
SparkPost/elixir-webhook-sample
22d367b63f4995eb0ddb4b0aaf484790987b8491
[ "Apache-2.0" ]
null
null
null
test/support/data_case.ex
SparkPost/elixir-webhook-sample
22d367b63f4995eb0ddb4b0aaf484790987b8491
[ "Apache-2.0" ]
null
null
null
defmodule TrackUserAgents.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, it cannot be async. For this reason, every test runs inside a transaction which is reset at the beginning of the test unless the test case is marked as async. """ use ExUnit.CaseTemplate using do quote do alias TrackUserAgents.Repo import Ecto import Ecto.Changeset import Ecto.Query import TrackUserAgents.DataCase end end setup tags do :ok = Ecto.Adapters.SQL.Sandbox.checkout(TrackUserAgents.Repo) unless tags[:async] do Ecto.Adapters.SQL.Sandbox.mode(TrackUserAgents.Repo, {:shared, self()}) end :ok end @doc """ A helper that transform changeset errors to 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} -> Enum.reduce(opts, message, fn {key, value}, acc -> String.replace(acc, "%{#{key}}", to_string(value)) end) end) end end
26.351852
77
0.688686
79f7c9a447560cc348a6429b4c80cb1cdc41f01d
1,133
ex
Elixir
lib/sbom_poc_web/live/page_live.ex
TraceyOnim/SbomPoc-sFractal
bac895a7eda61c47c00b8bbe682a6fda4dd7255c
[ "MIT" ]
2
2020-10-04T12:41:58.000Z
2021-03-11T20:51:26.000Z
lib/sbom_poc_web/live/page_live.ex
TraceyOnim/SbomPoc-sFractal
bac895a7eda61c47c00b8bbe682a6fda4dd7255c
[ "MIT" ]
113
2020-07-25T02:29:33.000Z
2022-03-01T01:07:23.000Z
lib/sbom_poc_web/live/page_live.ex
TraceyOnim/SbomPoc-sFractal
bac895a7eda61c47c00b8bbe682a6fda4dd7255c
[ "MIT" ]
5
2020-07-10T09:57:58.000Z
2021-03-11T20:51:29.000Z
defmodule SbomPocWeb.PageLive do @moduledoc "Landing page live view" use SbomPocWeb, :live_view @impl true def mount(_params, _session, socket) do {:ok, assign(socket, query: "", results: %{})} end @impl true def handle_event("suggest", %{"q" => query}, socket) do {:noreply, assign(socket, results: search(query), query: query)} end @impl true def handle_event("search", %{"q" => query}, socket) do case search(query) do %{^query => vsn} -> {:noreply, redirect(socket, external: "https://hexdocs.pm/#{query}/#{vsn}")} _ -> {:noreply, socket |> put_flash(:error, "No dependencies found matching \"#{query}\"") |> assign(results: %{}, query: query)} end end defp search(query) do # if not SbomPocWeb.Endpoint.config(:code_reloader) do # raise "action disabled when not in development" # end for {app, desc, vsn} <- Application.started_applications(), app = to_string(app), String.starts_with?(app, query) and not List.starts_with?(desc, ~c"ERTS"), into: %{}, do: {app, vsn} end end
27.634146
84
0.603707
79f7c9c1a5bb3d07b0c67f490599e99960e38df9
422
ex
Elixir
lib/nox/parsers/logger.ex
tableturn/nox
4fbe1a08196b2f84cca702715e84e6c7a67a42aa
[ "Apache-2.0" ]
5
2018-04-28T14:25:09.000Z
2020-10-27T07:06:59.000Z
lib/nox/parsers/logger.ex
kbrw/nodex
f362cb135cf5da23cc3c1bc159cbe6d120ca1494
[ "Apache-2.0" ]
2
2018-04-19T08:52:58.000Z
2018-04-19T13:01:13.000Z
lib/nox/parsers/logger.ex
kbrw/nodex
f362cb135cf5da23cc3c1bc159cbe6d120ca1494
[ "Apache-2.0" ]
1
2019-07-12T11:10:28.000Z
2019-07-12T11:10:28.000Z
defmodule Nox.Parsers.Logger do @moduledoc """ Default CLI parser. Output lines with Logger.info """ use Nox.Parser require Logger @doc """ Level can be :info, :debug, :warn """ def init(level), do: level @doc false def parse(line, :info), do: (Logger.info(line); :info) def parse(line, :debug), do: (Logger.debug(line); :debug) def parse(line, :warn), do: (Logger.debug(line); :warn) end
21.1
59
0.63981
79f7ea6f981bc14eefaddc3e95687e76660928c7
1,398
ex
Elixir
test/support/data_case.ex
troelsim/matchalert
9379796b3046e0ce28674432568f9cb5b01aab6f
[ "Apache-2.0" ]
null
null
null
test/support/data_case.ex
troelsim/matchalert
9379796b3046e0ce28674432568f9cb5b01aab6f
[ "Apache-2.0" ]
null
null
null
test/support/data_case.ex
troelsim/matchalert
9379796b3046e0ce28674432568f9cb5b01aab6f
[ "Apache-2.0" ]
null
null
null
defmodule Matchalert.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, it cannot be async. For this reason, every test runs inside a transaction which is reset at the beginning of the test unless the test case is marked as async. """ use ExUnit.CaseTemplate using do quote do alias Matchalert.Repo import Ecto import Ecto.Changeset import Ecto.Query import Matchalert.DataCase end end setup tags do :ok = Ecto.Adapters.SQL.Sandbox.checkout(Matchalert.Repo) unless tags[:async] do Ecto.Adapters.SQL.Sandbox.mode(Matchalert.Repo, {:shared, self()}) end :ok end @doc """ A helper that transform changeset errors to 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} -> Enum.reduce(opts, message, fn {key, value}, acc -> String.replace(acc, "%{#{key}}", to_string(value)) end) end) end end
25.888889
77
0.683119
79f830699c2041efac4260f0193794e45bdf0838
186
exs
Elixir
priv/repo/migrations/20211205234245_create_lead_sources.exs
ThanhUong/Chronos
5e1b0823c585b784f5c51212513d518cab53a571
[ "MIT" ]
null
null
null
priv/repo/migrations/20211205234245_create_lead_sources.exs
ThanhUong/Chronos
5e1b0823c585b784f5c51212513d518cab53a571
[ "MIT" ]
null
null
null
priv/repo/migrations/20211205234245_create_lead_sources.exs
ThanhUong/Chronos
5e1b0823c585b784f5c51212513d518cab53a571
[ "MIT" ]
null
null
null
defmodule App.Repo.Migrations.CreateLeadSources do use Ecto.Migration def change do create table(:lead_sources) do add :name, :string timestamps() end end end
16.909091
50
0.693548
79f8310b20cd0057402c21c00c8bbadbb4dc291f
419
ex
Elixir
test/support/spy_formatter.ex
kianmeng/beamchmark
e5ee1af12339c5161dda0245f254bee9a382697d
[ "Apache-2.0" ]
34
2021-12-08T19:39:02.000Z
2022-03-31T13:55:41.000Z
test/support/spy_formatter.ex
kianmeng/beamchmark
e5ee1af12339c5161dda0245f254bee9a382697d
[ "Apache-2.0" ]
8
2022-01-12T13:47:28.000Z
2022-03-21T08:59:50.000Z
test/support/spy_formatter.ex
kianmeng/beamchmark
e5ee1af12339c5161dda0245f254bee9a382697d
[ "Apache-2.0" ]
1
2022-03-26T15:48:21.000Z
2022-03-26T15:48:21.000Z
defmodule SpyFormatter do @moduledoc false @behaviour Beamchmark.Formatter @impl true def format(suite, options) do send(options[:pid], {suite, options}) :ok end @impl true def format(new_suite, base_suite, options) do send(options[:pid], {new_suite, base_suite, options}) :ok end @impl true def write(data, options) do send(options[:pid], {data, options}) :ok end end
17.458333
57
0.665871
79f83dd42adb3d2dbb21397c737cb8dcc74dc281
4,637
ex
Elixir
clients/you_tube_reporting/lib/google_api/you_tube_reporting/v1/request_builder.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/you_tube_reporting/lib/google_api/you_tube_reporting/v1/request_builder.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/you_tube_reporting/lib/google_api/you_tube_reporting/v1/request_builder.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
1
2018-07-28T20:50:50.000Z
2018-07-28T20:50:50.000Z
# 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.YouTubeReporting.V1.RequestBuilder do @moduledoc """ Helper functions for building Tesla requests """ @path_template_regex ~r/{(\+?[^}]+)}/i @doc """ Specify the request method when building a request ## Parameters - request (Map) - Collected request options - m (String) - Request method ## Returns Map """ @spec method(map(), String.t) :: map() def method(request, m) do Map.put_new(request, :method, m) end @doc """ Specify the request method when building a request ## Parameters - request (Map) - Collected request options - u (String) - Request URL ## Returns Map """ @spec url(map(), String.t, Map.t) :: map() def url(request, u, replacements) do url(request, replace_path_template_vars(u, replacements)) end def url(request, u) do Map.put_new(request, :url, u) end def replace_path_template_vars(u, replacements) do Regex.replace(@path_template_regex, u, fn (_, var) -> replacement_value(var, replacements) end) end defp replacement_value("+" <> name, replacements) do URI.decode(replacement_value(name, replacements)) end defp replacement_value(name, replacements) do Map.get(replacements, name, "") end @doc """ Add optional parameters to the request ## Parameters - request (Map) - Collected request options - definitions (Map) - Map of parameter name to parameter location. - options (KeywordList) - The provided optional parameters ## Returns Map """ @spec add_optional_params(map(), %{optional(:atom) => :atom}, keyword()) :: map() def add_optional_params(request, _, []), do: request def add_optional_params(request, definitions, [{key, value} | tail]) do case definitions do %{^key => location} -> request |> add_param(location, key, value) |> add_optional_params(definitions, tail) _ -> add_optional_params(request, definitions, tail) end end @doc """ Add optional parameters to the request ## Parameters - request (Map) - Collected request options - location (atom) - Where to put the parameter - key (atom) - The name of the parameter - value (any) - The value of the parameter ## Returns Map """ @spec add_param(map(), :atom, :atom, any()) :: map() def add_param(request, :body, :body, value), do: Map.put(request, :body, value) def add_param(request, :body, key, value) do request |> Map.put_new_lazy(:body, &Tesla.Multipart.new/0) |> Map.update!(:body, &(Tesla.Multipart.add_field(&1, key, Poison.encode!(value), headers: [{:"Content-Type", "application/json"}]))) end def add_param(request, :file, name, path) do request |> Map.put_new_lazy(:body, &Tesla.Multipart.new/0) |> Map.update!(:body, &(Tesla.Multipart.add_file(&1, path, name: name))) end def add_param(request, :form, name, value) do request |> Map.update(:body, %{name => value}, &(Map.put(&1, name, value))) end def add_param(request, location, key, value) do Map.update(request, location, [{key, value}], &(&1 ++ [{key, value}])) end @doc """ Handle the response for a Tesla request ## Parameters - env (Tesla.Env) - The response object - struct - The shape of the struct to deserialize into ## Returns {:ok, struct} on success {:error, info} on failure """ @spec decode(Tesla.Env.t) :: {:ok, struct()} | {:error, Tesla.Env.t} def decode(%Tesla.Env{status: 200, body: body}), do: Poison.decode(body) def decode(response) do {:error, response} end @spec decode(Tesla.Env.t, struct()) :: {:ok, struct()} | {:error, Tesla.Env.t} def decode(%Tesla.Env{status: 200} = env, false), do: {:ok, env} def decode(%Tesla.Env{status: 200, body: body}, struct) do Poison.decode(body, as: struct) end def decode(response, _struct) do {:error, response} end end
28.801242
137
0.670045
79f8411c21e5f2dc7370bf108e2f97311b6c8e3a
1,261
ex
Elixir
lib/he_broker/request.ex
HackerExperience/HEBroker
2a653a43b512c6392f55508dfc1be8463a845b31
[ "BSD-3-Clause" ]
5
2017-02-15T18:25:35.000Z
2018-03-29T16:36:31.000Z
lib/he_broker/request.ex
HackerExperience/HeBroker
2a653a43b512c6392f55508dfc1be8463a845b31
[ "BSD-3-Clause" ]
null
null
null
lib/he_broker/request.ex
HackerExperience/HeBroker
2a653a43b512c6392f55508dfc1be8463a845b31
[ "BSD-3-Clause" ]
null
null
null
defmodule HeBroker.Request do alias HeBroker.Request.Dont alias HeBroker.Request.Just alias HeBroker.Request.Headers @debug? Application.get_env(:hebroker, :debug, Mix.env in [:test, :dev]) @trace? @debug? || Application.get_env(:hebroker, :trace, true) @processor @trace? && Just || Dont @type t :: %__MODULE__{ reply_to: pid | port | nil, message_id: reference, trace: [String.t], headers: Headers.t } defstruct \ reply_to: nil, message_id: nil, trace: [], headers: %Headers{} @doc false defdelegate bounce(request, topic), to: @processor @doc false def init, do: @processor.init(%__MODULE__{}) @doc false def init(nil, nil), do: init() def init(request, nil), do: request def init(nil, headers), do: %__MODULE__{init()| headers: Headers.new(headers)} def init(request, headers), do: %__MODULE__{request| headers: Headers.new(headers)} defmodule Dont do def bounce(request, _), do: request def init(request), do: request end defmodule Just do def bounce(request, topic), do: %{request| trace: [topic| request.trace], message_id: make_ref()} def init(request), do: %{request| message_id: make_ref()} end end
21.372881
75
0.64314
79f86f99cddef11e278db5fbb88faaafdc4e7ec1
2,696
exs
Elixir
config/prod.exs
synion/tilex
ea29646830efaa89fc47fad347f6e495ff7ce48b
[ "MIT" ]
1
2019-05-28T20:43:28.000Z
2019-05-28T20:43:28.000Z
config/prod.exs
synion/tilex
ea29646830efaa89fc47fad347f6e495ff7ce48b
[ "MIT" ]
1
2019-02-11T23:14:15.000Z
2019-02-11T23:14:15.000Z
config/prod.exs
synion/tilex
ea29646830efaa89fc47fad347f6e495ff7ce48b
[ "MIT" ]
1
2019-12-02T08:59:45.000Z
2019-12-02T08:59:45.000Z
use Mix.Config # For production, we configure the host to read the PORT # from the system environment. Therefore, you will need # to set PORT=80 before running your server. # # You should also configure the url host to something # meaningful, we use this information when generating URLs. # # Finally, we also include the path to a manifest # containing the digested version of static files. This # manifest is generated by the mix phoenix.digest task # which you typically run after static files are built. config :tilex, TilexWeb.Endpoint, http: [port: {:system, "PORT"}], # For some reason, this config below is not being reflected in generated URLs - especially path. url: [scheme: "https", host: System.get_env("APP_HOST"), path: "/til"], cache_static_manifest: "priv/static/manifest.json", secret_key_base: System.get_env("SECRET_KEY_BASE") # Do not print debug messages in production config :logger, level: :info config :tilex, Tilex.Repo, adapter: Ecto.Adapters.Postgres, url: System.get_env("DATABASE_URL"), pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), ssl: true # ## 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 :tilex, TilexWeb.Endpoint, # ... # url: [host: "example.com", port: 443], # https: [port: 443, # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"), # certfile: System.get_env("SOME_APP_SSL_CERT_PATH")] # # Where those two env variables return an absolute path to # the key and cert in disk or a relative path inside priv, # for example "priv/ssl/server.key". # # We also recommend setting `force_ssl`, ensuring no data is # ever sent via http, always redirecting to https: config :tilex, TilexWeb.Endpoint, force_ssl: [rewrite_on: [:x_forwarded_proto]] # Check `Plug.SSL` for all available options in `force_ssl`. # ## Using releases # # If you are doing OTP releases, you need to instruct Phoenix # to start the server for all endpoints: # # config :phoenix, :serve_endpoints, true # # Alternatively, you can configure exactly which server to # start per endpoint: # # config :tilex, TilexWeb.Endpoint, server: true # # Finally import the config/prod.secret.exs # which should be versioned separately. if System.get_env("ENABLE_BASIC_AUTH") do config :tilex, :basic_auth, realm: "tilex", username: System.get_env("BASIC_AUTH_USERNAME"), password: System.get_env("BASIC_AUTH_PASSWORD") end config :tilex, :page_size, 50 config :tilex, :ga_identifier, System.get_env("GA_IDENTIFIER") config :appsignal, :config, active: true config :tilex, :page_size, 50
33.283951
98
0.724407
79f886e44931906adfc2d9d8f7d5e1937afbc657
1,690
exs
Elixir
mix.exs
CTMoney/phoenix-postgres-react
b51c298fdcef339324a601dd874a82e1e0cc8e6e
[ "MIT" ]
null
null
null
mix.exs
CTMoney/phoenix-postgres-react
b51c298fdcef339324a601dd874a82e1e0cc8e6e
[ "MIT" ]
1
2021-03-09T11:33:04.000Z
2021-03-09T11:33:04.000Z
mix.exs
CTMoney/phoenix_
b51c298fdcef339324a601dd874a82e1e0cc8e6e
[ "MIT" ]
null
null
null
defmodule PhoenixPostgresReact.MixProject do use Mix.Project def project do [ app: :phoenix_postgres_react, version: "0.1.0", elixir: "~> 1.5", 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: {PhoenixPostgresReact.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.4.9"}, {:phoenix_pubsub, "~> 1.1"}, {:phoenix_ecto, "~> 4.0"}, {:ecto_sql, "~> 3.1"}, {:postgrex, ">= 0.0.0"}, {:phoenix_html, "~> 2.11"}, {:phoenix_live_reload, "~> 1.2", only: :dev}, {:gettext, "~> 0.11"}, {:jason, "~> 1.0"}, {:plug_cowboy, "~> 2.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
26.825397
79
0.586982
79f8985fd8707212a2c7b5ebe5e97a456f1e4b5d
648
exs
Elixir
mix.exs
kianmeng/progress_bar
a6285c683b23a46a97870d15652a2988f6631bcc
[ "MIT" ]
null
null
null
mix.exs
kianmeng/progress_bar
a6285c683b23a46a97870d15652a2988f6631bcc
[ "MIT" ]
null
null
null
mix.exs
kianmeng/progress_bar
a6285c683b23a46a97870d15652a2988f6631bcc
[ "MIT" ]
null
null
null
defmodule ProgressBar.Mixfile do use Mix.Project def project do [ app: :progress_bar, version: "2.0.1", elixir: "~> 1.3", description: "Command-line progress bars and spinners.", package: package(), build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, deps: deps() ] end def application do [extra_applications: [:logger]] end def package do [ maintainers: ["Henrik Nyh"], licenses: ["MIT"], links: %{"GitHub" => "https://github.com/henrik/progress_bar"} ] end defp deps do [ {:decimal, "~> 2.0"} ] end end
18.514286
68
0.560185
79f89cd668a41b4195d10575adab39540f3e44fc
2,047
ex
Elixir
lib/ex_unit_notifier.ex
pojiro/ex_unit_notifier
4f6977cfeb45521a4a7e48c0ee82afc8c173b484
[ "MIT" ]
null
null
null
lib/ex_unit_notifier.ex
pojiro/ex_unit_notifier
4f6977cfeb45521a4a7e48c0ee82afc8c173b484
[ "MIT" ]
null
null
null
lib/ex_unit_notifier.ex
pojiro/ex_unit_notifier
4f6977cfeb45521a4a7e48c0ee82afc8c173b484
[ "MIT" ]
null
null
null
defmodule ExUnitNotifier do @moduledoc """ Shows notifications for ExUnit test runs To enable notifications, add `ExUnitNotifier` as a formatter in your `test_helper.exs`: ExUnit.configure formatters: [ExUnit.CLIFormatter, ExUnitNotifier] """ use GenServer alias ExUnitNotifier.Counter alias ExUnitNotifier.MessageFormatter @notifiers [ ExUnitNotifier.Notifiers.TerminalNotifier, ExUnitNotifier.Notifiers.NotifySend, ExUnitNotifier.Notifiers.TerminalTitle ] def init(_opts), do: {:ok, %Counter{}} def handle_cast({:test_finished, %ExUnit.Test{state: nil}}, counter), do: {:noreply, counter |> Counter.add_test()} def handle_cast({:test_finished, %ExUnit.Test{state: {:failed, _}}}, counter), do: {:noreply, counter |> Counter.add_test() |> Counter.add_failed()} def handle_cast({:test_finished, %ExUnit.Test{state: {:excluded, _}}}, counter), do: {:noreply, counter |> Counter.add_test() |> Counter.add_excluded()} def handle_cast({:test_finished, %ExUnit.Test{state: {:skipped, _}}}, counter), do: {:noreply, counter |> Counter.add_test() |> Counter.add_skipped()} def handle_cast({:test_finished, %ExUnit.Test{state: {:invalid, _}}}, counter), do: {:noreply, counter |> Counter.add_test() |> Counter.add_invalid()} def handle_cast({:suite_finished, run_us, load_us}, counter) do apply(notifier(), :notify, [ status(counter), MessageFormatter.format(counter, run_us, load_us), opts() ]) {:noreply, counter} end def handle_cast(_, counter), do: {:noreply, counter} defp status(%Counter{failures: failures, invalid: invalid}) when failures > 0 or invalid > 0, do: :error defp status(_), do: :ok defp opts, do: %{ clear_history: Application.get_env(:ex_unit_notifier, :clear_history, false) } defp notifier, do: Application.get_env(:ex_unit_notifier, :notifier, first_available_notifier()) defp first_available_notifier, do: @notifiers |> Enum.find(fn notifier -> notifier.available? end) end
31.015152
98
0.696629
79f8be9e9cad7c442afd0a43d9f7894af27caf4f
3,066
ex
Elixir
server/lib/workrec/models/event.ex
iii-ishida/workrec
d9937282f1665aa65cf6a25d56a583831017239e
[ "MIT" ]
2
2019-02-25T01:43:21.000Z
2019-07-22T03:57:14.000Z
server/lib/workrec/models/event.ex
iii-ishida/workrec
d9937282f1665aa65cf6a25d56a583831017239e
[ "MIT" ]
2
2022-02-14T03:11:33.000Z
2022-02-27T12:05:43.000Z
server/lib/workrec/models/event.ex
iii-ishida/workrec
d9937282f1665aa65cf6a25d56a583831017239e
[ "MIT" ]
null
null
null
defmodule Workrec.Model.Event do @moduledoc """ event """ @behaviour Workrec.Repository.CloudDatastore.EntityModel defstruct [ :id, :prev_id, :user_id, :task_id, :task_action_id, :action, :title, :time, :created_at ] def kind_name, do: "Event" def for_create_task(user_id, %{title: title}) do now = DateTime.utc_now() id = new_id() task_id = "t-#{id}" %__MODULE__{ id: id, user_id: user_id, task_id: task_id, action: :create_task, title: title, created_at: now } end def for_update_task(prev_event, %{title: title}) do now = DateTime.utc_now() %__MODULE__{ id: new_id(), prev_id: prev_event.id, user_id: prev_event.user_id, task_id: prev_event.task_id, action: :update_task, title: title, created_at: now } end def for_delete_task(prev_event) do now = DateTime.utc_now() %__MODULE__{ id: new_id(), prev_id: prev_event.id, user_id: prev_event.user_id, task_id: prev_event.task_id, action: :delete_task, created_at: now } end def for_start_task(prev_event, params), do: for_change_task_state(prev_event, :start_task, params) def for_pause_task(prev_event, params), do: for_change_task_state(prev_event, :pause_task, params) def for_resume_task(prev_event, params), do: for_change_task_state(prev_event, :resume_task, params) def for_finish_task(prev_event, params), do: for_change_task_state(prev_event, :finish_task, params) def for_unfinish_task(prev_event, params), do: for_change_task_state(prev_event, :unfinish_task, params) defp for_change_task_state(prev_event, action, %{time: time}) do now = DateTime.utc_now() id = new_id() task_action_id = "s-#{id}" %__MODULE__{ id: id, prev_id: prev_event.id, user_id: prev_event.user_id, task_id: prev_event.task_id, task_action_id: task_action_id, action: action, time: time, created_at: now } end defp new_id, do: UUID.uuid4() def from_entity(properties) do %__MODULE__{ id: properties["id"], user_id: properties["user_id"], task_id: properties["task_id"], task_action_id: properties["task_action_id"], action: String.to_existing_atom(properties["action"]), title: properties["title"], time: properties["time"], created_at: properties["created_at"] } end end defimpl Workrec.Repository.CloudDatastore.Entity.Decoder, for: Workrec.Model.Event do alias DsWrapper.Entity alias DsWrapper.Key alias Workrec.Model.Event def to_entity(value) do Entity.new(Key.new(Event.kind_name(), value.id), %{ "id" => value.id, "prev_id" => value.prev_id, "user_id" => value.user_id, "task_id" => value.task_id, "task_action_id" => value.task_action_id, "title" => value.title, "time" => value.time, "action" => Atom.to_string(value.action), "created_at" => value.created_at }) end end
25.131148
106
0.652968
79f8c06a6f7bc5702c0b68952206c1348531dbb8
677
exs
Elixir
priv/repo/migrations/20150626143135_resources.exs
houshuang/survey
948acaf20840af82af1d9af3147acca94cb4fcf8
[ "Apache-2.0" ]
48
2015-06-29T21:20:25.000Z
2021-05-09T04:27:41.000Z
priv/repo/migrations/20150626143135_resources.exs
houshuang/survey
948acaf20840af82af1d9af3147acca94cb4fcf8
[ "Apache-2.0" ]
null
null
null
priv/repo/migrations/20150626143135_resources.exs
houshuang/survey
948acaf20840af82af1d9af3147acca94cb4fcf8
[ "Apache-2.0" ]
15
2015-06-29T21:13:57.000Z
2021-07-27T10:02:40.000Z
defmodule Survey.Repo.Migrations.Resources do use Ecto.Migration def change do create table(:resources) do add :name, :text add :url, :text add :tags, :"text[]" add :description, :text add :generic, :boolean add :user_id, :integer add :comments, :"jsonb[]" add :score, :float add :sig_id, :integer add :inserted_at, :datetime add :updated_at, :datetime end create index(:resources, [:url]) create index(:resources, [:user_id]) create index(:resources, [:tags]) create index(:resources, [:score]) alter table(:users) do add :resources_seen, :"integer[]" end end end
24.178571
45
0.610044
79f8ca73c29d9f87bb14a66a8f2e3c4baa7af206
1,923
ex
Elixir
lib/koans/06_lists.ex
CuriousCurmudgeon/elixir-koans
d085a59c55495623268cd2051d8e53d2ebd88b96
[ "MIT" ]
null
null
null
lib/koans/06_lists.ex
CuriousCurmudgeon/elixir-koans
d085a59c55495623268cd2051d8e53d2ebd88b96
[ "MIT" ]
null
null
null
lib/koans/06_lists.ex
CuriousCurmudgeon/elixir-koans
d085a59c55495623268cd2051d8e53d2ebd88b96
[ "MIT" ]
null
null
null
defmodule Lists do use Koans @intro "Lists" koan "We can see what is ahead" do assert List.first([1, 2, 3]) == 1 end koan "Checking what's trailing is also simple" do assert List.last([1, 2, 3]) == 3 end koan "Lists can store anything you throw at them" do assert [1, 2] ++ [:a, "b"] == [1, 2, :a, "b"] end koan "Things can evolve" do assert [1, 2, 3] -- [3] == [1, 2] end koan "Evolution can have different forms" do assert List.delete([:a, :b, :c], :b) == [:a, :c] end koan "Precision is also valued" do # Zero based assert List.delete_at([:a, :b, :c], 2) == [:a, :b] end koan "Replication is also possible" do assert List.duplicate("life", 3) == ["life", "life", "life"] end koan "Sometimes leveling the playing field is desired" do assert List.flatten([1, [2, 3], 4, [5]]) == [1, 2, 3, 4, 5] end koan "Order can also be specified for new members" do assert List.insert_at([1, 2, 3], 1, 4) == [1, 4, 2, 3] end koan "We can replace things at specified positions" do assert List.replace_at([1, 2, 3], 0, 10) == [10, 2, 3] end koan "When a replacement cannot be found, the list remains the same" do assert List.replace_at([1, 2, 3], 10, 0) == [1, 2, 3] end koan "Order is bound by nature's laws" do assert List.insert_at([1, 2, 3], 10, 4) == [1, 2, 3, 4] end koan "Sometimes it's faster to loop around back" do assert List.insert_at([1, 2, 3], -1, 4) == [1, 2, 3, 4] end koan "We can also transform ourselves completely" do assert List.to_tuple([1, 2, 3]) == {1, 2, 3} end koan "Wrapping other values is a handy option" do assert List.wrap("value") == ["value"] end koan "Wrapping nothing produces a list of nothing" do assert List.wrap(nil) == [] end koan "When there is already a list do not wrap it again" do assert List.wrap(["value"]) == ["value"] end end
25.64
73
0.599584
79f8d5577fbfcee616f41111864172ec6cc51e7f
2,461
exs
Elixir
config/dev.exs
ResiliaDev/Planga
b21d290dd7c2c7fa30571d0a5124d63bd09c0c9e
[ "MIT" ]
37
2018-07-13T14:08:16.000Z
2021-04-09T15:00:22.000Z
config/dev.exs
ResiliaDev/Planga
b21d290dd7c2c7fa30571d0a5124d63bd09c0c9e
[ "MIT" ]
9
2018-07-16T15:24:39.000Z
2021-09-01T14:21:20.000Z
config/dev.exs
ResiliaDev/Planga
b21d290dd7c2c7fa30571d0a5124d63bd09c0c9e
[ "MIT" ]
3
2018-10-05T20:19:25.000Z
2019-12-05T00:30:01.000Z
use Mix.Config # For development, we disable any cache and enable # debugging and code reloading. # # The watchers configuration can be used to run external # watchers to your application. For example, we use it # with brunch.io to recompile .js and .css sources. config :planga, PlangaWeb.Endpoint, http: [port: 4000], debug_errors: true, code_reloader: true, check_origin: false, watchers: [ node: [ "node_modules/brunch/bin/brunch", "watch", "--stdin", cd: Path.expand("../assets", __DIR__) ] ] # ## SSL Support # # In order to use HTTPS in development, a self-signed # certificate can be generated by running the following # command from your terminal: # # openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout priv/server.key -out priv/server.pem # # The `http:` config above can be replaced with: # # https: [port: 4000, keyfile: "priv/server.key", certfile: "priv/server.pem"], # # If desired, both `http:` and `https:` keys can be # configured to run both http and https servers on # different ports. # Watch static and templates for browser reloading. config :planga, PlangaWeb.Endpoint, live_reload: [ patterns: [ ~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$}, ~r{priv/gettext/.*(po)$}, ~r{lib/planga_web/views/.*(ex)$}, ~r{lib/planga_web/templates/.*(eex)$} ] ] # Do not include metadata nor timestamps in development logs config :logger, :console, format: "[$level] $message\n" # Set a higher stacktrace during development. Avoid configuring such # in production as building large stacktraces may be expensive. config :phoenix, :stacktrace_depth, 20 # Configure your database # config :planga, Planga.Repo, # adapter: Ecto.Adapters.Postgres, # username: "postgres", # password: "postgres", # database: "planga_dev", # hostname: "localhost", # pool_size: 10 # config :planga, Planga.Repo, # adapter: Sqlite.Ecto2, # database: "planga_db.sqlite3" config :planga, Planga.Repo, adapter: EctoMnesia.Adapter, # priv: "priv/ecto_mnesia_repo", # host: {:system, :atom, "MNESIA_HOST", Kernel.node()}, host: node(), storage_type: :disc_copies config :planga, :amqp_settings, username: "guest", password: "guest", host: "localhost", port: 5672, ssl_options: :none config :hound, driver: "chrome_driver", app_host: "http://localhost", app_port: 4000
28.952941
170
0.689557
79f9159d8dda6e1c045eba738158f3668c2f453a
16,758
ex
Elixir
apps/nerves_hub_web_core/lib/nerves_hub_web_core/firmwares.ex
nerves-hub/beamware
5c239b7125a82d8fcb2b84ff1ad22d3bb0af01eb
[ "Apache-2.0" ]
null
null
null
apps/nerves_hub_web_core/lib/nerves_hub_web_core/firmwares.ex
nerves-hub/beamware
5c239b7125a82d8fcb2b84ff1ad22d3bb0af01eb
[ "Apache-2.0" ]
null
null
null
apps/nerves_hub_web_core/lib/nerves_hub_web_core/firmwares.ex
nerves-hub/beamware
5c239b7125a82d8fcb2b84ff1ad22d3bb0af01eb
[ "Apache-2.0" ]
null
null
null
defmodule NervesHubWebCore.Firmwares do import Ecto.Query alias Ecto.Changeset alias NervesHubWebCore.Accounts alias NervesHubWebCore.Accounts.{OrgKey, Org} alias NervesHubWebCore.Firmwares.{Firmware, FirmwareMetadata, FirmwareDelta, FirmwareTransfer} alias NervesHubWebCore.Products alias NervesHubWebCore.Products.Product alias NervesHubWebCore.Repo require Logger @type upload_file_2 :: (filepath :: String.t(), filename :: String.t() -> :ok | {:error, any()}) @uploader Application.fetch_env!(:nerves_hub_web_core, :firmware_upload) @spec get_firmwares_by_product(integer()) :: [Firmware.t()] def get_firmwares_by_product(product_id) do from( f in Firmware, where: f.product_id == ^product_id, order_by: [desc: :version, desc: :inserted_at] ) |> Firmware.with_product() |> Repo.all() end @spec get_firmware(Org.t(), integer()) :: {:ok, Firmware.t()} | {:error, :not_found} def get_firmware(%Org{id: org_id}, id) do from( f in Firmware, where: f.id == ^id, join: p in assoc(f, :product), where: p.org_id == ^org_id ) |> Firmware.with_product() |> Repo.one() |> case do nil -> {:error, :not_found} firmware -> {:ok, firmware} end end def get_firmware!(firmware_id), do: Repo.get!(Firmware, firmware_id) @spec get_firmware_by_org_id(non_neg_integer()) :: [Firmware.t()] def get_firmware_by_org_id(org_id) do q = from( f in Firmware, join: p in assoc(f, :product), where: p.org_id == ^org_id ) Repo.all(q) end @spec get_firmware_by_product_and_version(Org.t(), String.t(), String.t()) :: {:ok, Firmware.t()} | {:error, :not_found} def get_firmware_by_product_and_version(%Org{} = org, product, version) do Firmware |> Repo.get_by(org_id: org.id, product: product, version: version) |> case do nil -> {:error, :not_found} firmware -> {:ok, firmware} end end @spec get_firmware_by_uuid(String.t() | nil) :: [Firmware.t()] def get_firmware_by_uuid(nil), do: [] def get_firmware_by_uuid(uuid) do from( f in Firmware, where: f.uuid == ^uuid ) |> Repo.all() end @spec get_firmware_by_product_and_uuid(Product.t(), String.t()) :: {:ok, Firmware.t()} | {:error, :not_found} def get_firmware_by_product_and_uuid(%Product{id: product_id}, uuid) do from( f in Firmware, where: f.uuid == ^uuid, join: p in assoc(f, :product), preload: [product: p], where: p.id == ^product_id ) |> Repo.one() |> case do nil -> {:error, :not_found} firmware -> {:ok, firmware} end end @spec create_firmware( org :: Org.t(), filepath :: Path.t(), params :: map(), opts :: [{:upload_file_2, upload_file_2()}] ) :: {:ok, Firmware.t()} | {:error, Changeset.t() | :no_public_keys | :invalid_signature | any} def create_firmware(org, filepath, params \\ %{}, opts \\ []) do upload_file_2 = opts[:upload_file_2] || (&@uploader.upload_file/2) Repo.transaction( fn -> with {:ok, params} <- build_firmware_params(org, filepath, params), params <- set_ttl(org, params), {:ok, firmware} <- insert_firmware(params), :ok <- upload_file_2.(filepath, firmware.upload_metadata) do firmware else {:error, error} -> Logger.error(fn -> "Error while publishing firmware: #{inspect(error)}" end) Repo.rollback(error) end end, timeout: 30_000 ) end def delete_firmware(%Firmware{} = firmware) do do_delete_firmware = fn -> firmware |> Firmware.delete_changeset(%{}) |> Repo.delete() end do_delete_from_s3 = fn -> firmware.upload_metadata |> NervesHubWebCore.Workers.DeleteFirmware.new() |> Oban.insert() end Repo.transaction(fn -> with {:ok, firmware} <- do_delete_firmware.(), {:ok, _} <- do_delete_from_s3.() do {:ok, firmware} else {:error, error} -> Repo.rollback(error) end end) end @spec verify_signature(String.t(), [OrgKey.t()]) :: {:ok, OrgKey.t()} | {:error, :invalid_signature} | {:error, :no_public_keys} def verify_signature(_filepath, []), do: {:error, :no_public_keys} def verify_signature(filepath, keys) when is_binary(filepath) do keys |> Enum.find(fn %{key: key} -> case System.cmd("fwup", ["--verify", "--public-key", key, "-i", filepath]) do {_, 0} -> true _ -> false end end) |> case do %OrgKey{} = key -> {:ok, key} nil -> {:error, :invalid_signature} end end def update_firmware_ttl(nil), do: :ok def update_firmware_ttl(firmware_id) do q = from(f in NervesHubWebCore.Firmwares.Firmware, left_join: d in NervesHubWebCore.Deployments.Deployment, on: d.firmware_id == f.id, where: f.id == ^firmware_id and not is_nil(d.firmware_id), limit: 1 ) case Repo.one(q) do # Firmware has no associations. Set ttl. nil -> case NervesHubWebCore.Repo.get(Firmware, firmware_id) do %Firmware{ttl_until: nil, ttl: ttl} = firmware -> ttl_until = DateTime.utc_now() |> Timex.shift(seconds: ttl) firmware |> Firmware.update_changeset(%{ttl_until: ttl_until}) |> Repo.update() :set _ -> :noop end # Firmware has associations and no ttl has been set. %Firmware{ttl_until: nil} -> :noop # Firmware has associations and is marked for ttl. Unset ttl. %Firmware{} = firmware -> firmware |> Firmware.update_changeset(%{ttl_until: nil}) |> Repo.update() :unset end end def get_firmware_by_expired_ttl() do from( f in Firmware, where: f.ttl_until < ^DateTime.utc_now() ) |> Repo.all() end def metadata_from_conn(%Plug.Conn{} = conn) do params = %{ uuid: get_metadata_req_header(conn, "uuid"), architecture: get_metadata_req_header(conn, "architecture"), platform: get_metadata_req_header(conn, "platform"), product: get_metadata_req_header(conn, "product"), version: get_metadata_req_header(conn, "version"), author: get_metadata_req_header(conn, "author"), description: get_metadata_req_header(conn, "description"), fwup_version: get_metadata_req_header(conn, "fwup-version"), vcs_identifier: get_metadata_req_header(conn, "vcs-identifier"), misc: get_metadata_req_header(conn, "misc") } metadata_or_firmware(params) end @doc """ Returns metadata for a Firmware struct """ @spec metadata_from_firmware(Firmware.t()) :: {:ok, FirmwareMetadata.metadata()} def metadata_from_firmware(%Firmware{} = firmware) do firmware = Repo.preload(firmware, [:product]) metadata = %{ architecture: firmware.architecture, author: firmware.author, description: firmware.description, misc: firmware.misc, platform: firmware.platform, product: firmware.product.name, uuid: firmware.uuid, vcs_identifier: firmware.vcs_identifier, version: firmware.version } {:ok, metadata} end @doc """ Same as `metadata_from_firmware/1` but takes a file path instead of a firmware struct """ @spec metadata_from_fwup(Path.t()) :: {:ok, FirmwareMetadata.metadata()} | {:error, any()} def metadata_from_fwup(firmware_file) do with {:ok, fwup_metadata} <- get_fwup_metadata(firmware_file), {:ok, uuid} <- fetch_fwup_metadata_value(fwup_metadata, "meta-uuid"), {:ok, architecture} <- fetch_fwup_metadata_value(fwup_metadata, "meta-architecture"), {:ok, platform} <- fetch_fwup_metadata_value(fwup_metadata, "meta-platform"), {:ok, product} <- fetch_fwup_metadata_value(fwup_metadata, "meta-product"), {:ok, version} <- fetch_fwup_metadata_value(fwup_metadata, "meta-version"), author <- get_fwup_metadata_value(fwup_metadata, "meta-author"), description <- get_fwup_metadata_value(fwup_metadata, "meta-description"), misc <- get_fwup_metadata_value(fwup_metadata, "meta-misc"), vcs_identifier <- get_fwup_metadata_value(fwup_metadata, "meta-vcs-identifier") do metadata = %{ architecture: architecture, author: author, description: description, misc: misc, platform: platform, product: product, uuid: uuid, vcs_identifier: vcs_identifier, version: version } {:ok, metadata} end end def metadata_from_device(metadata) do params = %{ uuid: Map.get(metadata, "nerves_fw_uuid"), architecture: Map.get(metadata, "nerves_fw_architecture"), platform: Map.get(metadata, "nerves_fw_platform"), product: Map.get(metadata, "nerves_fw_product"), version: Map.get(metadata, "nerves_fw_version"), author: Map.get(metadata, "nerves_fw_author"), description: Map.get(metadata, "nerves_fw_description"), fwup_version: Map.get(metadata, "fwup_version"), vcs_identifier: Map.get(metadata, "nerves_fw_vcs_identifier"), misc: Map.get(metadata, "nerves_fw_misc") } metadata_or_firmware(params) end def create_firmware_transfer(params) do %FirmwareTransfer{} |> FirmwareTransfer.changeset(params) |> Repo.insert() end def get_firmware_transfers_by_org_id_between_dates(org_id, from_datetime, to_datetime) do q = from( ft in FirmwareTransfer, where: ft.org_id == ^org_id and ft.timestamp >= ^from_datetime and ft.timestamp <= ^to_datetime ) Repo.all(q) end @spec get_firmware_delta(integer()) :: {:ok, FirmwareDelta.t()} | {:error, :not_found} def get_firmware_delta(firmware_delta_id) do case Repo.get(FirmwareDelta, firmware_delta_id) do nil -> {:error, :not_found} firmware_delta -> {:ok, firmware_delta} end end @spec get_firmware_delta_by_source_and_target(Firmware.t(), Firmware.t()) :: {:ok, FirmwareDelta.t()} | {:error, :not_found} def get_firmware_delta_by_source_and_target(%Firmware{id: source_id}, %Firmware{id: target_id}) do get_firmware_delta_by_source_and_target(source_id, target_id) end @spec get_firmware_delta_by_source_and_target(integer(), integer()) :: {:ok, FirmwareDelta.t()} | {:error, :not_found} def get_firmware_delta_by_source_and_target(source_id, target_id) do q = from( fd in FirmwareDelta, where: fd.source_id == ^source_id and fd.target_id == ^target_id ) case Repo.one(q) do nil -> {:error, :not_found} firmware_delta -> {:ok, firmware_delta} end end @spec get_firmware_url(Firmware.t() | FirmwareDelta.t()) :: {:ok, String.t()} | {:error, :failure} def get_firmware_url(fw_or_delta) do @uploader.download_file(fw_or_delta) end @spec create_firmware_delta(Firmware.t(), Firmware.t()) :: {:ok, FirmwareDelta.t()} | {:error, Changeset.t()} def create_firmware_delta(source_firmware, target_firmware) do %Firmware{org: org} = source_firmware |> Repo.preload(:org) {:ok, source_url} = @uploader.download_file(source_firmware) {:ok, target_url} = @uploader.download_file(target_firmware) firmware_delta_path = delta_updater().create_firmware_delta_file(source_url, target_url) firmware_delta_filename = Path.basename(firmware_delta_path) Repo.transaction( fn -> with upload_metadata <- @uploader.metadata(org.id, firmware_delta_filename), {:ok, firmware_delta} <- insert_firmware_delta(%{ source_id: source_firmware.id, target_id: target_firmware.id, upload_metadata: upload_metadata }), {:ok, firmware_delta} <- get_firmware_delta(firmware_delta.id), :ok <- @uploader.upload_file(firmware_delta_path, upload_metadata), :ok <- delta_updater().cleanup_firmware_delta_files(firmware_delta_path) do firmware_delta else {:error, error} -> Repo.rollback(error) end end, timeout: 30_000 ) end # Private functions def insert_firmware_delta(params) do %FirmwareDelta{} |> FirmwareDelta.changeset(params) |> Repo.insert() end defp insert_firmware(params) do %Firmware{} |> Firmware.create_changeset(params) |> Repo.insert() end @spec build_firmware_params(Org.t(), Path.t(), map()) :: {:ok, map()} | {:error, any()} defp build_firmware_params(%{id: org_id} = org, filepath, params) do org = NervesHubWebCore.Repo.preload(org, :org_keys) with {:ok, %{id: org_key_id}} <- verify_signature(filepath, org.org_keys), {:ok, metadata} <- metadata_from_fwup(filepath) do filename = metadata.uuid <> ".fw" params = resolve_product(%{ architecture: metadata.architecture, author: metadata.author, description: metadata.description, filename: filename, filepath: filepath, misc: metadata.misc, org_id: org_id, org_key_id: org_key_id, delta_updatable: delta_updater().delta_updatable?(filepath), platform: metadata.platform, product_name: metadata.product, upload_metadata: @uploader.metadata(org_id, filename), size: :filelib.file_size(filepath), ttl: Map.get(params, :ttl), uuid: metadata.uuid, vcs_identifier: metadata.vcs_identifier, version: metadata.version }) {:ok, params} end end defp set_ttl(%{id: org_id}, params) do ttl = case Map.get(params, :ttl) do ttl when ttl == nil or ttl == "" -> org_id |> Accounts.get_org_limit_by_org_id() |> Map.get(:firmware_ttl_seconds_default) ttl when is_binary(ttl) -> String.to_integer(ttl) ttl -> ttl end ttl_until = DateTime.utc_now() |> Timex.shift(seconds: ttl) params |> Map.put(:ttl, ttl) |> Map.put(:ttl_until, ttl_until) end defp resolve_product(params) do with {:ok, product} <- Products.get_product_by_org_id_and_name(params.org_id, params.product_name) do Map.put(params, :product_id, product.id) else _ -> params end end @spec metadata_or_firmware(map()) :: {:ok, FirmwareMetadata.t() | nil} def metadata_or_firmware(metadata) do if FirmwareMetadata.changeset(%FirmwareMetadata{}, metadata).valid? do {:ok, metadata} else case get_firmware_by_uuid(metadata[:uuid]) do [firmware | _] -> metadata_from_firmware(firmware) [] -> {:ok, nil} end end end @typep metadata_string() :: String.t() @typep metadata_key() :: String.t() @typep metadata_value() :: String.t() | nil @spec get_fwup_metadata(Path.t()) :: {:ok, metadata_string()} | {:error, String.t()} defp get_fwup_metadata(filepath) do case System.cmd("fwup", ["-m", "-i", filepath]) do {metadata, 0} -> {:ok, metadata} {error, _} -> {:error, error} end end @spec fetch_fwup_metadata_value(metadata_string(), metadata_key()) :: {:ok, metadata_value()} | {:error, {metadata_key(), :not_found}} defp fetch_fwup_metadata_value(metadata, key) when is_binary(key) do {:ok, regex} = "#{key}=\"(?<value>[^\n]+)\"" |> Regex.compile() case Regex.named_captures(regex, metadata) do %{"value" => value} -> {:ok, value} _ -> {:error, {key, :not_found}} end end @spec get_fwup_metadata_value(metadata_string(), metadata_key()) :: metadata_value() defp get_fwup_metadata_value(metadata, key) when is_binary(key) do case fetch_fwup_metadata_value(metadata, key) do {:ok, metadata_item} -> metadata_item {:error, {_, :not_found}} -> nil end end defp get_metadata_req_header(conn, header) do case Plug.Conn.get_req_header(conn, "x-nerveshub-#{header}") do [] -> nil ["" | _] -> nil [value | _] -> value end end defp delta_updater() do Application.get_env( :nerves_hub_web_core, :delta_updater, NervesHubWebCore.Firmwares.DeltaUpdater.Default ) end end
30.249097
100
0.620897
79f9323df059503bef2054c920cd54493b67ff6d
720
exs
Elixir
hamming/hamming.exs
nlhuykhang/elixir-exercism
0462661cc411cb28b4bf800639b16684480a06a7
[ "MIT" ]
null
null
null
hamming/hamming.exs
nlhuykhang/elixir-exercism
0462661cc411cb28b4bf800639b16684480a06a7
[ "MIT" ]
null
null
null
hamming/hamming.exs
nlhuykhang/elixir-exercism
0462661cc411cb28b4bf800639b16684480a06a7
[ "MIT" ]
null
null
null
defmodule Hamming do @doc """ Returns number of differences between two strands of DNA, known as the Hamming Distance. ## Examples iex> Hamming.hamming_distance('AAGTCATA', 'TAGCGATC') {:ok, 4} """ @spec hamming_distance([char], [char]) :: non_neg_integer def hamming_distance(strand1, strand2) do cond do length(strand1) == length(strand2) -> epic(strand1, strand2) true -> {:error, "Lists must be the same length"} end end defp epic(s1, s2) do epic(s1, s2, 0) end defp epic([], [], count) do {:ok, count} end defp epic([h1 | t1], [h2 | t2], count) do cond do h1 == h2 -> epic(t1, t2, count) true -> epic(t1, t2, count + 1) end end end
21.818182
90
0.608333
79f94191a9c4280194e6f3f7abf6eb2fb02ef7ad
637
exs
Elixir
elixir/hello-world/hello_world.exs
esambo/exercism_solutions
520d9a5c28793c6fab2cb963b8c6de6c3404ac0b
[ "MIT" ]
2
2017-05-19T18:31:38.000Z
2017-05-19T18:31:41.000Z
elixir/hello-world/hello_world.exs
esambo/exorcism_solutions
520d9a5c28793c6fab2cb963b8c6de6c3404ac0b
[ "MIT" ]
null
null
null
elixir/hello-world/hello_world.exs
esambo/exorcism_solutions
520d9a5c28793c6fab2cb963b8c6de6c3404ac0b
[ "MIT" ]
null
null
null
defmodule HelloWorld do @moduledoc """ Elixir counts the number of arguments as part of the function name. For instance; def hello() do end would be a completely different function from def hello(name) do end Can you find a way to make all the tests pass with just one function? Hint: look into argument defaults here: http://elixir-lang.org/getting-started/modules.html#default-arguments """ @doc """ Greets the user by name, or by saying "Hello, World!" if no name is given. """ @spec hello(String.t) :: String.t def hello(name \\ "World") do "Hello, #{name}!" end end
21.233333
71
0.66405
79f9425e028a9237025f37791159d1294460d942
878
ex
Elixir
lib/xeroxero/core_api/models/contacts/contact/balances.ex
scottmessinger/elixero
4e62c4d80d221639ba2347a563002511e8d4a6c6
[ "MIT" ]
1
2021-12-01T18:21:31.000Z
2021-12-01T18:21:31.000Z
lib/xeroxero/core_api/models/contacts/contact/balances.ex
scottmessinger/elixero
4e62c4d80d221639ba2347a563002511e8d4a6c6
[ "MIT" ]
null
null
null
lib/xeroxero/core_api/models/contacts/contact/balances.ex
scottmessinger/elixero
4e62c4d80d221639ba2347a563002511e8d4a6c6
[ "MIT" ]
1
2021-10-01T12:09:46.000Z
2021-10-01T12:09:46.000Z
defmodule XeroXero.CoreApi.Models.Contacts.Contact.Balances do use Ecto.Schema import Ecto.Changeset @derive {Jason.Encoder, except: [:__meta__, :id]} schema "balances" do embeds_one :AccountsReceivable, XeroXero.CoreApi.Models.Contacts.Contact.Balances.Balance embeds_one :AccountsPayable, XeroXero.CoreApi.Models.Contacts.Contact.Balances.Balance embeds_many :ValidationErrors, XeroXero.CoreApi.Models.Common.Error embeds_many :Warnings, XeroXero.CoreApi.Models.Common.Warning field :StatusAttributeString, :string end def changeset(struct, data) do struct |> cast(data, [:StatusAttributeString]) |> cast_embed(:AccountsReceivable) |> cast_embed(:AccountsPayable) |> cast_embed(:ValidationErrors) |> cast_embed(:Warnings) end end
36.583333
98
0.68451
79f9488f3c3277b518066e4cb1876865bb74f1a3
14,051
ex
Elixir
clients/ad_exchange_buyer/lib/google_api/ad_exchange_buyer/v14/api/proposals.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/ad_exchange_buyer/lib/google_api/ad_exchange_buyer/v14/api/proposals.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/ad_exchange_buyer/lib/google_api/ad_exchange_buyer/v14/api/proposals.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
1
2018-07-28T20:50:50.000Z
2018-07-28T20:50:50.000Z
# 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.AdExchangeBuyer.V14.Api.Proposals do @moduledoc """ API calls for all endpoints tagged `Proposals`. """ alias GoogleApi.AdExchangeBuyer.V14.Connection import GoogleApi.AdExchangeBuyer.V14.RequestBuilder @doc """ Get a proposal given its id ## Parameters - connection (GoogleApi.AdExchangeBuyer.V14.Connection): Connection to server - proposal_id (String): Id of the proposal to retrieve. - opts (KeywordList): [optional] Optional parameters - :alt (String): Data format for the response. - :fields (String): Selector specifying which fields to include in a partial response. - :key (String): 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): OAuth 2.0 token for the current user. - :pretty_print (Boolean): Returns response with indentations and line breaks. - :quota_user (String): 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. Overrides userIp if both are provided. - :user_ip (String): IP address of the site where the request originates. Use this if you want to enforce per-user limits. ## Returns {:ok, %GoogleApi.AdExchangeBuyer.V14.Model.Proposal{}} on success {:error, info} on failure """ @spec adexchangebuyer_proposals_get(Tesla.Env.client, String.t, keyword()) :: {:ok, GoogleApi.AdExchangeBuyer.V14.Model.Proposal.t} | {:error, Tesla.Env.t} def adexchangebuyer_proposals_get(connection, proposal_id, opts \\ []) do optional_params = %{ :"alt" => :query, :"fields" => :query, :"key" => :query, :"oauth_token" => :query, :"prettyPrint" => :query, :"quotaUser" => :query, :"userIp" => :query } %{} |> method(:get) |> url("/proposals/{proposalId}", %{ "proposalId" => URI.encode_www_form(proposal_id) }) |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%GoogleApi.AdExchangeBuyer.V14.Model.Proposal{}) end @doc """ Create the given list of proposals ## Parameters - connection (GoogleApi.AdExchangeBuyer.V14.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :alt (String): Data format for the response. - :fields (String): Selector specifying which fields to include in a partial response. - :key (String): 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): OAuth 2.0 token for the current user. - :pretty_print (Boolean): Returns response with indentations and line breaks. - :quota_user (String): 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. Overrides userIp if both are provided. - :user_ip (String): IP address of the site where the request originates. Use this if you want to enforce per-user limits. - :body (CreateOrdersRequest): ## Returns {:ok, %GoogleApi.AdExchangeBuyer.V14.Model.CreateOrdersResponse{}} on success {:error, info} on failure """ @spec adexchangebuyer_proposals_insert(Tesla.Env.client, keyword()) :: {:ok, GoogleApi.AdExchangeBuyer.V14.Model.CreateOrdersResponse.t} | {:error, Tesla.Env.t} def adexchangebuyer_proposals_insert(connection, opts \\ []) do optional_params = %{ :"alt" => :query, :"fields" => :query, :"key" => :query, :"oauth_token" => :query, :"prettyPrint" => :query, :"quotaUser" => :query, :"userIp" => :query, :"body" => :body } %{} |> method(:post) |> url("/proposals/insert") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%GoogleApi.AdExchangeBuyer.V14.Model.CreateOrdersResponse{}) end @doc """ Update the given proposal. This method supports patch semantics. ## Parameters - connection (GoogleApi.AdExchangeBuyer.V14.Connection): Connection to server - proposal_id (String): The proposal id to update. - revision_number (String): The last known revision number to update. If the head revision in the marketplace database has since changed, an error will be thrown. The caller should then fetch the latest proposal at head revision and retry the update at that revision. - update_action (String): The proposed action to take on the proposal. This field is required and it must be set when updating a proposal. - opts (KeywordList): [optional] Optional parameters - :alt (String): Data format for the response. - :fields (String): Selector specifying which fields to include in a partial response. - :key (String): 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): OAuth 2.0 token for the current user. - :pretty_print (Boolean): Returns response with indentations and line breaks. - :quota_user (String): 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. Overrides userIp if both are provided. - :user_ip (String): IP address of the site where the request originates. Use this if you want to enforce per-user limits. - :body (Proposal): ## Returns {:ok, %GoogleApi.AdExchangeBuyer.V14.Model.Proposal{}} on success {:error, info} on failure """ @spec adexchangebuyer_proposals_patch(Tesla.Env.client, String.t, String.t, String.t, keyword()) :: {:ok, GoogleApi.AdExchangeBuyer.V14.Model.Proposal.t} | {:error, Tesla.Env.t} def adexchangebuyer_proposals_patch(connection, proposal_id, revision_number, update_action, opts \\ []) do optional_params = %{ :"alt" => :query, :"fields" => :query, :"key" => :query, :"oauth_token" => :query, :"prettyPrint" => :query, :"quotaUser" => :query, :"userIp" => :query, :"body" => :body } %{} |> method(:patch) |> url("/proposals/{proposalId}/{revisionNumber}/{updateAction}", %{ "proposalId" => URI.encode_www_form(proposal_id), "revisionNumber" => URI.encode_www_form(revision_number), "updateAction" => URI.encode_www_form(update_action) }) |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%GoogleApi.AdExchangeBuyer.V14.Model.Proposal{}) end @doc """ Search for proposals using pql query ## Parameters - connection (GoogleApi.AdExchangeBuyer.V14.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :alt (String): Data format for the response. - :fields (String): Selector specifying which fields to include in a partial response. - :key (String): 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): OAuth 2.0 token for the current user. - :pretty_print (Boolean): Returns response with indentations and line breaks. - :quota_user (String): 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. Overrides userIp if both are provided. - :user_ip (String): IP address of the site where the request originates. Use this if you want to enforce per-user limits. - :pql_query (String): Query string to retrieve specific proposals. ## Returns {:ok, %GoogleApi.AdExchangeBuyer.V14.Model.GetOrdersResponse{}} on success {:error, info} on failure """ @spec adexchangebuyer_proposals_search(Tesla.Env.client, keyword()) :: {:ok, GoogleApi.AdExchangeBuyer.V14.Model.GetOrdersResponse.t} | {:error, Tesla.Env.t} def adexchangebuyer_proposals_search(connection, opts \\ []) do optional_params = %{ :"alt" => :query, :"fields" => :query, :"key" => :query, :"oauth_token" => :query, :"prettyPrint" => :query, :"quotaUser" => :query, :"userIp" => :query, :"pqlQuery" => :query } %{} |> method(:get) |> url("/proposals/search") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%GoogleApi.AdExchangeBuyer.V14.Model.GetOrdersResponse{}) end @doc """ Update the given proposal to indicate that setup has been completed. ## Parameters - connection (GoogleApi.AdExchangeBuyer.V14.Connection): Connection to server - proposal_id (String): The proposal id for which the setup is complete - opts (KeywordList): [optional] Optional parameters - :alt (String): Data format for the response. - :fields (String): Selector specifying which fields to include in a partial response. - :key (String): 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): OAuth 2.0 token for the current user. - :pretty_print (Boolean): Returns response with indentations and line breaks. - :quota_user (String): 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. Overrides userIp if both are provided. - :user_ip (String): IP address of the site where the request originates. Use this if you want to enforce per-user limits. ## Returns {:ok, %{}} on success {:error, info} on failure """ @spec adexchangebuyer_proposals_setupcomplete(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def adexchangebuyer_proposals_setupcomplete(connection, proposal_id, opts \\ []) do optional_params = %{ :"alt" => :query, :"fields" => :query, :"key" => :query, :"oauth_token" => :query, :"prettyPrint" => :query, :"quotaUser" => :query, :"userIp" => :query } %{} |> method(:post) |> url("/proposals/{proposalId}/setupcomplete", %{ "proposalId" => URI.encode_www_form(proposal_id) }) |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(false) end @doc """ Update the given proposal ## Parameters - connection (GoogleApi.AdExchangeBuyer.V14.Connection): Connection to server - proposal_id (String): The proposal id to update. - revision_number (String): The last known revision number to update. If the head revision in the marketplace database has since changed, an error will be thrown. The caller should then fetch the latest proposal at head revision and retry the update at that revision. - update_action (String): The proposed action to take on the proposal. This field is required and it must be set when updating a proposal. - opts (KeywordList): [optional] Optional parameters - :alt (String): Data format for the response. - :fields (String): Selector specifying which fields to include in a partial response. - :key (String): 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): OAuth 2.0 token for the current user. - :pretty_print (Boolean): Returns response with indentations and line breaks. - :quota_user (String): 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. Overrides userIp if both are provided. - :user_ip (String): IP address of the site where the request originates. Use this if you want to enforce per-user limits. - :body (Proposal): ## Returns {:ok, %GoogleApi.AdExchangeBuyer.V14.Model.Proposal{}} on success {:error, info} on failure """ @spec adexchangebuyer_proposals_update(Tesla.Env.client, String.t, String.t, String.t, keyword()) :: {:ok, GoogleApi.AdExchangeBuyer.V14.Model.Proposal.t} | {:error, Tesla.Env.t} def adexchangebuyer_proposals_update(connection, proposal_id, revision_number, update_action, opts \\ []) do optional_params = %{ :"alt" => :query, :"fields" => :query, :"key" => :query, :"oauth_token" => :query, :"prettyPrint" => :query, :"quotaUser" => :query, :"userIp" => :query, :"body" => :body } %{} |> method(:put) |> url("/proposals/{proposalId}/{revisionNumber}/{updateAction}", %{ "proposalId" => URI.encode_www_form(proposal_id), "revisionNumber" => URI.encode_www_form(revision_number), "updateAction" => URI.encode_www_form(update_action) }) |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%GoogleApi.AdExchangeBuyer.V14.Model.Proposal{}) end end
47.309764
269
0.693047
79f9537936db6978f7254e3852431786f27f9f0a
311
exs
Elixir
priv/repo/migrations/20190410150812_create_high_fives.exs
justmendes/corker
b7a6d7cbae47d30816bb99b8fe8576e9a0d5722d
[ "0BSD" ]
5
2019-05-24T17:00:42.000Z
2019-05-27T13:50:56.000Z
priv/repo/migrations/20190410150812_create_high_fives.exs
justmendes/corker
b7a6d7cbae47d30816bb99b8fe8576e9a0d5722d
[ "0BSD" ]
17
2019-05-27T08:59:36.000Z
2020-02-17T06:45:27.000Z
priv/repo/migrations/20190410150812_create_high_fives.exs
justmendes/corker
b7a6d7cbae47d30816bb99b8fe8576e9a0d5722d
[ "0BSD" ]
1
2019-08-27T14:27:06.000Z
2019-08-27T14:27:06.000Z
defmodule Corker.Repo.Migrations.CreateHighFives do use Ecto.Migration def change do create table(:high_fives) do add :sender_id, references(:users), null: false add :receiver_id, references(:users), null: false add :reason, :string, null: false timestamps() end end end
22.214286
55
0.684887
79f9562b08e13f010ed3de469b00a525e16a3c6b
854
ex
Elixir
lib/oli_web/live/curriculum/activity_delta.ex
malav2110/oli-torus
8af64e762a7c8a2058bd27a7ab8e96539ffc055f
[ "MIT" ]
45
2020-04-17T15:40:27.000Z
2022-03-25T00:13:30.000Z
lib/oli_web/live/curriculum/activity_delta.ex
malav2110/oli-torus
8af64e762a7c8a2058bd27a7ab8e96539ffc055f
[ "MIT" ]
944
2020-02-13T02:37:01.000Z
2022-03-31T17:50:07.000Z
lib/oli_web/live/curriculum/activity_delta.ex
malav2110/oli-torus
8af64e762a7c8a2058bd27a7ab8e96539ffc055f
[ "MIT" ]
23
2020-07-28T03:36:13.000Z
2022-03-17T14:29:02.000Z
defmodule OliWeb.Curriculum.ActivityDelta do alias Oli.Resources defstruct current: nil, deleted: [], added: [] def new(current_page, old_page) do current = get_activities_from_page(current_page) |> MapSet.new() previous_activities = get_activities_from_page(old_page) |> MapSet.new() deleted = MapSet.difference(previous_activities, current) |> MapSet.to_list() added = MapSet.difference(current, previous_activities) |> MapSet.to_list() {:ok, %__MODULE__{current: current, deleted: deleted, added: added}} end def have_activities_changed?(%__MODULE__{} = struct) do length(struct.added) > 0 or length(struct.deleted) > 0 end # extract all the activity ids referenced from a page model defp get_activities_from_page(revision) do Resources.activity_references(revision) end end
31.62963
81
0.723653
79f96c9e991acb636a4700e35fde7e16bf9d926f
532
exs
Elixir
config/prod.secret.exs
licaonfee/phoenix_gitlab_monitor
1b7dd437018d42a2b7b9a1643e6767a48f312eee
[ "MIT" ]
12
2018-11-04T03:39:34.000Z
2020-04-29T19:30:58.000Z
config/prod.secret.exs
licaonfee/phoenix_gitlab_monitor
1b7dd437018d42a2b7b9a1643e6767a48f312eee
[ "MIT" ]
16
2018-11-07T01:05:01.000Z
2021-05-07T21:32:07.000Z
config/prod.secret.exs
licaonfee/phoenix_gitlab_monitor
1b7dd437018d42a2b7b9a1643e6767a48f312eee
[ "MIT" ]
3
2019-08-27T20:29:00.000Z
2020-05-25T20:36:12.000Z
use Mix.Config # In this file, we keep production configuration that # you'll likely want to automate and keep away from # your version control system. # # You should document the content of this # file or create a script for recreating it, since it's # kept out of version control and might be hard to recover # or recreate for your teammates (or yourself later on). config :monitor, MonitorWeb.Endpoint, secret_key_base: System.get_env("SECRET_KEY_BASE") || :crypto.strong_rand_bytes(64) |> Base.encode64 |> binary_part(0, 64)
40.923077
124
0.766917
79f97acfbd3a4e4935f7ebbba596e01f36b387bc
1,942
ex
Elixir
lib/annotations.ex
openapi-ro/annotations
a141164235d68d20b52ef199e342b5b9bf130acb
[ "WTFPL" ]
null
null
null
lib/annotations.ex
openapi-ro/annotations
a141164235d68d20b52ef199e342b5b9bf130acb
[ "WTFPL" ]
null
null
null
lib/annotations.ex
openapi-ro/annotations
a141164235d68d20b52ef199e342b5b9bf130acb
[ "WTFPL" ]
null
null
null
defmodule Annotations do alias Annotations.AnnotatedString @moduledoc """ `Annotations` is a package for augmenting plain strings with information on ranges of that `String`. Let's create an `AnnotatedString`: iex(2)> AnnotatedString.new("first second third. fourth fifth sixth.") %Annotations.AnnotatedString{annotations: [], str: "first second third. fourth fifth sixth."} `Annotation`s store information inȘ * `tags` * the `info` member ## Example Let's tag each word, sentence and punctuation using `Regex` expressions: iex> alias Annotations.{AnnotatedString,Annotations} iex> ann_str = AnnotatedString.new("first second third. fourth fifth sixth.") iex> ann_str = ann_str |> AnnotatedString.tag_all(~r/[.]/ , :punctuation) \ ...> |> AnnotatedString.tag_all(~r/[^.[:space:]]+[^.]+/ , :sentence) \ ...> |> AnnotatedString.tag_all(~r/[[:alnum:]]+/ , :word) %Annotations.AnnotatedString{annotations: [%Annotations.Annotation{from: 18, info: nil, tags: [:punctuation], to: 19}, %Annotations.Annotation{from: 38, info: nil, tags: [:punctuation], to: 39}, %Annotations.Annotation{from: 0, info: nil, tags: [:sentence], to: 18}, %Annotations.Annotation{from: 20, info: nil, tags: [:sentence], to: 38}, %Annotations.Annotation{from: 0, info: nil, tags: [:word], to: 5}, %Annotations.Annotation{from: 6, info: nil, tags: [:word], to: 12}, %Annotations.Annotation{from: 13, info: nil, tags: [:word], to: 18}, %Annotations.Annotation{from: 20, info: nil, tags: [:word], to: 26}, %Annotations.Annotation{from: 27, info: nil, tags: [:word], to: 32}, %Annotations.Annotation{from: 33, info: nil, tags: [:word], to: 38}], str: "first second third. fourth fifth sixth."} Now Let's grab a list of words: iex> AnnotatedString.extract_annotations(ann_str, :word, as: :string) ["first", "second", "third", "fourth", "fifth", "sixth"] """ end
45.162791
102
0.667353
79f9c6ed57c4d688d7b9b2e7d11d462ef91308d8
2,530
exs
Elixir
apps/astarte_data_updater_plant/mix.exs
Annopaolo/astarte
f8190e8bf044759a9b84bdeb5786a55b6f793a4f
[ "Apache-2.0" ]
191
2018-03-30T13:23:08.000Z
2022-03-02T12:05:32.000Z
apps/astarte_data_updater_plant/mix.exs
Annopaolo/astarte
f8190e8bf044759a9b84bdeb5786a55b6f793a4f
[ "Apache-2.0" ]
402
2018-03-30T13:37:00.000Z
2022-03-31T16:47:10.000Z
apps/astarte_data_updater_plant/mix.exs
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 2017-2021 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.Mixfile do use Mix.Project def project do [ app: :astarte_data_updater_plant, version: "1.1.0-dev", elixir: "~> 1.11", build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, test_coverage: [tool: ExCoveralls], preferred_cli_env: [ coveralls: :test, "coveralls.detail": :test, "coveralls.post": :test, "coveralls.html": :test ], dialyzer_cache_directory: dialyzer_cache_directory(Mix.env()), deps: deps() ++ astarte_required_modules(System.get_env("ASTARTE_IN_UMBRELLA")) ] end def application do [ extra_applications: [:lager, :logger], mod: {Astarte.DataUpdaterPlant.Application, []} ] end defp dialyzer_cache_directory(:ci) do "dialyzer_cache" end defp dialyzer_cache_directory(_) do nil end defp astarte_required_modules("true") do [ {:astarte_core, in_umbrella: true}, {:astarte_data_access, in_umbrella: true}, {:astarte_rpc, in_umbrella: true} ] end defp astarte_required_modules(_) do [ {:astarte_core, github: "astarte-platform/astarte_core"}, {:astarte_data_access, github: "astarte-platform/astarte_data_access"}, {:astarte_rpc, github: "astarte-platform/astarte_rpc"} ] end defp deps do [ {:amqp, "~> 2.1"}, {:castore, "~> 0.1.0"}, {:cyanide, github: "ispirata/cyanide"}, {:excoveralls, "~> 0.12", only: :test}, {:pretty_log, "~> 0.1"}, {:plug_cowboy, "~> 2.1"}, {:telemetry_metrics_prometheus_core, "~> 0.4"}, {:telemetry_metrics, "~> 0.4"}, {:telemetry_poller, "~> 0.4"}, {:xandra, "~> 0.13"}, {:skogsra, "~> 2.2"}, {:telemetry, "~> 0.4"}, {:observer_cli, "~> 1.5"}, {:dialyzex, github: "Comcast/dialyzex", only: [:dev, :ci]} ] end end
27.802198
85
0.632806
79f9cd636e2a40901d711c3e9d31bd6d47ea450b
479
exs
Elixir
test/hlds_logs/log_producer_test.exs
JonnyPower/hlds_logs
be0b58bc5f482da7c6f31cfe3e699875d40ae719
[ "MIT" ]
2
2021-09-12T00:11:44.000Z
2022-02-13T20:45:40.000Z
test/hlds_logs/log_producer_test.exs
JonnyPower/hlds_logs
be0b58bc5f482da7c6f31cfe3e699875d40ae719
[ "MIT" ]
1
2018-11-19T04:47:38.000Z
2018-11-19T04:47:38.000Z
test/hlds_logs/log_producer_test.exs
JonnyPower/hlds_logs
be0b58bc5f482da7c6f31cfe3e699875d40ae719
[ "MIT" ]
null
null
null
defmodule HLDSLogs.LogProducerTest do use ExUnit.Case doctest HLDSLogs.LogProducer test "events from udp message" do assert {:noreply, [%HLDSLogs.LogEntry{}], nil} = HLDSLogs.LogProducer.handle_info( { :udp, nil, nil, nil, <<255, 255, 255, 255, 108>> <> "L 05/10/2018 - 18:14:39: \"player18<7><STEAM_0:0:0000000000><marine1team>\" triggered \"structure_built\" (type \"resourcetower\")" }, nil ) end end
26.611111
171
0.607516
79f9d5ac1cf8567c1f52f3560de27a0384078d8b
114
ex
Elixir
lib/phoenixcicd/repo.ex
JackMaarek/phoenix-cicd
746c66a7b248e089b1c138a81f5e4169e73aac67
[ "MIT" ]
1
2021-05-20T12:03:40.000Z
2021-05-20T12:03:40.000Z
lib/phoenixcicd/repo.ex
JackMaarek/phoenix-cicd
746c66a7b248e089b1c138a81f5e4169e73aac67
[ "MIT" ]
null
null
null
lib/phoenixcicd/repo.ex
JackMaarek/phoenix-cicd
746c66a7b248e089b1c138a81f5e4169e73aac67
[ "MIT" ]
1
2021-05-20T12:04:10.000Z
2021-05-20T12:04:10.000Z
defmodule Phoenixcicd.Repo do use Ecto.Repo, otp_app: :phoenixcicd, adapter: Ecto.Adapters.Postgres end
19
35
0.745614
79f9d5bfef8ca0ad6ba2250a3e0455e4c36b221f
1,766
ex
Elixir
clients/android_publisher/lib/google_api/android_publisher/v2/model/tracks_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/android_publisher/lib/google_api/android_publisher/v2/model/tracks_list_response.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/android_publisher/lib/google_api/android_publisher/v2/model/tracks_list_response.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.AndroidPublisher.V2.Model.TracksListResponse do @moduledoc """ ## Attributes * `kind` (*type:* `String.t`, *default:* `androidpublisher#tracksListResponse`) - Identifies what kind of resource this is. Value: the fixed string "androidpublisher#tracksListResponse". * `tracks` (*type:* `list(GoogleApi.AndroidPublisher.V2.Model.Track.t)`, *default:* `nil`) - """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :kind => String.t(), :tracks => list(GoogleApi.AndroidPublisher.V2.Model.Track.t()) } field(:kind) field(:tracks, as: GoogleApi.AndroidPublisher.V2.Model.Track, type: :list) end defimpl Poison.Decoder, for: GoogleApi.AndroidPublisher.V2.Model.TracksListResponse do def decode(value, options) do GoogleApi.AndroidPublisher.V2.Model.TracksListResponse.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.AndroidPublisher.V2.Model.TracksListResponse do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
35.32
190
0.739524
79f9f90e37fcc8a165467ab2e158d061f06ce0ee
61
ex
Elixir
flights/web/views/layout_view.ex
sifxtreme/phoenix-flights
afc8724e9a9d6f9158305d57df8132327943894d
[ "MIT" ]
null
null
null
flights/web/views/layout_view.ex
sifxtreme/phoenix-flights
afc8724e9a9d6f9158305d57df8132327943894d
[ "MIT" ]
null
null
null
flights/web/views/layout_view.ex
sifxtreme/phoenix-flights
afc8724e9a9d6f9158305d57df8132327943894d
[ "MIT" ]
null
null
null
defmodule Flights.LayoutView do use Flights.Web, :view end
15.25
31
0.786885
79fa13ea034e7ac8f7f4ef0b4ed030eaa3f68f9d
14,845
ex
Elixir
clients/compute/lib/google_api/compute/v1/model/instance.ex
renovate-bot/elixir-google-api
1da34cd39b670c99f067011e05ab90af93fef1f6
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/compute/lib/google_api/compute/v1/model/instance.ex
swansoffiee/elixir-google-api
9ea6d39f273fb430634788c258b3189d3613dde0
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/compute/lib/google_api/compute/v1/model/instance.ex
dazuma/elixir-google-api
6a9897168008efe07a6081d2326735fe332e522c
[ "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.Compute.V1.Model.Instance do @moduledoc """ Represents an Instance resource. An instance is a virtual machine that is hosted on Google Cloud Platform. For more information, read Virtual Machine Instances. ## Attributes * `advancedMachineFeatures` (*type:* `GoogleApi.Compute.V1.Model.AdvancedMachineFeatures.t`, *default:* `nil`) - Controls for advanced machine-related behavior features. * `machineType` (*type:* `String.t`, *default:* `nil`) - Full or partial URL of the machine type resource to use for this instance, in the format: zones/zone/machineTypes/machine-type. This is provided by the client when the instance is created. For example, the following is a valid partial url to a predefined machine type: zones/us-central1-f/machineTypes/n1-standard-1 To create a custom machine type, provide a URL to a machine type in the following format, where CPUS is 1 or an even number up to 32 (2, 4, 6, ... 24, etc), and MEMORY is the total memory for this instance. Memory must be a multiple of 256 MB and must be supplied in MB (e.g. 5 GB of memory is 5120 MB): zones/zone/machineTypes/custom-CPUS-MEMORY For example: zones/us-central1-f/machineTypes/custom-4-5120 For a full list of restrictions, read the Specifications for custom machine types. * `tags` (*type:* `GoogleApi.Compute.V1.Model.Tags.t`, *default:* `nil`) - Tags to apply to this instance. Tags are used to identify valid sources or targets for network firewalls and are specified by the client during instance creation. The tags can be later modified by the setTags method. Each tag within the list must comply with RFC1035. Multiple tags can be specified via the 'tags.items' field. * `lastSuspendedTimestamp` (*type:* `String.t`, *default:* `nil`) - [Output Only] Last suspended timestamp in RFC3339 text format. * `statusMessage` (*type:* `String.t`, *default:* `nil`) - [Output Only] An optional, human-readable explanation of the status. * `serviceAccounts` (*type:* `list(GoogleApi.Compute.V1.Model.ServiceAccount.t)`, *default:* `nil`) - A list of service accounts, with their specified scopes, authorized for this instance. Only one service account per VM instance is supported. Service accounts generate access tokens that can be accessed through the metadata server and used to authenticate applications on the instance. See Service Accounts for more information. * `guestAccelerators` (*type:* `list(GoogleApi.Compute.V1.Model.AcceleratorConfig.t)`, *default:* `nil`) - A list of the type and count of accelerator cards attached to the instance. * `satisfiesPzs` (*type:* `boolean()`, *default:* `nil`) - [Output Only] Reserved for future use. * `metadata` (*type:* `GoogleApi.Compute.V1.Model.Metadata.t`, *default:* `nil`) - The metadata key/value pairs assigned to this instance. This includes custom metadata and predefined keys. * `confidentialInstanceConfig` (*type:* `GoogleApi.Compute.V1.Model.ConfidentialInstanceConfig.t`, *default:* `nil`) - * `zone` (*type:* `String.t`, *default:* `nil`) - [Output Only] URL of the zone where the instance resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. * `description` (*type:* `String.t`, *default:* `nil`) - An optional description of this resource. Provide this property when you create the resource. * `networkPerformanceConfig` (*type:* `GoogleApi.Compute.V1.Model.NetworkPerformanceConfig.t`, *default:* `nil`) - * `sourceMachineImageEncryptionKey` (*type:* `GoogleApi.Compute.V1.Model.CustomerEncryptionKey.t`, *default:* `nil`) - Source machine image encryption key when creating an instance from a machine image. * `kind` (*type:* `String.t`, *default:* `compute#instance`) - [Output Only] Type of the resource. Always compute#instance for instances. * `shieldedInstanceConfig` (*type:* `GoogleApi.Compute.V1.Model.ShieldedInstanceConfig.t`, *default:* `nil`) - * `name` (*type:* `String.t`, *default:* `nil`) - The name of the resource, provided by the client when initially creating the resource. The resource name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. * `displayDevice` (*type:* `GoogleApi.Compute.V1.Model.DisplayDevice.t`, *default:* `nil`) - Enables display device for the instance. * `startRestricted` (*type:* `boolean()`, *default:* `nil`) - [Output Only] Whether a VM has been restricted for start because Compute Engine has detected suspicious activity. * `fingerprint` (*type:* `String.t`, *default:* `nil`) - Specifies a fingerprint for this resource, which is essentially a hash of the instance's contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update the instance. You must always provide an up-to-date fingerprint hash in order to update the instance. To see the latest fingerprint, make get() request to the instance. * `networkInterfaces` (*type:* `list(GoogleApi.Compute.V1.Model.NetworkInterface.t)`, *default:* `nil`) - An array of network configurations for this instance. These specify how interfaces are configured to interact with other network services, such as connecting to the internet. Multiple interfaces are supported per instance. * `sourceMachineImage` (*type:* `String.t`, *default:* `nil`) - Source machine image * `hostname` (*type:* `String.t`, *default:* `nil`) - Specifies the hostname of the instance. The specified hostname must be RFC1035 compliant. If hostname is not specified, the default hostname is [INSTANCE_NAME].c.[PROJECT_ID].internal when using the global DNS, and [INSTANCE_NAME].[ZONE].c.[PROJECT_ID].internal when using zonal DNS. * `status` (*type:* `String.t`, *default:* `nil`) - [Output Only] The status of the instance. One of the following values: PROVISIONING, STAGING, RUNNING, STOPPING, SUSPENDING, SUSPENDED, REPAIRING, and TERMINATED. For more information about the status of the instance, see Instance life cycle. * `deletionProtection` (*type:* `boolean()`, *default:* `nil`) - Whether the resource should be protected against deletion. * `resourcePolicies` (*type:* `list(String.t)`, *default:* `nil`) - Resource policies applied to this instance. * `disks` (*type:* `list(GoogleApi.Compute.V1.Model.AttachedDisk.t)`, *default:* `nil`) - Array of disks associated with this instance. Persistent disks must be created before you can assign them. * `privateIpv6GoogleAccess` (*type:* `String.t`, *default:* `nil`) - The private IPv6 google access type for the VM. If not specified, use INHERIT_FROM_SUBNETWORK as default. * `shieldedInstanceIntegrityPolicy` (*type:* `GoogleApi.Compute.V1.Model.ShieldedInstanceIntegrityPolicy.t`, *default:* `nil`) - * `lastStopTimestamp` (*type:* `String.t`, *default:* `nil`) - [Output Only] Last stop timestamp in RFC3339 text format. * `minCpuPlatform` (*type:* `String.t`, *default:* `nil`) - Specifies a minimum CPU platform for the VM instance. Applicable values are the friendly names of CPU platforms, such as minCpuPlatform: "Intel Haswell" or minCpuPlatform: "Intel Sandy Bridge". * `labelFingerprint` (*type:* `String.t`, *default:* `nil`) - A fingerprint for this request, which is essentially a hash of the label's contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels. To see the latest fingerprint, make get() request to the instance. * `creationTimestamp` (*type:* `String.t`, *default:* `nil`) - [Output Only] Creation timestamp in RFC3339 text format. * `id` (*type:* `String.t`, *default:* `nil`) - [Output Only] The unique identifier for the resource. This identifier is defined by the server. * `canIpForward` (*type:* `boolean()`, *default:* `nil`) - Allows this instance to send and receive packets with non-matching destination or source IPs. This is required if you plan to use this instance to forward routes. For more information, see Enabling IP Forwarding . * `labels` (*type:* `map()`, *default:* `nil`) - Labels to apply to this instance. These can be later modified by the setLabels method. * `lastStartTimestamp` (*type:* `String.t`, *default:* `nil`) - [Output Only] Last start timestamp in RFC3339 text format. * `selfLink` (*type:* `String.t`, *default:* `nil`) - [Output Only] Server-defined URL for this resource. * `reservationAffinity` (*type:* `GoogleApi.Compute.V1.Model.ReservationAffinity.t`, *default:* `nil`) - Specifies the reservations that this instance can consume from. * `cpuPlatform` (*type:* `String.t`, *default:* `nil`) - [Output Only] The CPU platform used by this instance. * `scheduling` (*type:* `GoogleApi.Compute.V1.Model.Scheduling.t`, *default:* `nil`) - Sets the scheduling options for this instance. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :advancedMachineFeatures => GoogleApi.Compute.V1.Model.AdvancedMachineFeatures.t() | nil, :machineType => String.t() | nil, :tags => GoogleApi.Compute.V1.Model.Tags.t() | nil, :lastSuspendedTimestamp => String.t() | nil, :statusMessage => String.t() | nil, :serviceAccounts => list(GoogleApi.Compute.V1.Model.ServiceAccount.t()) | nil, :guestAccelerators => list(GoogleApi.Compute.V1.Model.AcceleratorConfig.t()) | nil, :satisfiesPzs => boolean() | nil, :metadata => GoogleApi.Compute.V1.Model.Metadata.t() | nil, :confidentialInstanceConfig => GoogleApi.Compute.V1.Model.ConfidentialInstanceConfig.t() | nil, :zone => String.t() | nil, :description => String.t() | nil, :networkPerformanceConfig => GoogleApi.Compute.V1.Model.NetworkPerformanceConfig.t() | nil, :sourceMachineImageEncryptionKey => GoogleApi.Compute.V1.Model.CustomerEncryptionKey.t() | nil, :kind => String.t() | nil, :shieldedInstanceConfig => GoogleApi.Compute.V1.Model.ShieldedInstanceConfig.t() | nil, :name => String.t() | nil, :displayDevice => GoogleApi.Compute.V1.Model.DisplayDevice.t() | nil, :startRestricted => boolean() | nil, :fingerprint => String.t() | nil, :networkInterfaces => list(GoogleApi.Compute.V1.Model.NetworkInterface.t()) | nil, :sourceMachineImage => String.t() | nil, :hostname => String.t() | nil, :status => String.t() | nil, :deletionProtection => boolean() | nil, :resourcePolicies => list(String.t()) | nil, :disks => list(GoogleApi.Compute.V1.Model.AttachedDisk.t()) | nil, :privateIpv6GoogleAccess => String.t() | nil, :shieldedInstanceIntegrityPolicy => GoogleApi.Compute.V1.Model.ShieldedInstanceIntegrityPolicy.t() | nil, :lastStopTimestamp => String.t() | nil, :minCpuPlatform => String.t() | nil, :labelFingerprint => String.t() | nil, :creationTimestamp => String.t() | nil, :id => String.t() | nil, :canIpForward => boolean() | nil, :labels => map() | nil, :lastStartTimestamp => String.t() | nil, :selfLink => String.t() | nil, :reservationAffinity => GoogleApi.Compute.V1.Model.ReservationAffinity.t() | nil, :cpuPlatform => String.t() | nil, :scheduling => GoogleApi.Compute.V1.Model.Scheduling.t() | nil } field(:advancedMachineFeatures, as: GoogleApi.Compute.V1.Model.AdvancedMachineFeatures) field(:machineType) field(:tags, as: GoogleApi.Compute.V1.Model.Tags) field(:lastSuspendedTimestamp) field(:statusMessage) field(:serviceAccounts, as: GoogleApi.Compute.V1.Model.ServiceAccount, type: :list) field(:guestAccelerators, as: GoogleApi.Compute.V1.Model.AcceleratorConfig, type: :list) field(:satisfiesPzs) field(:metadata, as: GoogleApi.Compute.V1.Model.Metadata) field(:confidentialInstanceConfig, as: GoogleApi.Compute.V1.Model.ConfidentialInstanceConfig) field(:zone) field(:description) field(:networkPerformanceConfig, as: GoogleApi.Compute.V1.Model.NetworkPerformanceConfig) field(:sourceMachineImageEncryptionKey, as: GoogleApi.Compute.V1.Model.CustomerEncryptionKey) field(:kind) field(:shieldedInstanceConfig, as: GoogleApi.Compute.V1.Model.ShieldedInstanceConfig) field(:name) field(:displayDevice, as: GoogleApi.Compute.V1.Model.DisplayDevice) field(:startRestricted) field(:fingerprint) field(:networkInterfaces, as: GoogleApi.Compute.V1.Model.NetworkInterface, type: :list) field(:sourceMachineImage) field(:hostname) field(:status) field(:deletionProtection) field(:resourcePolicies, type: :list) field(:disks, as: GoogleApi.Compute.V1.Model.AttachedDisk, type: :list) field(:privateIpv6GoogleAccess) field(:shieldedInstanceIntegrityPolicy, as: GoogleApi.Compute.V1.Model.ShieldedInstanceIntegrityPolicy ) field(:lastStopTimestamp) field(:minCpuPlatform) field(:labelFingerprint) field(:creationTimestamp) field(:id) field(:canIpForward) field(:labels, type: :map) field(:lastStartTimestamp) field(:selfLink) field(:reservationAffinity, as: GoogleApi.Compute.V1.Model.ReservationAffinity) field(:cpuPlatform) field(:scheduling, as: GoogleApi.Compute.V1.Model.Scheduling) end defimpl Poison.Decoder, for: GoogleApi.Compute.V1.Model.Instance do def decode(value, options) do GoogleApi.Compute.V1.Model.Instance.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Compute.V1.Model.Instance do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
84.346591
866
0.717817
79fa1976908ba8ec0d98866e6b1f836e8ffc62ac
719
exs
Elixir
test/scenic/primitive/style/miter_limit_test.exs
bruceme/scenic
bd8a1e63c122c44cc263e1fb5dfab2547ce8ef43
[ "Apache-2.0" ]
null
null
null
test/scenic/primitive/style/miter_limit_test.exs
bruceme/scenic
bd8a1e63c122c44cc263e1fb5dfab2547ce8ef43
[ "Apache-2.0" ]
null
null
null
test/scenic/primitive/style/miter_limit_test.exs
bruceme/scenic
bd8a1e63c122c44cc263e1fb5dfab2547ce8ef43
[ "Apache-2.0" ]
null
null
null
# # Created by Boyd Multerer on 2017-05-12. # Copyright © 2017-2021 Kry10 Limited. All rights reserved. # defmodule Scenic.Primitive.Style.MiterLimitTest do use ExUnit.Case, async: true doctest Scenic.Primitive.Style.MiterLimit alias Scenic.Primitive.Style.MiterLimit test "validate accepts valid data" do assert MiterLimit.validate(12) == {:ok, 12} assert MiterLimit.validate(16.5) == {:ok, 16.5} end test "validate rejects negative numbers" do {:error, msg} = MiterLimit.validate(-12) assert msg =~ "must be a positive number" end test "validate rejects invalid data" do {:error, msg} = MiterLimit.validate("way off") assert msg =~ "must be a positive number" end end
26.62963
60
0.706537
79fa3c4d6dd0098abddda7fdd8525f9823ed9008
147
exs
Elixir
test/bootlegger_test.exs
mogorman/bootlegger
2852afb8ef09a7098a6c866316191808cda37e06
[ "MIT" ]
null
null
null
test/bootlegger_test.exs
mogorman/bootlegger
2852afb8ef09a7098a6c866316191808cda37e06
[ "MIT" ]
null
null
null
test/bootlegger_test.exs
mogorman/bootlegger
2852afb8ef09a7098a6c866316191808cda37e06
[ "MIT" ]
null
null
null
defmodule BootleggerTest do use ExUnit.Case doctest Bootlegger test "greets the world" do assert Bootlegger.hello() == :world end end
16.333333
39
0.727891
79fa6227fe68c44c7653c11628b6246bd95fb090
1,504
ex
Elixir
test/support/queue_test_helper.ex
smartrent/task_bunny
db0b91d966b54df75e0f60f9c788ffa044c1f37a
[ "MIT" ]
null
null
null
test/support/queue_test_helper.ex
smartrent/task_bunny
db0b91d966b54df75e0f60f9c788ffa044c1f37a
[ "MIT" ]
null
null
null
test/support/queue_test_helper.ex
smartrent/task_bunny
db0b91d966b54df75e0f60f9c788ffa044c1f37a
[ "MIT" ]
null
null
null
defmodule TaskBunny.QueueTestHelper do defmacro clean(queues) do quote do # Remove pre-existing queues before every test. {:ok, connection} = AMQP.Connection.open() {:ok, channel} = AMQP.Channel.open(connection) Enum.each(unquote(queues), fn queue -> AMQP.Queue.delete(channel, queue) end) on_exit(fn -> # Cleanup after test by removing queue. Enum.each(unquote(queues), fn queue -> AMQP.Queue.delete(channel, queue) end) :ok = AMQP.Connection.close(connection) end) end end # Queue Helpers def open_channel(host \\ :default) do conn = TaskBunny.Connection.get_connection!(host) {:ok, _channel} = AMQP.Channel.open(conn) end def declare(queue, host \\ :default) do {:ok, channel} = open_channel(host) {:ok, _state} = AMQP.Queue.declare(channel, queue, durable: true) :ok = AMQP.Channel.close(channel) :ok end def purge(queue, host \\ :default) def purge(queue, host) when is_binary(queue) do {:ok, channel} = open_channel(host) {:ok, _} = AMQP.Queue.purge(channel, queue) {:ok, _} = AMQP.Queue.delete(channel, queue) :ok = AMQP.Channel.close(channel) :ok end def pop(queue) do {:ok, channel} = open_channel() :ok = AMQP.Basic.qos(channel, prefetch_count: 1) {:ok, _} = AMQP.Basic.consume(channel, queue) receive do {:basic_deliver, payload, meta} -> :ok = AMQP.Channel.close(channel) {payload, meta} end end end
25.491525
85
0.636968
79fa9370e7a92811398090965c20126995502090
1,925
ex
Elixir
lib/makeup/styles/html/pygments/colorful.ex
kipcole9/makeup
dff1bd2e3d6b2938138ebaea5771821bf7c4e45a
[ "BSD-2-Clause" ]
13
2018-09-19T21:03:29.000Z
2022-01-27T04:06:32.000Z
deps/makeup/lib/makeup/styles/html/pygments/colorful.ex
mwindholtz/limbo
84da57c72ddb2f1dd78bf2992410268c5ad1b2d4
[ "Apache-2.0" ]
1
2020-05-26T04:16:57.000Z
2020-05-26T04:16:57.000Z
deps/makeup/lib/makeup/styles/html/pygments/colorful.ex
mwindholtz/limbo
84da57c72ddb2f1dd78bf2992410268c5ad1b2d4
[ "Apache-2.0" ]
3
2020-05-21T04:32:08.000Z
2021-07-28T05:14:01.000Z
defmodule Makeup.Styles.HTML.ColorfulStyle do @moduledoc false @styles %{ :error => "#F00 bg:#FAA", :keyword => "bold #080", :keyword_pseudo => "#038", :keyword_type => "#339", :name_attribute => "#00C", :name_builtin => "#007020", :name_class => "bold #B06", :name_constant => "bold #036", :name_decorator => "bold #555", :name_entity => "bold #800", :name_exception => "bold #F00", :name_function => "bold #06B", :name_label => "bold #970", :name_namespace => "bold #0e84b5", :name_tag => "#070", :name_variable => "#963", :name_variable_class => "#369", :name_variable_global => "bold #d70", :name_variable_instance => "#33B", :string => "bg:#fff0f0", :string_char => "#04D bg:", :string_doc => "#D42 bg:", :string_escape => "bold #666", :string_interpol => "bg:#eee", :string_other => "#D20", :string_regex => "bg:#fff0ff #000", :string_symbol => "#A60 bg:", :number => "bold #60E", :number_float => "bold #60E", :number_hex => "bold #058", :number_integer => "bold #00D", :number_oct => "bold #40E", :operator => "#333", :operator_word => "bold #000", :comment => "#888", :comment_preproc => "#579", :comment_special => "bold #cc0000", :generic_deleted => "#A00000", :generic_emph => "italic", :generic_error => "#FF0000", :generic_heading => "bold #000080", :generic_inserted => "#00A000", :generic_output => "#888", :generic_prompt => "bold #c65d09", :generic_strong => "bold", :generic_subheading => "bold #800080", :generic_traceback => "#04D" } alias Makeup.Styles.HTML.Style @style_struct Style.make_style( short_name: "colorful", long_name: "Colorful Style", background_color: "#ffffff", highlight_color: "#ffffcc", styles: @styles) def style() do @style_struct() end end
28.308824
45
0.578182
79fa9c562c423383262f87b288670517a560b004
6,064
ex
Elixir
lib/app/accounts.ex
ThanhUong/Chronos
5e1b0823c585b784f5c51212513d518cab53a571
[ "MIT" ]
null
null
null
lib/app/accounts.ex
ThanhUong/Chronos
5e1b0823c585b784f5c51212513d518cab53a571
[ "MIT" ]
null
null
null
lib/app/accounts.ex
ThanhUong/Chronos
5e1b0823c585b784f5c51212513d518cab53a571
[ "MIT" ]
null
null
null
defmodule App.Accounts do @moduledoc """ The Accounts context. """ import Ecto.Query, warn: false alias App.Repo alias App.Accounts.User alias App.Projects @doc """ Gets a single user. Raises `Ecto.NoResultsError` if the User does not exist. ## Examples iex> get_user!(123) %User{} iex> get_user!(456) ** (Ecto.NoResultsError) """ def get_user!(id) do User |> Repo.get(id) end def get_user_by_email(email) do Repo.get_by(User, email: email) end @doc """ Creates a user. ## Examples iex> create_user(%{field: value}) {:ok, %User{}} iex> create_user(%{field: bad_value}) {:error, %Ecto.Changeset{}} """ def create_user(attrs \\ %{}) do %User{} |> change_user(attrs) |> Repo.insert() end @doc """ Updates a user. ## Examples iex> update_user(user, %{field: new_value}) {:ok, %User{}} iex> update_user(user, %{field: bad_value}) {:error, %Ecto.Changeset{}} """ def update_user(%User{} = user, attrs) do user |> change_user(attrs) |> Repo.update() end @doc """ Returns an `%Ecto.Changeset{}` for tracking user changes. ## Examples iex> change_user(user) %Ecto.Changeset{data: %User{}} """ def change_user(%User{} = user, attrs \\ %{}) do organization = get_or_create_organization(attrs["organization"]) user |> Repo.preload(:organizations) |> User.changeset(attrs) |> Ecto.Changeset.put_assoc(:organizations, [organization]) end alias App.Accounts.Organization @doc """ Returns the list of organizations. ## Examples iex> list_organizations() [%Organization{}, ...] """ def list_organizations do Repo.all(Organization) end @doc """ Returns the list of organizations of a user. """ def list_organizations_of_user(nil), do: [] def list_organizations_of_user(user) do user |> Ecto.assoc(:organizations) |> Repo.all |> Repo.preload([workflows: :stages]) end @doc """ Gets a single organization. Raises `Ecto.NoResultsError` if the Organization does not exist. ## Examples iex> get_organization!(123) %Organization{} iex> get_organization!(456) ** (Ecto.NoResultsError) """ def get_organization!(id) do Organization |> Repo.get!(id) |> Repo.preload([:users]) end @doc """ Gets a single organization without preloading users association. Raises `Ecto.NoResultsError` if the Organization does not exist. ## Examples iex> get_organization!(123) %Organization{} iex> get_organization!(456) ** (Ecto.NoResultsError) """ def get_organization_without_users!(id) do Organization |> Repo.get!(id) end def get_or_create_organization(organization) do if is_binary(organization) do {:ok, organization} = create_organization(%{name: organization}) {:ok, workflow} = Projects.create_workflow(%{organization_id: organization.id}) Projects.create_default_stages(workflow.id) organization else get_organization!(organization) end end @doc """ Creates a organization. ## Examples iex> create_organization(%{field: value}) {:ok, %Organization{}} iex> create_organization(%{field: bad_value}) {:error, %Ecto.Changeset{}} """ def create_organization(attrs \\ %{}) do %Organization{} |> Organization.changeset(attrs) |> Repo.insert() end @doc """ Updates a organization. ## Examples iex> update_organization(organization, %{field: new_value}) {:ok, %Organization{}} iex> update_organization(organization, %{field: bad_value}) {:error, %Ecto.Changeset{}} """ def update_organization(%Organization{} = organization, attrs) do organization |> Organization.changeset(attrs) |> Repo.update() end @doc """ Deletes a organization. ## Examples iex> delete_organization(organization) {:ok, %Organization{}} iex> delete_organization(organization) {:error, %Ecto.Changeset{}} """ def delete_organization(%Organization{} = organization) do Repo.delete(organization) end @doc """ Returns an `%Ecto.Changeset{}` for tracking organization changes. ## Examples iex> change_organization(organization) %Ecto.Changeset{data: %Organization{}} """ def change_organization(%Organization{} = organization, attrs \\ %{}) do Organization.changeset(organization, attrs) end alias App.Accounts.Role @doc """ Returns the list of roles. ## Examples iex> list_roles() [%Role{}, ...] """ def list_roles do Repo.all(Role) end @doc """ Gets a single role. Raises `Ecto.NoResultsError` if the Role does not exist. ## Examples iex> get_role!(123) %Role{} iex> get_role!(456) ** (Ecto.NoResultsError) """ def get_role!(id), do: Repo.get!(Role, id) @doc """ Creates a role. ## Examples iex> create_role(%{field: value}) {:ok, %Role{}} iex> create_role(%{field: bad_value}) {:error, %Ecto.Changeset{}} """ def create_role(attrs \\ %{}) do %Role{} |> Role.changeset(attrs) |> Repo.insert() end @doc """ Updates a role. ## Examples iex> update_role(role, %{field: new_value}) {:ok, %Role{}} iex> update_role(role, %{field: bad_value}) {:error, %Ecto.Changeset{}} """ def update_role(%Role{} = role, attrs) do role |> Role.changeset(attrs) |> Repo.update() end @doc """ Deletes a role. ## Examples iex> delete_role(role) {:ok, %Role{}} iex> delete_role(role) {:error, %Ecto.Changeset{}} """ def delete_role(%Role{} = role) do Repo.delete(role) end @doc """ Returns an `%Ecto.Changeset{}` for tracking role changes. ## Examples iex> change_role(role) %Ecto.Changeset{data: %Role{}} """ def change_role(%Role{} = role, attrs \\ %{}) do Role.changeset(role, attrs) end end
18.95
88
0.616755
79faababe3956214cc82e94d80370bed2d30b50c
5,781
ex
Elixir
clients/games/lib/google_api/games/v1/api/players.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/games/lib/google_api/games/v1/api/players.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/games/lib/google_api/games/v1/api/players.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
1
2018-07-28T20:50:50.000Z
2018-07-28T20:50:50.000Z
# 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.Games.V1.Api.Players do @moduledoc """ API calls for all endpoints tagged `Players`. """ alias GoogleApi.Games.V1.Connection import GoogleApi.Games.V1.RequestBuilder @doc """ Retrieves the Player resource with the given ID. To retrieve the player for the currently authenticated user, set playerId to me. ## Parameters - connection (GoogleApi.Games.V1.Connection): Connection to server - player_id (String): A player ID. A value of me may be used in place of the authenticated player&#39;s ID. - opts (KeywordList): [optional] Optional parameters - :alt (String): Data format for the response. - :fields (String): Selector specifying which fields to include in a partial response. - :key (String): 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): OAuth 2.0 token for the current user. - :pretty_print (Boolean): Returns response with indentations and line breaks. - :quota_user (String): 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. Overrides userIp if both are provided. - :user_ip (String): IP address of the site where the request originates. Use this if you want to enforce per-user limits. - :consistency_token (String): The last-seen mutation timestamp. - :language (String): The preferred language to use for strings returned by this method. ## Returns {:ok, %GoogleApi.Games.V1.Model.Player{}} on success {:error, info} on failure """ @spec games_players_get(Tesla.Env.client, String.t, keyword()) :: {:ok, GoogleApi.Games.V1.Model.Player.t} | {:error, Tesla.Env.t} def games_players_get(connection, player_id, opts \\ []) do optional_params = %{ :"alt" => :query, :"fields" => :query, :"key" => :query, :"oauth_token" => :query, :"prettyPrint" => :query, :"quotaUser" => :query, :"userIp" => :query, :"consistencyToken" => :query, :"language" => :query } %{} |> method(:get) |> url("/players/{playerId}", %{ "playerId" => URI.encode_www_form(player_id) }) |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%GoogleApi.Games.V1.Model.Player{}) end @doc """ Get the collection of players for the currently authenticated user. ## Parameters - connection (GoogleApi.Games.V1.Connection): Connection to server - collection (String): Collection of players being retrieved - opts (KeywordList): [optional] Optional parameters - :alt (String): Data format for the response. - :fields (String): Selector specifying which fields to include in a partial response. - :key (String): 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): OAuth 2.0 token for the current user. - :pretty_print (Boolean): Returns response with indentations and line breaks. - :quota_user (String): 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. Overrides userIp if both are provided. - :user_ip (String): IP address of the site where the request originates. Use this if you want to enforce per-user limits. - :consistency_token (String): The last-seen mutation timestamp. - :language (String): The preferred language to use for strings returned by this method. - :max_results (Integer): The maximum number of player resources to return in the response, used for paging. For any response, the actual number of player resources returned may be less than the specified maxResults. - :page_token (String): The token returned by the previous request. ## Returns {:ok, %GoogleApi.Games.V1.Model.PlayerListResponse{}} on success {:error, info} on failure """ @spec games_players_list(Tesla.Env.client, String.t, keyword()) :: {:ok, GoogleApi.Games.V1.Model.PlayerListResponse.t} | {:error, Tesla.Env.t} def games_players_list(connection, collection, opts \\ []) do optional_params = %{ :"alt" => :query, :"fields" => :query, :"key" => :query, :"oauth_token" => :query, :"prettyPrint" => :query, :"quotaUser" => :query, :"userIp" => :query, :"consistencyToken" => :query, :"language" => :query, :"maxResults" => :query, :"pageToken" => :query } %{} |> method(:get) |> url("/players/me/players/{collection}", %{ "collection" => URI.encode_www_form(collection) }) |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%GoogleApi.Games.V1.Model.PlayerListResponse{}) end end
45.519685
220
0.692095
79faba289eb520a6d21dac0e2f8a11c6bfd2546a
2,674
ex
Elixir
lib/ex_oapi/parser/ecto_types/typed_enum.ex
mnussbaumer/ex_oapi
f5eb610283a7f92a69e6266effc0dc4e2c497b61
[ "MIT" ]
null
null
null
lib/ex_oapi/parser/ecto_types/typed_enum.ex
mnussbaumer/ex_oapi
f5eb610283a7f92a69e6266effc0dc4e2c497b61
[ "MIT" ]
null
null
null
lib/ex_oapi/parser/ecto_types/typed_enum.ex
mnussbaumer/ex_oapi
f5eb610283a7f92a69e6266effc0dc4e2c497b61
[ "MIT" ]
null
null
null
defmodule ExOAPI.EctoTypes.TypedEnum do defmacro __before_compile__(_env) do # these are inserted in the before_compile hook to give opportunity to the # implementing module to define additional variations quote do def cast(_), do: :error def dump(_), do: :error defp get_term(data), do: data end end defmacro __using__(opts) do values = Keyword.fetch!(opts, :values) mod = __CALLER__.module quote bind_quoted: [atoms: values, mod: mod] do @before_compile ExOAPI.EctoTypes.TypedEnum strings = Enum.map(atoms, fn entry -> Atom.to_string(entry) end) mapped = Enum.zip(strings, atoms) |> Enum.into(%{}) @behaviour Ecto.Type @impl Ecto.Type def type, do: :string strings = Enum.map(atoms, fn entry -> Atom.to_string(entry) end) mapped = Enum.zip(strings, atoms) |> Enum.into(%{}) Module.put_attribute(mod, :valid_atoms, atoms) Module.put_attribute(mod, :valid_strings, strings) Module.put_attribute(mod, :validation_mappings, mapped) @type t() :: unquote(Enum.reduce(Enum.reverse(atoms), &{:|, [], [&1, &2]})) @spec values(:atoms | :strings) :: list(t()) | list(String.t()) def values(type \\ :atoms) def values(:atoms), do: unquote(atoms) def values(:strings), do: unquote(strings) @impl Ecto.Type def load(data), do: cast(data) @impl Ecto.Type @doc false def cast(data) when is_atom(data) and data in unquote(atoms), do: {:ok, data} def cast(data) when is_binary(data) and data in unquote(strings), do: {:ok, String.to_atom(data)} @impl Ecto.Type @doc false def dump(data) when is_atom(data) and data in unquote(atoms), do: {:ok, Atom.to_string(data)} def dump(data) when is_binary(data) and data in unquote(strings), do: {:ok, data} @doc false def dump!(data) do case dump(data) do {:ok, value} -> value _ -> raise Ecto.CastError, message: "Unable to dump:: #{inspect(data)} ::into:: #{inspect(unquote(mod))}", type: unquote(mod), value: data end end @impl Ecto.Type @doc false def embed_as(_), do: :dump @impl Ecto.Type @doc false def equal?(term_1, term_1), do: true def equal?(term_1, term_2), do: get_term(term_1) == get_term(term_2) defp get_term(data) when is_atom(data) and data in unquote(atoms), do: data defp get_term(data) when is_binary(data) and data in unquote(strings), do: @validation_mappings[data] end end end
30.044944
93
0.60733
79fabb59ebc05c7fb2e0fa999287d42b3b3f188d
1,212
exs
Elixir
mix.exs
skirino/pool_sup
1cd5a60ce6538fac73cd23782fd6ee1431b65032
[ "MIT" ]
8
2016-04-05T01:59:33.000Z
2017-09-22T18:59:33.000Z
mix.exs
skirino/pool_sup
1cd5a60ce6538fac73cd23782fd6ee1431b65032
[ "MIT" ]
2
2018-06-26T07:53:04.000Z
2018-06-27T13:28:39.000Z
mix.exs
skirino/pool_sup
1cd5a60ce6538fac73cd23782fd6ee1431b65032
[ "MIT" ]
1
2018-06-26T04:35:42.000Z
2018-06-26T04:35:42.000Z
defmodule PoolSup.Mixfile do use Mix.Project @github_url "https://github.com/skirino/pool_sup" def project() do [ app: :pool_sup, version: "0.6.1", elixir: "~> 1.6", build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, deps: deps(), description: "A supervisor specialized to manage pool of workers", package: package(), source_url: @github_url, homepage_url: @github_url, test_coverage: [tool: ExCoveralls], preferred_cli_env: [coveralls: :test, "coveralls.detail": :test, "coveralls.post": :test, "coveralls.html": :test], ] end def application() do [] end defp deps() do [ {:croma , "~> 0.9"}, {:dialyxir , "~> 0.5" , [only: :dev ]}, {:ex_doc , "~> 0.18.0", [only: :dev ]}, {:excoveralls, "~> 0.10" , [only: :test]}, ] end defp package() do [ files: ["lib", "mix.exs", "README.md", "LICENSE"], maintainers: ["Shunsuke Kirino"], licenses: ["MIT"], links: %{"GitHub repository" => @github_url}, ] end end
26.933333
121
0.502475
79fac55d8a771dfd543fce4ab0ededffd4b84fe1
1,449
ex
Elixir
insights/lib/insights_web/router.ex
MillionIntegrals/elixir-mongodb-driver
96c4cc3f21c4043323b8a9b33ad3a374760864c6
[ "Apache-2.0" ]
null
null
null
insights/lib/insights_web/router.ex
MillionIntegrals/elixir-mongodb-driver
96c4cc3f21c4043323b8a9b33ad3a374760864c6
[ "Apache-2.0" ]
null
null
null
insights/lib/insights_web/router.ex
MillionIntegrals/elixir-mongodb-driver
96c4cc3f21c4043323b8a9b33ad3a374760864c6
[ "Apache-2.0" ]
null
null
null
defmodule InsightsWeb.Router do use InsightsWeb, :router pipeline :browser do plug :accepts, ["html"] plug :fetch_session plug :fetch_live_flash plug :put_root_layout, {InsightsWeb.LayoutView, :root} plug :protect_from_forgery plug :put_secure_browser_headers end pipeline :api do plug :accepts, ["json"] end scope "/", InsightsWeb do pipe_through :browser live "/", TopologyLive, :index end # Other scopes may use custom stacks. # scope "/api", InsightsWeb do # pipe_through :api # end # Enables LiveDashboard only for development # # If you want to use the LiveDashboard in production, you should put # it behind authentication and allow only admins to access it. # If your application does not have an admins-only section yet, # you can use Plug.BasicAuth to set up some basic authentication # as long as you are also using SSL (which you should anyway). if Mix.env() in [:dev, :test] do import Phoenix.LiveDashboard.Router scope "/" do pipe_through :browser live_dashboard "/dashboard", metrics: InsightsWeb.Telemetry end end # Enables the Swoosh mailbox preview in development. # # Note that preview only shows emails that were sent by the same # node running the Phoenix server. if Mix.env() == :dev do scope "/dev" do pipe_through :browser forward "/mailbox", Plug.Swoosh.MailboxPreview end end end
25.875
70
0.697723
79fac68ea7dd80adf03fdbb98cecc3eec0994777
2,999
exs
Elixir
apps/astarte_pairing_api/mix.exs
Spidey20202022/astarte
3950855c592b34363af0cf7f8a921762ce64e512
[ "Apache-2.0" ]
1
2020-02-04T13:15:22.000Z
2020-02-04T13:15:22.000Z
apps/astarte_pairing_api/mix.exs
Spidey20202022/astarte
3950855c592b34363af0cf7f8a921762ce64e512
[ "Apache-2.0" ]
1
2020-01-20T09:52:48.000Z
2020-01-20T09:52:48.000Z
apps/astarte_pairing_api/mix.exs
Spidey20202022/astarte
3950855c592b34363af0cf7f8a921762ce64e512
[ "Apache-2.0" ]
1
2020-02-04T13:15:50.000Z
2020-02-04T13:15:50.000Z
# # This file is part of Astarte. # # Copyright 2017 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.Pairing.API.Mixfile do use Mix.Project def project do [ app: :astarte_pairing_api, version: "0.11.0-beta.3", elixir: "~> 1.8", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), start_permanent: Mix.env() == :prod, test_coverage: [tool: ExCoveralls], preferred_cli_env: [ coveralls: :test, "coveralls.detail": :test, "coveralls.post": :test, "coveralls.html": :test ], dialyzer_cache_directory: dialyzer_cache_directory(Mix.env()), deps: deps() ++ astarte_required_modules(System.get_env("ASTARTE_IN_UMBRELLA")) ] end # Configuration for the OTP application. # # Type `mix help compile.app` for more information. def application do [ mod: {Astarte.Pairing.API.Application, []}, extra_applications: [:lager, :logger, :runtime_tools] ] end # Specifies which paths to compile per environment. defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] defp dialyzer_cache_directory(:ci) do "dialyzer_cache" end defp dialyzer_cache_directory(_) do nil end defp astarte_required_modules("true") do [ {:astarte_core, in_umbrella: true}, {:astarte_rpc, in_umbrella: true} ] end defp astarte_required_modules(_) do [ {:astarte_core, github: "astarte-platform/astarte_core", branch: "release-0.11"}, {:astarte_rpc, github: "astarte-platform/astarte_rpc", branch: "release-0.11"} ] end # Specifies your project dependencies. # # Type `mix help deps` for examples and options. defp deps do [ {:phoenix, "~> 1.4"}, {:phoenix_pubsub, "~> 1.1"}, {:gettext, "~> 0.11"}, {:plug_cowboy, "~> 2.0"}, {:phoenix_ecto, "~> 4.0"}, {:jason, "~> 1.0"}, {:guardian, "~> 1.2"}, {:remote_ip, "~> 0.1"}, {:conform, "== 2.5.2"}, {:distillery, "~> 1.5", runtime: false}, {:excoveralls, "~> 0.11", only: :test}, {:mox, "~> 0.3", only: :test}, {:pretty_log, "~> 0.1"}, {:plug_logger_with_meta, "~> 0.1"}, {:prometheus_process_collector, "~> 1.4"}, {:prometheus_phoenix, "~> 1.3"}, {:prometheus_plugs, "~> 1.1"}, {:dialyzex, github: "Comcast/dialyzex", only: [:dev, :ci]} ] end end
28.836538
87
0.624542
79fad1302e9914e5fa16ea9fb3b6f284b0423e1f
1,658
ex
Elixir
priv/templates/brando.install/lib/application_name/authorization.ex
brandocms/brando
4198e0c0920031bd909969055064e4e2b7230d21
[ "MIT" ]
4
2020-10-30T08:40:38.000Z
2022-01-07T22:21:37.000Z
priv/templates/brando.install/lib/application_name/authorization.ex
brandocms/brando
4198e0c0920031bd909969055064e4e2b7230d21
[ "MIT" ]
1,162
2020-07-05T11:20:15.000Z
2022-03-31T06:01:49.000Z
priv/templates/brando.install/lib/application_name/authorization.ex
brandocms/brando
4198e0c0920031bd909969055064e4e2b7230d21
[ "MIT" ]
null
null
null
defmodule <%= application_module %>.Authorization do @moduledoc """ Authorization module for application. This module sets permissions across the application on the backend as well as the frontend. """ use Brando.Authorization # Declare types so we can translate seamlessly between # frontend and backend authorization queries. types [ {"Identity", Brando.Sites.Identity}, {"Image", Brando.Image}, {"ImageSeries", Brando.ImageSeries}, {"ImageCategory", Brando.ImageCategory}, {"Page", Brando.Pages.Page}, {"Fragment", Brando.Pages.Fragment}, {"Module", Brando.Content.Module}, {"User", Brando.Users.User} ] # Rules for :superuser rules :superuser do can :manage, :all end # Rules for :admin rules :admin do can :manage, :all cannot :manage, %Brando.Users.User{}, when: %{role: "superuser"} cannot :view, "MenuItem", when: %{to: %{name: "modules"}} end # Rules for :editor rules :editor do can :manage, :all cannot :manage, "SEO" cannot :manage, "Globals" cannot :manage, %Brando.Sites.Identity{} cannot :manage, %Brando.Content.Module{} cannot :manage, %Brando.Users.User{} cannot :view, "MenuItem", when: %{to: %{name: "navigation"}} cannot :view, "MenuItem", when: %{to: %{name: "config-seo"}} cannot :view, "MenuItem", when: %{to: %{name: "config-identity"}} cannot :view, "MenuItem", when: %{to: %{name: "config-globals"}} cannot :view, "MenuItem", when: %{to: %{name: "modules"}} cannot :view, "MenuItem", when: %{to: %{name: "users"}} end # Rules for :user rules :user do cannot :manage, :all end end
29.087719
69
0.64234
79fb0b1056ce375815221107d4021421a1487df4
2,016
ex
Elixir
apps/gobstopper_api/lib/gobstopper.api/auth.ex
ZURASTA/gobstopper
f8d231c4459af6fa44273c3ef80857348410c70b
[ "BSD-2-Clause" ]
null
null
null
apps/gobstopper_api/lib/gobstopper.api/auth.ex
ZURASTA/gobstopper
f8d231c4459af6fa44273c3ef80857348410c70b
[ "BSD-2-Clause" ]
12
2017-07-24T12:29:51.000Z
2018-04-05T03:58:10.000Z
apps/gobstopper_api/lib/gobstopper.api/auth.ex
ZURASTA/gobstopper
f8d231c4459af6fa44273c3ef80857348410c70b
[ "BSD-2-Clause" ]
4
2017-07-24T12:19:23.000Z
2019-02-19T06:34:46.000Z
defmodule Gobstopper.API.Auth do @moduledoc """ Handles the authorization of session tokens. """ @service Gobstopper.Service.Auth @type token :: String.t @type uuid :: String.t @doc """ Logout of an identity's active session. #{Gobstopper.API.option_docs} """ @spec logout(token, keyword(any)) :: :ok def logout(token, options \\ []) do options = Gobstopper.API.defaults(options) GenServer.cast(options[:server].(@service), { :logout, token }) :ok end @doc """ Verify an identity's session. #{Gobstopper.API.option_docs} Returns the unique ID of the identity if verifying a valid session token. Otherwise returns `nil`. """ @spec verify(token, keyword(any)) :: uuid | nil def verify(token, options \\ []) do options = Gobstopper.API.defaults(options) GenServer.call(options[:server].(@service), { :verify, token }, options[:timeout]) end @doc """ Refresh an identity's session. #{Gobstopper.API.option_docs} Returns a new session token and disables the previous one. Otherwise returns an error. """ @spec refresh(token, keyword(any)) :: { :ok, uuid } | { :error, String.t } def refresh(token, options \\ []) do options = Gobstopper.API.defaults(options) GenServer.call(options[:server].(@service), { :refresh, token }, options[:timeout]) end @doc """ Get the state of all credentials an identity could be associated with. Returns all the credentials presentable state if successful. Otherwise returns an error. """ @spec all_credentials(token, keyword(any)) :: { :ok, [{ atom, { :unverified | :verified, String.t } | { :none, nil } }] } | { :error, String.t } def all_credentials(token, options \\ []) do options = Gobstopper.API.defaults(options) GenServer.call(options[:server].(@service), { :all_credentials, token }, options[:timeout]) end end
32
148
0.623016
79fb3416919f721b1b7518ed41036ec7f4e13799
1,090
exs
Elixir
clients/firebase_dynamic_links/test/test_helper.exs
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/firebase_dynamic_links/test/test_helper.exs
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/firebase_dynamic_links/test/test_helper.exs
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "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. ExUnit.start() defmodule GoogleApi.FirebaseDynamicLinks.TestHelper do defmacro __using__(opts) do quote do use ExUnit.Case, unquote(opts) import GoogleApi.FirebaseDynamicLinks.TestHelper end end def for_scope(scopes) when is_list(scopes), do: for_scope(Enum.join(scopes, " ")) def for_scope(scope) do {:ok, token} = Goth.Token.for_scope(scope) token.token end end
30.277778
83
0.744954
79fb42a0fae56368ed4d807adc64223f4978f726
1,445
exs
Elixir
mix.exs
fenollp/excoveralls
a9fc2410397ac6391d58d2c5436141e644c3d733
[ "MIT" ]
null
null
null
mix.exs
fenollp/excoveralls
a9fc2410397ac6391d58d2c5436141e644c3d733
[ "MIT" ]
null
null
null
mix.exs
fenollp/excoveralls
a9fc2410397ac6391d58d2c5436141e644c3d733
[ "MIT" ]
null
null
null
defmodule ExCoveralls.Mixfile do use Mix.Project def project do [ app: :excoveralls, version: "0.9.2", elixir: "~> 1.3", elixirc_paths: elixirc_paths(Mix.env()), deps: deps(), description: description(), package: package(), test_coverage: [tool: ExCoveralls], preferred_cli_env: cli_env_for(:test, [ "coveralls", "coveralls.detail", "coveralls.html", "coveralls.json", "coveralls.post", ]) ] end defp cli_env_for(env, tasks) do Enum.reduce(tasks, [], fn(key, acc) -> Keyword.put(acc, :"#{key}", env) end) end # Configuration for the OTP application def application do [] end # Specifies which paths to compile per environment. defp elixirc_paths(:test), do: ["lib", "test/fixtures/test_missing.ex"] defp elixirc_paths(_), do: ["lib"] # Returns the list of dependencies in the format: # { :foobar, "~> 0.1", git: "https://github.com/elixir-lang/foobar.git" } def deps do [ {:mock, "~> 0.2.1", only: :test}, {:meck, "~> 0.8.9", only: :test}, {:jason, "~> 1.0"}, {:hackney, ">= 0.12.0"}, {:ex_doc, ">= 0.0.0", only: :dev} ] end defp description do """ Coverage report tool for Elixir with coveralls.io integration. """ end defp package do [ maintainers: ["parroty"], licenses: ["MIT"], links: %{"GitHub" => "https://github.com/parroty/excoveralls"} ] end end
25.803571
94
0.590311
79fb5643aca887df140dac13a6640d6c0b81b64f
3,256
ex
Elixir
lib/honeybadger/notice.ex
abstractcoder/honeybadger-elixir
4917909d8735457d472400c5515a4d0075bff265
[ "MIT" ]
null
null
null
lib/honeybadger/notice.ex
abstractcoder/honeybadger-elixir
4917909d8735457d472400c5515a4d0075bff265
[ "MIT" ]
null
null
null
lib/honeybadger/notice.ex
abstractcoder/honeybadger-elixir
4917909d8735457d472400c5515a4d0075bff265
[ "MIT" ]
null
null
null
defmodule Honeybadger.Notice do @doc false alias Honeybadger.{Backtrace, Utils} alias Honeybadger.Breadcrumbs.{Collector} @type error :: %{ backtrace: list, class: atom | iodata, fingerprint: String.t(), message: iodata, tags: list } @type notifier :: %{name: String.t(), url: String.t(), version: String.t()} @type server :: %{ environment_name: atom, hostname: String.t(), project_root: Path.t(), revision: String.t() } @type noticeable :: Exception.t() | String.t() | map() | atom() @type t :: %__MODULE__{ notifier: notifier(), server: server(), error: error(), breadcrumbs: Collector.t(), request: map() } @url get_in(Honeybadger.Mixfile.project(), [:package, :links, "GitHub"]) @version Honeybadger.Mixfile.project()[:version] @notifier %{name: "honeybadger-elixir", language: "elixir", url: @url, version: @version} @derive Jason.Encoder @enforce_keys [:breadcrumbs, :notifier, :server, :error, :request] defstruct [:breadcrumbs, :notifier, :server, :error, :request] @spec new(noticeable(), map(), list(), String.t()) :: t() def new(error, metadata, stacktrace, fingerprint \\ "") def new(message, metadata, stacktrace, fingerprint) when is_binary(message) and is_map(metadata) and is_list(stacktrace) do new(%RuntimeError{message: message}, metadata, stacktrace, fingerprint) end def new(%{class: exception_name, message: message}, metadata, stacktrace, fingerprint) when is_map(metadata) and is_list(stacktrace) do new(exception_name, message, metadata, stacktrace, fingerprint) end def new(exception, metadata, stacktrace, fingerprint) when is_map(metadata) and is_list(stacktrace) do {exception, stacktrace} = Exception.blame(:error, exception, stacktrace) %{__struct__: exception_mod} = exception class = Utils.module_to_string(exception_mod) message = exception_mod.message(exception) new(class, message, metadata, stacktrace, fingerprint) end # bundles exception (or pseudo exception) information in to notice defp new(class, message, metadata, stacktrace, fingerprint) do message = if message, do: IO.iodata_to_binary(message), else: nil error = %{ class: class, message: message, backtrace: Backtrace.from_stacktrace(stacktrace), tags: Map.get(metadata, :tags, []), fingerprint: fingerprint } request = metadata |> Map.get(:plug_env, %{}) |> Map.put(:context, Map.get(metadata, :context, %{})) filter(%__MODULE__{ breadcrumbs: Map.get(metadata, :breadcrumbs, %{}), error: error, request: request, notifier: @notifier, server: server() }) end defp filter(notice) do case Honeybadger.get_env(:notice_filter) do nil -> notice notice_filter -> notice_filter.filter(notice) end end defp server do %{ environment_name: Honeybadger.get_env(:environment_name), hostname: Honeybadger.get_env(:hostname), project_root: Honeybadger.get_env(:project_root), revision: Honeybadger.get_env(:revision) } end end
29.87156
91
0.648034
79fb9c84065aa8e25d7c343506344924df4ed9e1
2,347
exs
Elixir
test/build_test.exs
eksperimental/buildable
cf6be3dee76bf6dab39517b58bfa5de441b05427
[ "MIT" ]
9
2021-01-02T07:29:14.000Z
2021-12-20T01:34:34.000Z
test/build_test.exs
eksperimental/buildable
cf6be3dee76bf6dab39517b58bfa5de441b05427
[ "MIT" ]
null
null
null
test/build_test.exs
eksperimental/buildable
cf6be3dee76bf6dab39517b58bfa5de441b05427
[ "MIT" ]
2
2021-11-07T19:42:31.000Z
2021-11-07T19:43:02.000Z
defmodule BuildTest do use ExUnit.Case doctest Build setup_all _ do %{ foo: %{__struct__: Foo, map: %{a: 2, b: 4, c: 6}}, map: %{a: 2, b: 4, c: 6} } end test "extract", %{foo: foo, map: map} do assert Build.extract(foo) == Build.extract(foo, :first) assert Build.extract(foo, :first) == {:ok, {:a, 2}, %{__struct__: Foo, map: %{b: 4, c: 6}}} assert Build.extract(foo, :last) == {:ok, {:c, 6}, %{__struct__: Foo, map: %{a: 2, b: 4}}} assert Build.extract(map) == {:ok, {:a, 2}, %{b: 4, c: 6}} end test "insert", %{foo: foo} do assert Build.insert(foo, {:d, 8}) == %{__struct__: Foo, map: %{a: 2, b: 4, c: 6, d: 8}} assert Build.insert(foo, {:d, 8}) == %{__struct__: Foo, map: %{a: 2, b: 4, c: 6, d: 8}} end test "into/2", %{foo: foo} do assert Build.into([], 1..5) == [1, 2, 3, 4, 5] assert Build.into(%{}, a: 1, b: 2) == %{a: 1, b: 2} assert Build.into(%{c: 3}, a: 1, b: 2) == %{a: 1, b: 2, c: 3} assert Build.into([], %{a: 1, b: 2}) == [a: 1, b: 2] assert Build.into([], 1..3) == [1, 2, 3] assert Build.into("", ["H", "i"]) == "Hi" assert Build.into(foo, a: 1, b: 2, x: 100) == %{ __struct__: Foo, map: %{a: 1, b: 2, c: 6, x: 100} } end test "into/3", %{foo: foo} do assert Build.into(%Foo{}, [a: 1, b: 2, c: 3], fn {k, v} -> {k, v * 2} end) == %{__struct__: Foo, map: %{a: 2, b: 4, c: 6}} assert Build.into(%Foo{}, [a: 1, b: 2, c: 3], fn {k, v} -> {k, v * 2} end) == %{__struct__: Foo, map: %{a: 2, b: 4, c: 6}} assert Build.into([], 1..5, fn x -> x * 2 end) == [2, 4, 6, 8, 10] assert Build.into("numbers: ", 1..3, &to_string/1) == "numbers: 123" assert Build.into([], [1, 2, 3], fn x -> x * 2 end) == [2, 4, 6] assert Build.into("numbers: ", [1, 2, 3], &to_string/1) == "numbers: 123" assert_raise FunctionClauseError, fn -> Build.into(%{a: 1}, [2, 3], & &1) assert Build.into(foo, a: 1, b: 2, x: 100) == Build.into(foo, [a: 1, b: 2, x: 100], & &1) end end test "reduce/3", %{foo: foo} do # here we rely delegate to the implementation of Enumerable.Foo assert Build.reduce(foo, Foo.empty(), &Build.insert(&2, &1)) == foo end test "to_empty", %{foo: foo} do assert Build.to_empty(foo, []) == %Foo{} end end
34.514706
95
0.49297
79fbd9ee0fcae5c697696b0125d918cbd990d01b
4,934
exs
Elixir
test/sanbase_web/graphql/comments/wallet_hunters_proposal_comments_api_test.exs
rmoorman/sanbase2
226784ab43a24219e7332c49156b198d09a6dd85
[ "MIT" ]
1
2022-01-30T19:51:39.000Z
2022-01-30T19:51:39.000Z
test/sanbase_web/graphql/comments/wallet_hunters_proposal_comments_api_test.exs
rmoorman/sanbase2
226784ab43a24219e7332c49156b198d09a6dd85
[ "MIT" ]
null
null
null
test/sanbase_web/graphql/comments/wallet_hunters_proposal_comments_api_test.exs
rmoorman/sanbase2
226784ab43a24219e7332c49156b198d09a6dd85
[ "MIT" ]
null
null
null
defmodule SanbaseWeb.Graphql.WalletHuntersProposalCommentsApiTest do use SanbaseWeb.ConnCase, async: false import Sanbase.Factory import Sanbase.TestHelpers import SanbaseWeb.Graphql.TestHelpers import Sanbase.CommentsApiHelper alias Sanbase.WalletHunters.Proposal @opts [entity_type: :wallet_hunters_proposal, extra_fields: ["proposalId"]] setup do clean_task_supervisor_children() user = insert(:user) proposal = insert(:wallet_hunters_proposal, proposal_id: 2, user: user, hunter_address: "0x26caae548b7cecf98da12ccaaa633d6d140447aa", transaction_id: "0x2" ) conn = setup_jwt_auth(build_conn(), user) %{conn: conn, user: user, proposal: proposal} end test "commentsCount on a wallet hunters proposal", context do %{conn: conn, proposal: proposal} = context # Mock to avoid a parity call Sanbase.Mock.prepare_mock2(&Proposal.fetch_by_proposal_id/1, {:ok, proposal}) |> Sanbase.Mock.run_with_mocks(fn -> assert comments_count(conn, proposal.id) == 0 create_comment(conn, proposal.id, "some content", @opts) assert comments_count(conn, proposal.id) == 1 create_comment(conn, proposal.id, "some content", @opts) create_comment(conn, proposal.id, "some content", @opts) create_comment(conn, proposal.id, "some content", @opts) assert comments_count(conn, proposal.id) == 4 create_comment(conn, proposal.id, "some content", @opts) assert comments_count(conn, proposal.id) == 5 end) end test "comment a wallet hunters proposal", context do %{proposal: proposal, conn: conn, user: user} = context other_user_conn = setup_jwt_auth(build_conn(), insert(:user)) content = "nice proposal" comment = create_comment(conn, proposal.id, content, @opts) comments = get_comments(other_user_conn, proposal.id, @opts) assert comment["proposalId"] |> Sanbase.Math.to_integer() == proposal.id assert comment["content"] == content assert comment["insertedAt"] != nil assert comment["editedAt"] == nil assert comment["user"]["email"] == user.email assert length(comments) == 1 assert comments |> List.first() |> Map.get("id") == comment["id"] assert comments |> hd() |> get_in(["user", "email"]) == "<email hidden>" end test "update a comment", context do %{conn: conn, proposal: proposal} = context content = "nice proposal" new_content = "updated content" comment = create_comment(conn, proposal.id, content, @opts) updated_comment = update_comment(conn, comment["id"], new_content, @opts) comments = get_comments(conn, proposal.id, @opts) assert comment["editedAt"] == nil assert updated_comment["editedAt"] != nil edited_at = NaiveDateTime.from_iso8601!(updated_comment["editedAt"]) assert Sanbase.TestUtils.datetime_close_to(edited_at, Timex.now(), 1, :seconds) == true assert comment["content"] == content assert updated_comment["content"] == new_content assert length(comments) == 1 assert comments |> List.first() |> Map.get("content") == new_content end test "delete a comment", context do %{conn: conn, proposal: proposal} = context fallback_user = insert(:insights_fallback_user) content = "nice proposal" comment = create_comment(conn, proposal.id, content, @opts) delete_comment(conn, comment["id"], @opts) comments = get_comments(conn, proposal.id, @opts) proposal_comment = comments |> List.first() assert proposal_comment["user"]["id"] != comment["user"]["id"] assert proposal_comment["user"]["id"] |> Sanbase.Math.to_integer() == fallback_user.id assert proposal_comment["content"] != comment["content"] assert proposal_comment["content"] =~ "deleted" end test "create a subcomment", context do %{conn: conn, proposal: proposal} = context c1 = create_comment(conn, proposal.id, "some content", @opts) opts = Keyword.put(@opts, :parent_id, c1["id"]) c2 = create_comment(conn, proposal.id, "other content", opts) opts = Keyword.put(@opts, :parent_id, c2["id"]) create_comment(conn, proposal.id, "other content2", opts) [comment, subcomment1, subcomment2] = get_comments(conn, proposal.id, @opts) |> Enum.sort_by(& &1["id"]) assert comment["parentId"] == nil assert comment["rootParentId"] == nil assert subcomment1["parentId"] == comment["id"] assert subcomment1["rootParentId"] == comment["id"] assert subcomment2["parentId"] == subcomment1["id"] assert subcomment2["rootParentId"] == comment["id"] end defp comments_count(conn, post_id) do query = """ { walletHuntersProposal(id: #{post_id}) { commentsCount } } """ conn |> post("/graphql", query_skeleton(query)) |> json_response(200) |> get_in(["data", "walletHuntersProposal", "commentsCount"]) end end
33.564626
91
0.67653
79fbeef8453581021ae6c6111fa56e817ea38b28
493
ex
Elixir
lib/telepath_web/views/error_view.ex
jdangerx/telepath
75314db05dd97ea86b5a828ab673fed33ecad5e1
[ "MIT" ]
null
null
null
lib/telepath_web/views/error_view.ex
jdangerx/telepath
75314db05dd97ea86b5a828ab673fed33ecad5e1
[ "MIT" ]
null
null
null
lib/telepath_web/views/error_view.ex
jdangerx/telepath
75314db05dd97ea86b5a828ab673fed33ecad5e1
[ "MIT" ]
null
null
null
defmodule TelepathWeb.ErrorView do use TelepathWeb, :view # If you want to customize a particular status code # for a certain format, you may uncomment below. # def render("500.html", _assigns) do # "Internal Server Error" # end # By default, Phoenix returns the status message from # the template name. For example, "404.html" becomes # "Not Found". def template_not_found(template, _assigns) do Phoenix.Controller.status_message_from_template(template) end end
29
61
0.736308
79fc1dec2a77ac3e45132beadc9e78e0e9d54cfa
2,339
exs
Elixir
exercises/concept/freelancer-rates/test/freelancer_rates_test.exs
devtayls/elixir
67824de8209ff1b6ed2f736deedfb5bd815130ca
[ "MIT" ]
1
2020-04-06T19:41:50.000Z
2020-04-06T19:41:50.000Z
exercises/concept/freelancer-rates/test/freelancer_rates_test.exs
devtayls/elixir
67824de8209ff1b6ed2f736deedfb5bd815130ca
[ "MIT" ]
null
null
null
exercises/concept/freelancer-rates/test/freelancer_rates_test.exs
devtayls/elixir
67824de8209ff1b6ed2f736deedfb5bd815130ca
[ "MIT" ]
1
2021-03-15T11:02:40.000Z
2021-03-15T11:02:40.000Z
defmodule FreelancerRatesTest do use ExUnit.Case describe "daily_rate/1" do @tag task_id: 1 test "it's the hourly_rate times 8" do assert FreelancerRates.daily_rate(50) == 400.0 end @tag task_id: 1 test "it always returns a float" do assert FreelancerRates.daily_rate(60) === 480.0 end @tag task_id: 1 test "it does not round" do assert FreelancerRates.daily_rate(55.1) == 440.8 end end describe "apply_discount" do @tag task_id: 2 test "a discount of 10% leaves 90% of the original price" do assert FreelancerRates.apply_discount(140.0, 10) == 126.0 end @tag task_id: 2 test "it always returns a float" do assert FreelancerRates.apply_discount(100, 10) == 90.0 end @tag task_id: 2 test "it doesn't round" do assert_in_delta FreelancerRates.apply_discount(111.11, 13.5), 96.11015, 0.000001 end end describe "monthly_rate/1" do @tag task_id: 3 test "it's the daily_rate times 22" do assert FreelancerRates.monthly_rate(62, 0.0) == 10_912 end @tag task_id: 3 test "it always returns an integer" do assert FreelancerRates.monthly_rate(70, 0.0) === 12_320 end @tag task_id: 3 test "the result is rounded up" do # 11_052.8 assert FreelancerRates.monthly_rate(62.8, 0.0) == 11_053 # 11_475.2 assert FreelancerRates.monthly_rate(65.2, 0.0) == 11_476 end @tag task_id: 3 test "gives a discount" do # 11_792 - 12% * 11_792 = 10_376.96 assert FreelancerRates.monthly_rate(67, 12.0) == 10_377 end end describe "days_in_budget/3" do @tag task_id: 4 test "it's the budget divided by the daily rate" do assert FreelancerRates.days_in_budget(1_600, 50, 0.0) == 4 end @tag task_id: 4 test "it always returns a float" do assert FreelancerRates.days_in_budget(520, 65, 0.0) === 1.0 end @tag task_id: 4 test "it rounds down to one decimal place" do # 10.02273 assert FreelancerRates.days_in_budget(4_410, 55, 0.0) == 10.0 # 10.18182 assert FreelancerRates.days_in_budget(4_480, 55, 0.0) == 10.1 end @tag task_id: 4 test "it applies the discount" do # 1.25 assert FreelancerRates.days_in_budget(480, 60, 20) == 1.2 end end end
25.988889
86
0.645575
79fc3ccf4f0f59cce2bd47d14dc4d566090d6d33
8,248
ex
Elixir
lib/dart_sass.ex
dominicletz/dart_sass
e2f486686750ac528a261c68ff9bbcece243fe26
[ "MIT" ]
null
null
null
lib/dart_sass.ex
dominicletz/dart_sass
e2f486686750ac528a261c68ff9bbcece243fe26
[ "MIT" ]
null
null
null
lib/dart_sass.ex
dominicletz/dart_sass
e2f486686750ac528a261c68ff9bbcece243fe26
[ "MIT" ]
null
null
null
defmodule DartSass do @moduledoc """ DartSass is a installer and runner for [sass](https://sass-lang.com/dart-sass). ## Profiles You can define multiple dart_sass profiles. By default, there is a profile called `:default` which you can configure its args, current directory and environment: config :dart_sass, version: "1.39.0", default: [ args: ~w(css/app.scss ../priv/static/assets/app.css), cd: Path.expand("../assets", __DIR__) ] """ use Application require Logger @doc false def start(_, _) do unless Application.get_env(:dart_sass, :version) do Logger.warn(""" dart_sass version is not configured. Please set it in your config files: config :dart_sass, :version, "#{latest_version()}" """) end configured_version = configured_version() case bin_version() do {:ok, ^configured_version} -> :ok {:ok, version} -> Logger.warn(""" Outdated dart-sass version. Expected #{configured_version}, got #{version}. \ Please run `mix sass.install` or update the version in your config files.\ """) :error -> :ok end Supervisor.start_link([], strategy: :one_for_one) end @doc false # Latest known version at the time of publishing. def latest_version do "1.39.0" end @doc """ Returns the configured dart-sass version. """ def configured_version do Application.get_env(:dart_sass, :version, latest_version()) end @doc """ Returns the configuration for the given profile. Returns nil if the profile does not exist. """ def config_for!(profile) when is_atom(profile) do Application.get_env(:dart_sass, profile) || raise ArgumentError, """ unknown dart_sass profile. Make sure the profile is defined in your config files, such as: config :dart_sass, #{profile}: [ args: ~w(css/app.scss ../priv/static/assets/app.css), cd: Path.expand("../assets", __DIR__) ] """ end @doc """ Checks whether or not dart-sass is installed. """ def installed? do case bin_paths() do {sass, nil} -> File.exists?(sass) {vm, snapshot} -> File.exists?(vm) and File.exists?(snapshot) end end @doc """ Returns the path to the executable and optional snapshot. Depending on your environment, sass may be invoked through a portable instance of the Dart VM. In such case, this function will return a tuple of `{Dart, Snapshot}`, otherwise it will return `{Sass, Nil}`. """ def bin_paths do case :os.type() do {:unix, :darwin} -> {vm_path(), snapshot_path()} {:win32, _} -> {vm_path(), snapshot_path()} _ -> {sass_path(), nil} end end @doc false def sass_path() do Path.join(Path.dirname(Mix.Project.build_path()), "sass") end @doc false def snapshot_path do Path.join(Path.dirname(Mix.Project.build_path()), "sass.snapshot") end @doc false def vm_path do Path.join(Path.dirname(Mix.Project.build_path()), "dart") end # TODO: Remove when dart-sass will exit when stdin is closed. @doc false def script_path() do Path.join(:code.priv_dir(:dart_sass), "dart_sass.bash") end @doc """ Returns the version of the dart_sass executable. Returns `{:ok, version_string}` on success or `:error` when the executable is not available. """ def bin_version do {path, args} = sass(["--version"]) with true <- File.exists?(path), {result, 0} <- System.cmd(path, args) do {:ok, String.trim(result)} else _ -> :error end end defp sass(args) do {path, args} = case bin_paths() do {sass, nil} -> {sass, args} {vm, snapshot} -> {vm, [snapshot] ++ args} end # TODO: Remove when dart-sass will exit when stdin is closed. # Link: https://github.com/sass/dart-sass/pull/1411 cond do "--watch" in args and not match?({:win32, _}, :os.type()) -> {script_path(), [path] ++ args} true -> {path, args} end end @doc """ Runs the given command with `args`. The given args will be appended to the configured args. The task output will be streamed directly to stdio. It returns the status of the underlying call. """ def run(profile, extra_args) when is_atom(profile) and is_list(extra_args) do config = config_for!(profile) args = config[:args] || [] opts = [ cd: config[:cd] || File.cwd!(), env: config[:env] || %{}, into: IO.stream(:stdio, :line), stderr_to_stdout: true ] {path, args} = sass(args ++ extra_args) path |> System.cmd(args, opts) |> elem(1) end @doc """ Installs, if not available, and then runs `sass`. Returns the same as `run/2`. """ def install_and_run(profile, args) do unless installed?() do install() end run(profile, args) end @doc """ Installs dart-sass with `configured_version/0`. """ def install do version = configured_version() tmp_dir = Path.join(System.tmp_dir!(), "cs-dart-sass") File.rm_rf!(tmp_dir) File.mkdir_p!(tmp_dir) name = "dart-sass-#{version}-#{target()}" url = "https://github.com/sass/dart-sass/releases/download/#{version}/#{name}" archive = fetch_body!(url) case unpack_archive(Path.extname(name), archive, tmp_dir) do :ok -> :ok other -> raise "couldn't unpack archive: #{inspect(other)}" end sass_path = sass_path() snapshot_path = snapshot_path() vm_path = vm_path() case :os.type() do {:win32, _} -> File.cp!(Path.join([tmp_dir, "dart-sass", "src", "dart.exe"]), vm_path) File.cp!(Path.join([tmp_dir, "dart-sass", "src", "sass.snapshot"]), snapshot_path) {:unix, :darwin} -> File.cp!(Path.join([tmp_dir, "dart-sass", "src", "dart"]), vm_path) File.cp!(Path.join([tmp_dir, "dart-sass", "src", "sass.snapshot"]), snapshot_path) _ -> File.cp!(Path.join([tmp_dir, "dart-sass", "sass"]), sass_path) end end defp unpack_archive(".zip", zip, cwd) do with {:ok, _} <- :zip.unzip(zip, cwd: to_charlist(cwd)), do: :ok end defp unpack_archive(_, tar, cwd) do :erl_tar.extract({:binary, tar}, [:compressed, cwd: to_charlist(cwd)]) end # Available targets: https://github.com/sass/dart-sass/releases defp target do case :os.type() do {:win32, _} -> case :erlang.system_info(:wordsize) * 8 do 32 -> "windows-ia32.zip" 64 -> "windows-x64.zip" end {:unix, osname} -> arch_str = :erlang.system_info(:system_architecture) [arch | _] = arch_str |> List.to_string() |> String.split("-") osname = if osname == :darwin, do: :macos, else: osname case arch do "amd64" -> "#{osname}-x64.tar.gz" "x86_64" -> "#{osname}-x64.tar.gz" _ -> raise "could not download dart_sass for architecture: #{arch_str}" end end end defp fetch_body!(url) do url = String.to_charlist(url) Logger.debug("Downloading dart-sass from #{url}") {:ok, _} = Application.ensure_all_started(:inets) {:ok, _} = Application.ensure_all_started(:ssl) # https://erlef.github.io/security-wg/secure_coding_and_deployment_hardening/inets cacertfile = CAStore.file_path() |> String.to_charlist() http_options = [ autoredirect: false, ssl: [ verify: :verify_peer, cacertfile: cacertfile, depth: 2, customize_hostname_check: [ match_fun: :public_key.pkix_verify_hostname_match_fun(:https) ] ] ] case :httpc.request(:get, {url, []}, http_options, []) do {:ok, {{_, 302, _}, headers, _}} -> {'location', download} = List.keyfind(headers, 'location', 0) options = [body_format: :binary] case :httpc.request(:get, {download, []}, http_options, options) do {:ok, {{_, 200, _}, _, body}} -> body other -> raise "couldn't fetch #{download}: #{inspect(other)}" end other -> raise "couldn't fetch #{url}: #{inspect(other)}" end end end
26.779221
96
0.603904
79fc3e75e56e4ce526e034db6c83d1c0b9eeab01
1,708
ex
Elixir
lib/spelt/application.ex
jec/spelt
b6e5070226b646e1eb5dfc28453db7e7bf5030d9
[ "BSD-3-Clause" ]
null
null
null
lib/spelt/application.ex
jec/spelt
b6e5070226b646e1eb5dfc28453db7e7bf5030d9
[ "BSD-3-Clause" ]
null
null
null
lib/spelt/application.ex
jec/spelt
b6e5070226b646e1eb5dfc28453db7e7bf5030d9
[ "BSD-3-Clause" ]
null
null
null
defmodule Spelt.Application do # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications @moduledoc false use Application def start(_type, _args) do # Load Vapor config. providers = [ %Vapor.Provider.File{path: "config/#{Mix.env()}.yaml", bindings: [db: "db", jwt: "jwt"]} ] vapor_config = Vapor.load!(providers) # Set config for Spelt.Repo. neo4j_config = [ url: vapor_config.db["url"], basic_auth: [username: vapor_config.db["username"], password: vapor_config.db["password"]], pool_size: vapor_config.db["pool_size"] ] Application.put_env(:spelt, Spelt.Repo, neo4j_config) # Set config for Joken. joken_config = [ signer_alg: vapor_config.jwt["algorithm"], key_pem: vapor_config.jwt["key"] ] Application.put_env(:joken, :default, joken_config) children = [ # Start the Telemetry supervisor SpeltWeb.Telemetry, # Start the PubSub system {Phoenix.PubSub, name: Spelt.PubSub}, # Start the Neo4j repo Spelt.Repo, {Bolt.Sips, neo4j_config}, # Start the Endpoint (http/https) SpeltWeb.Endpoint # Start a worker by calling: Spelt.Worker.start_link(arg) # {Spelt.Worker, arg} ] # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: Spelt.Supervisor] Supervisor.start_link(children, opts) end # Tell Phoenix to update the endpoint configuration # whenever the application is updated. def config_change(changed, _new, removed) do SpeltWeb.Endpoint.config_change(changed, removed) :ok end end
28.466667
97
0.669789
79fc591e05591be80b9b279282eba17ee7e4d990
2,832
ex
Elixir
lib/rummage_phoenix/view.ex
glasnoster/rummage_phoenix
4818a096b19ccdd60ae195ddf992728396a08a24
[ "MIT" ]
null
null
null
lib/rummage_phoenix/view.ex
glasnoster/rummage_phoenix
4818a096b19ccdd60ae195ddf992728396a08a24
[ "MIT" ]
null
null
null
lib/rummage_phoenix/view.ex
glasnoster/rummage_phoenix
4818a096b19ccdd60ae195ddf992728396a08a24
[ "MIT" ]
null
null
null
defmodule Rummage.Phoenix.View do @moduledoc """ View Module for Rummage. This has view helpers that can generate rummagable links and forms. Usage: ```elixir defmodule MyApp.ProductView do use MyApp.Web, :view use Rummage.Phoenix.View end ``` """ @doc """ This macro includes the helpers functions from different Rummage.Phoenix.Views """ defmacro __using__(opts) do quote do require Rummage.Phoenix.{PaginateView, SearchView, SortView, ViewResolver} alias Rummage.Phoenix.{PaginateView, SearchView, SortView, ViewResolver} def pagination_link(conn, rummage, opts \\ []) do PaginateView.pagination_link(conn, rummage, opts ++ [struct: struct(), helpers: helpers()]) end # TODO: This doesn't scale well. def pagination_with_all_link(conn, rummage, opts \\ []) do PaginateView.pagination_with_all_link(conn, rummage, opts ++ [struct: struct(), helpers: helpers()]) end def sort_link(conn, rummage, field) do sort_link(conn, rummage, field, Phoenix.Naming.humanize(field), []) end def sort_link(conn, rummage, field, name) when is_binary(name) do sort_link(conn, rummage, field, name, []) end def sort_link(conn, rummage, field, opts) when is_list(opts) do sort_link(conn, rummage, field, Phoenix.Naming.humanize(field), opts) end def sort_link(conn, rummage, field, name, opts) do SortView.sort_link(conn, rummage, field, name, opts ++ [struct: struct(), helpers: helpers()]) end def search_form(conn, rummage, link_params, opts \\ []) do SearchView.search_form(conn, rummage, link_params, opts ++ [struct: struct(), helpers: helpers()]) end defp helpers do helpers = unquote(opts[:helpers]) || Rummage.Phoenix.default_helpers || ViewResolver.make_helpers_name_from_topmost_namespace(__MODULE__) unless Code.ensure_compiled?(helpers) do raise """ #{helpers} is undefined, please provide an explicit router to the View with: `use Rummage.Phoenix.View, helpers: MyApp.Web.Router.Helpers`" or through a config: config :rummage_phoenix, Rummage.Phoenix, [ default_helpers: MyApp.Web.Router.Helpers, ] """ end helpers end defp struct do struct = unquote(opts[:struct]) || ViewResolver.make_struct_name_from_bottommost_namespace(__MODULE__) helpers = helpers() unless function_exported?(helpers, String.to_atom("#{struct}_path"), 2) do raise "#{struct}_path is undefined, please provide an explicit struct to the View with: `use Rummage.Phoenix.View, struct: \"some_model\"" end struct end end end end
32.181818
148
0.650777
79fc96cf43ba46daa5354c61bee522f1bc01ed57
2,167
ex
Elixir
aax_test_set/aam_aad_sets.ex
XCaminhante/tutoriais-e-exemplos
a7dc1df8ad1a7a7c04353dfa2eb2b2561704babb
[ "Unlicense" ]
15
2017-11-09T23:58:05.000Z
2021-07-03T14:28:07.000Z
aax_test_set/aam_aad_sets.ex
XCaminhante/tutoriais-e-exemplos
a7dc1df8ad1a7a7c04353dfa2eb2b2561704babb
[ "Unlicense" ]
5
2020-04-05T23:17:38.000Z
2021-02-07T14:27:00.000Z
aax_test_set/aam_aad_sets.ex
XCaminhante/tutoriais-e-exemplos
a7dc1df8ad1a7a7c04353dfa2eb2b2561704babb
[ "Unlicense" ]
2
2018-03-26T19:26:18.000Z
2020-06-05T02:06:31.000Z
namespace aax_test_set include std/math.e /* AAM-AAD-J[N]?[PS]-based set-selector brutefinder (???) */ -- Resultset fields enum X, Y, JTYPE function test_solution (sequence xy, sequence a_set, sequence what_set, sequence words) integer found = 1 for k = 2 to length(a_set) do if and_bits(xor_bits(a_set[k], what_set[k]),1) != and_bits(xor_bits(a_set[1], what_set[1]),1) then found = 0 exit end if end for if found then if and_bits(xor_bits(a_set[1], what_set[1]),1) then xy &= {words[1]} else xy &= {words[2]} end if return xy[$] end if return 0 end function function find_solutions (sequence bytes, sequence what_set) integer al, ah sequence p = repeat(0, length(bytes)), s = repeat(0, length(bytes)), functional_solutions = {} object ret for x = 1 to 255 do for y = 0 to 255 do for k = 1 to length(bytes) do p[k] = 0 al = remainder(bytes[k], x) ah = floor(bytes[k] / x) al = remainder(al+ah*y, 256) ah = 0 if al < 0x80 then s[k]=0 else s[k]=1 end if while al do p[k] += remainder(al,2) al = shift_bits(al,1) end while end for ret = test_solution ({x,y}, p, what_set, {"JNP", "JP"}) if sequence(ret) then functional_solutions &= {{x,y,ret}} end if ret = test_solution ({x,y}, s, what_set, {"JNS", "JS"}) if sequence(ret) then functional_solutions &= {{x,y,ret}} end if end for end for return functional_solutions end function procedure show_solutions (sequence solutions) for a = 1 to length(solutions) do printf(1, "X=%d Y=%d using %s\n", { solutions[a][X], solutions[a][Y], solutions[a][JTYPE] }) end for end procedure sequence input_values = {0x01, 0x03, 0x25, 0x39, 0xB3, 0x78, 0xC4, 0x6B, 0xA6, 0x12, 0xF0}, resultset = {1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1}, instructions = find_solutions(input_values, resultset) show_solutions(instructions)
28.893333
87
0.562529
79fca47a76436f87bd35f79889219679fafe487e
2,605
exs
Elixir
test/client_test.exs
mainframe2/postgrex
7c3312f69b6b787e7d1831eedff32be36c3ee953
[ "Apache-2.0" ]
null
null
null
test/client_test.exs
mainframe2/postgrex
7c3312f69b6b787e7d1831eedff32be36c3ee953
[ "Apache-2.0" ]
null
null
null
test/client_test.exs
mainframe2/postgrex
7c3312f69b6b787e7d1831eedff32be36c3ee953
[ "Apache-2.0" ]
null
null
null
defmodule ClientTest do use ExUnit.Case import Postgrex.TestHelper import ExUnit.CaptureLog setup do opts = [database: "postgrex_test", backoff_type: :stop] {:ok, pid} = Postgrex.start_link(opts) {:ok, [pid: pid, options: opts]} end test "active client timeout", context do conn = context[:pid] %Postgrex.Result{connection_id: connection_id} = Postgrex.query!(conn, "SELECT 42", []) Process.flag(:trap_exit, true) capture_log fn -> assert [[_]] = query("SELECT pg_stat_get_activity($1)", [connection_id]) assert_raise DBConnection.ConnectionError, "tcp recv: closed", fn() -> query("SELECT pg_sleep(10)", [], [timeout: 50]) end assert_receive {:EXIT, ^conn, {:shutdown, %DBConnection.ConnectionError{}}} end :timer.sleep(500) {:ok, pid} = Postgrex.start_link(context[:options]) assert %Postgrex.Result{rows: []} = Postgrex.query!(pid, "SELECT pg_stat_get_activity($1)", [connection_id]) end test "active client cancel", context do conn = context[:pid] :sys.suspend(conn) assert {:timeout, _} = catch_exit(query("SELECT 42", [], [pool_timeout: 0])) Process.flag(:trap_exit, true) :sys.resume(conn) assert [[42]] = query("SELECT 42", []) end test "active client DOWN", context do self_pid = self() conn = context[:pid] pid = spawn fn -> send self_pid, query("SELECT pg_sleep(0.2)", []) end :timer.sleep(100) Process.flag(:trap_exit, true) capture_log fn -> Process.exit(pid, :shutdown) assert_receive {:EXIT, ^conn, {:shutdown, %DBConnection.ConnectionError{}}} end end test "queued client cancel", context do self_pid = self() Enum.each(1..10, fn _ -> spawn_link fn -> send self_pid, query("SELECT pg_sleep(0.1)", []) end end) :sys.suspend(context[:pid]) assert {:timeout, _} = catch_exit(query("SELECT 42", [], [pool_timeout: 0])) :sys.resume(context[:pid]) assert [[42]] = query("SELECT 42", []) Enum.each(1..10, fn _ -> assert_received [[:void]] end) end test "queued client DOWN", context do self_pid = self() Enum.each(1..10, fn _ -> spawn_link fn -> send self_pid, query("SELECT pg_sleep(0.1)", []) end end) :sys.suspend(context[:pid]) pid = spawn fn -> send self_pid, query("SELECT 42", []) end :sys.resume(context[:pid]) Process.exit(pid, :shutdown) assert [[42]] = query("SELECT 42", []) Enum.each(1..10, fn _ -> assert_received [[:void]] end) end end
24.575472
91
0.609597