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
7374a466d820e6601bd666aceac8118aa7ea56d2
1,224
exs
Elixir
mix.exs
lkoller/open_graph
21e218b44dfabb10cd364c71f070da9d48a9a63c
[ "MIT" ]
null
null
null
mix.exs
lkoller/open_graph
21e218b44dfabb10cd364c71f070da9d48a9a63c
[ "MIT" ]
null
null
null
mix.exs
lkoller/open_graph
21e218b44dfabb10cd364c71f070da9d48a9a63c
[ "MIT" ]
null
null
null
defmodule OpenGraph.Mixfile do use Mix.Project def project do [ app: :open_graph, version: "0.0.3", elixir: "~> 1.8", build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, deps: deps(), description: description(), package: package() ] end # Configuration for the OTP application # # Type "mix help compile.app" for more information def application do [applications: [:httpoison, :logger]] end # Dependencies can be Hex packages: # # {:mydep, "~> 0.3.0"} # # Or git/path repositories: # # {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"} # # Type "mix help deps" for more examples and options defp deps do [ {:httpoison, "~> 1.5"}, {:ex_doc, "~> 0.11", only: :dev}, {:credo, "~> 0.10.0", only: [:dev, :test], runtime: false} ] end defp description do """ A Elixir wrapper for the Open Graph protocol. """ end defp package do [ maintainers: ["Andriel Nuernberg"], licenses: ["MIT"], links: %{"GitHub" => "https://github.com/andrielfn/open_graph"}, files: ~w(lib mix.exs README.md LICENSE) ] end end
21.857143
77
0.571895
7374b301cc48e50baa0f562a8bc0528a7dbc7fce
561
exs
Elixir
test/views/error_view_test.exs
silppuri/daily
a31034dedbcc2eb74bd2e07e703df836c5b3607f
[ "MIT" ]
null
null
null
test/views/error_view_test.exs
silppuri/daily
a31034dedbcc2eb74bd2e07e703df836c5b3607f
[ "MIT" ]
null
null
null
test/views/error_view_test.exs
silppuri/daily
a31034dedbcc2eb74bd2e07e703df836c5b3607f
[ "MIT" ]
1
2019-09-05T12:37:23.000Z
2019-09-05T12:37:23.000Z
defmodule Daily.ErrorViewTest do use DailyWeb.ConnCase, async: true # Bring render/3 and render_to_string/3 for testing custom views import Phoenix.View test "renders 404.html" do assert render_to_string(Daily.ErrorView, "404.html", []) == "Page not found" end test "render 500.html" do assert render_to_string(Daily.ErrorView, "500.html", []) == "Internal server error" end test "render any other" do assert render_to_string(Daily.ErrorView, "505.html", []) == "Internal server error" end end
25.5
66
0.672014
7374cc576eb721320c79edb53eeb5a9aaa357923
3,748
exs
Elixir
test/httpoison/retry_test.exs
everilae/httpoison_retry
aa11029bf7a7f0169d76ed8749ad7a8203ccaf7b
[ "MIT" ]
null
null
null
test/httpoison/retry_test.exs
everilae/httpoison_retry
aa11029bf7a7f0169d76ed8749ad7a8203ccaf7b
[ "MIT" ]
null
null
null
test/httpoison/retry_test.exs
everilae/httpoison_retry
aa11029bf7a7f0169d76ed8749ad7a8203ccaf7b
[ "MIT" ]
1
2019-12-29T05:32:23.000Z
2019-12-29T05:32:23.000Z
defmodule HTTPoison.RetryTest do use ExUnit.Case import HTTPoison.Retry doctest HTTPoison.Retry test "max_attempts" do {:ok, agent} = Agent.start fn -> 0 end request = fn -> Agent.update agent, fn(i) -> i + 1 end {:error, %HTTPoison.Error{id: nil, reason: :nxdomain}} end assert {:error, %HTTPoison.Error{id: nil, reason: :nxdomain}} = autoretry(request.(), max_attempts: 10) assert 10 = Agent.get(agent, &(&1)) end test "nxdomain errors" do {:ok, agent} = Agent.start fn -> 0 end request = fn -> Agent.update agent, fn(i) -> i + 1 end {:error, %HTTPoison.Error{id: nil, reason: :nxdomain}} end assert {:error, %HTTPoison.Error{id: nil, reason: :nxdomain}} = autoretry(request.()) assert 5 = Agent.get(agent, &(&1)) end test "500 errors" do {:ok, agent} = Agent.start fn -> 0 end request = fn -> Agent.update agent, fn(i) -> i + 1 end {:ok, %HTTPoison.Response{status_code: 500}} end assert {:ok, %HTTPoison.Response{status_code: 500}} = autoretry(request.()) assert 5 = Agent.get(agent, &(&1)) end test "errors other than nxdomain/timeout by default" do {:ok, agent} = Agent.start fn -> 0 end request = fn -> Agent.update agent, fn(i) -> i + 1 end {:error, %HTTPoison.Error{id: nil, reason: :other}} end assert {:error, %HTTPoison.Error{id: nil, reason: :other}} = autoretry(request.()) assert 1 = Agent.get(agent, &(&1)) end test "include other error types" do {:ok, agent} = Agent.start fn -> 0 end request = fn -> Agent.update agent, fn(i) -> i + 1 end {:error, %HTTPoison.Error{id: nil, reason: :other}} end assert {:error, %HTTPoison.Error{id: nil, reason: :other}} = autoretry(request.(), retry_unknown_errors: true) assert 5 = Agent.get(agent, &(&1)) end test "404s by default" do {:ok, agent} = Agent.start fn -> 0 end request = fn -> Agent.update agent, fn(i) -> i + 1 end {:ok, %HTTPoison.Response{status_code: 404}} end assert {:ok, %HTTPoison.Response{status_code: 404}} = autoretry(request.()) assert 1 = Agent.get(agent, &(&1)) end test "include 404s" do {:ok, agent} = Agent.start fn -> 0 end request = fn -> Agent.update agent, fn(i) -> i + 1 end {:ok, %HTTPoison.Response{status_code: 404}} end assert {:ok, %HTTPoison.Response{status_code: 404}} = autoretry(request.(), status_codes: [500, 404]) assert 5 = Agent.get(agent, &(&1)) end test "successful" do {:ok, agent} = Agent.start fn -> 0 end request = fn -> Agent.update agent, fn(i) -> i + 1 end {:ok, %HTTPoison.Response{status_code: 200}} end assert {:ok, %HTTPoison.Response{status_code: 200}} = autoretry(request.()) assert 1 = Agent.get(agent, &(&1)) end test "1 failure followed by 1 successful" do {:ok, agent} = Agent.start fn -> 0 end request = fn -> if Agent.get_and_update(agent, fn(i) -> {i + 1, i + 1} end) > 1 do {:ok, %HTTPoison.Response{status_code: 200}} else {:error, %HTTPoison.Error{id: nil, reason: :nxdomain}} end end assert {:ok, %HTTPoison.Response{status_code: 200}} = autoretry(request.()) assert 2 = Agent.get(agent, &(&1)) end test "4 failures followed by 1 successful" do {:ok, agent} = Agent.start fn -> 0 end request = fn -> if Agent.get_and_update(agent, fn(i) -> {i + 1, i + 1} end) > 4 do {:ok, %HTTPoison.Response{status_code: 200}} else {:error, %HTTPoison.Error{id: nil, reason: :nxdomain}} end end assert {:ok, %HTTPoison.Response{status_code: 200}} = autoretry(request.()) assert 5 = Agent.get(agent, &(&1)) end end
33.464286
114
0.60032
7374d29c3f8dc2e58f25fc50d320a50619b6650b
2,490
exs
Elixir
ros/ros_ui_station/config/prod.exs
kujua/elixir-handbook
4185ad8da7f652fdb59c799dc58bcb33fda10475
[ "Apache-2.0" ]
1
2019-07-01T18:47:28.000Z
2019-07-01T18:47:28.000Z
ros/ros_ui_station/config/prod.exs
kujua/elixir-handbook
4185ad8da7f652fdb59c799dc58bcb33fda10475
[ "Apache-2.0" ]
4
2020-07-17T16:57:18.000Z
2021-05-09T23:50:52.000Z
ros/ros_ui_station/config/prod.exs
kujua/elixir-handbook
4185ad8da7f652fdb59c799dc58bcb33fda10475
[ "Apache-2.0" ]
null
null
null
use Mix.Config # For production, don't forget to configure the url host # to something meaningful, Phoenix uses this information # when generating URLs. # # Note we also include the path to a cache manifest # containing the digested version of static files. This # manifest is generated by the `mix phx.digest` task, # which you should run after static files are built and # before starting your production server. config :ros_ui_station, Ros.StationWeb.Endpoint, http: [:inet6, port: System.get_env("PORT") || 5002], url: [host: "example.com", port: 80], cache_static_manifest: "priv/static/cache_manifest.json" # Do not print debug messages in production config :logger, level: :info # ## SSL Support # # To get SSL working, you will need to add the `https` key # to the previous section and set your `:url` port to 443: # # config :ros_ui_station, Ros.StationWeb.Endpoint, # ... # url: [host: "example.com", port: 443], # https: [ # :inet6, # port: 443, # cipher_suite: :strong, # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"), # certfile: System.get_env("SOME_APP_SSL_CERT_PATH") # ] # # The `cipher_suite` is set to `:strong` to support only the # latest and more secure SSL ciphers. This means old browsers # and clients may not be supported. You can set it to # `:compatible` for wider support. # # `:keyfile` and `:certfile` expect an absolute path to the key # and cert in disk or a relative path inside priv, for example # "priv/ssl/server.key". For all supported SSL configuration # options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1 # # We also recommend setting `force_ssl` in your endpoint, ensuring # no data is ever sent via http, always redirecting to https: # # config :ros_ui_station, Ros.StationWeb.Endpoint, # force_ssl: [hsts: true] # # Check `Plug.SSL` for all available options in `force_ssl`. # ## Using releases (distillery) # # 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 :ros_ui_station, Ros.StationWeb.Endpoint, server: true # # Note you can't rely on `System.get_env/1` when using releases. # See the releases documentation accordingly. # Finally import the config/prod.secret.exs which should be versioned # separately. import_config "prod.secret.exs"
34.583333
69
0.716466
7374e6a11bc21474471e43d67501401f7887f966
115
exs
Elixir
tests/examples/elixir/std/test.expected/app/user_test.exs
rogeriochaves/un
5825fffd560951c61294b39c3d52e220bf729a40
[ "MIT" ]
4
2020-07-24T06:56:01.000Z
2021-01-02T23:31:26.000Z
tests/examples/elixir/std/test.expected/app/user_test.exs
rogeriochaves/un
5825fffd560951c61294b39c3d52e220bf729a40
[ "MIT" ]
3
2020-10-08T17:28:13.000Z
2021-11-07T23:57:44.000Z
tests/examples/elixir/std/test.expected/app/user_test.exs
rogeriochaves/unit
5825fffd560951c61294b39c3d52e220bf729a40
[ "MIT" ]
null
null
null
defmodule App.UserTest do use ExUnit.Case alias App.User test "it works" do assert 1 + 1 == 2 end end
12.777778
25
0.652174
7374f2f3662530e19388603c4bb096be1742a0da
3,606
ex
Elixir
lib/adaptable_costs_evaluator/computations.ex
patrotom/adaptable-costs-evaluator
c97e65af1e021d7c6acf6564f4671c60321346e3
[ "MIT" ]
null
null
null
lib/adaptable_costs_evaluator/computations.ex
patrotom/adaptable-costs-evaluator
c97e65af1e021d7c6acf6564f4671c60321346e3
[ "MIT" ]
4
2021-12-07T12:26:50.000Z
2021-12-30T14:17:25.000Z
lib/adaptable_costs_evaluator/computations.ex
patrotom/adaptable-costs-evaluator
c97e65af1e021d7c6acf6564f4671c60321346e3
[ "MIT" ]
null
null
null
defmodule AdaptableCostsEvaluator.Computations do @moduledoc """ The Computations context. """ import Ecto.Query, warn: false alias AdaptableCostsEvaluator.Repo alias AdaptableCostsEvaluator.Computations.Computation alias AdaptableCostsEvaluator.Users.User alias AdaptableCostsEvaluator.{Users, Organizations} @doc """ Returns the list of computations belonging to the particular user defined by `creator_id` or computations in the organization defined by `organization_id`. """ def list_computations(creator_id: creator_id) do user = Users.get_user!(creator_id) Repo.preload(user, :computations).computations end def list_computations(organization_id: organization_id) do organization = Organizations.get_organization!(organization_id) Repo.preload(organization, :computations).computations end @doc """ Gets a single computation. Raises `Ecto.NoResultsError` if the Computation does not exist. ## Examples iex> get_computation!(123) %Computation{} iex> get_computation!(456) ** (Ecto.NoResultsError) """ def get_computation!(id), do: Repo.get!(Computation, id) @doc """ Gets a single computation defined by the given `attrs`. """ def get_computation_by!(attrs) do Repo.get_by!(Computation, attrs) end @doc """ Creates a computation belonging to the given user. ## Examples iex> create_computation(user, %{field: value}) {:ok, %Computation{}} iex> create_computation(user, %{field: bad_value}) {:error, %Ecto.Changeset{}} """ def create_computation(%User{} = user, attrs \\ %{}) do attrs = Map.put(attrs, "creator_id", user.id) %Computation{} |> change_computation(attrs) |> Repo.insert() end @doc """ Shares the given computation with the users within the organization. It sets `organization_id` attribute of the given computation. """ def add_computation_to_organization(%Computation{} = computation, organization_id) do organization = Organizations.get_organization!(organization_id) computation |> change_computation(%{organization_id: organization.id}) |> Repo.update() end @doc """ Updates a computation. ## Examples iex> update_computation(computation, %{field: new_value}) {:ok, %Computation{}} iex> update_computation(computation, %{field: bad_value}) {:error, %Ecto.Changeset{}} """ def update_computation(%Computation{} = computation, attrs) do attrs = %{name: Map.get(attrs, "name")} computation |> change_computation(attrs) |> Repo.update() end @doc """ Deletes a computation. If `from_org` keyword is set to `true`, it deletes the computation only from the organization. ## Examples iex> delete_computation(computation) {:ok, %Computation{}} iex> delete_computation(computation, from_org: true) {:ok, %Computation{}} iex> delete_computation(computation) {:error, %Ecto.Changeset{}} """ def delete_computation( %Computation{} = computation, [from_org: fo] \\ [from_org: false] ) do if fo do computation |> change_computation(%{organization_id: nil}) |> Repo.update() else Repo.delete(computation) end end @doc """ Returns an `%Ecto.Changeset{}` for tracking computation changes. ## Examples iex> change_computation(computation) %Ecto.Changeset{data: %Computation{}} """ def change_computation(%Computation{} = computation, attrs \\ %{}) do Computation.changeset(computation, attrs) end end
24.868966
87
0.682751
737500af951ab424a12577e6980583074dd6f1c7
679
ex
Elixir
kubeojo/lib/jenkins/jenkins_junit_filter.ex
marcosvm/kubeojo
61182997a9e27ac100c79e854f2d79bb8b5c6818
[ "MIT" ]
null
null
null
kubeojo/lib/jenkins/jenkins_junit_filter.ex
marcosvm/kubeojo
61182997a9e27ac100c79e854f2d79bb8b5c6818
[ "MIT" ]
null
null
null
kubeojo/lib/jenkins/jenkins_junit_filter.ex
marcosvm/kubeojo
61182997a9e27ac100c79e854f2d79bb8b5c6818
[ "MIT" ]
null
null
null
# filter junit data defmodule Kubeojo.Jenkins.JunitParser do def name_and_status(%{"suites" => suites}) do status = get_in(suites, [Access.all(), "cases", Access.all(), "status"]) |> List.flatten() name = get_in(suites, [Access.all(), "cases", Access.all(), "name"]) |> List.flatten() Enum.zip(name, status) |> Enum.into(%{}) end # from results filter and keep only failed tests def failed_only(testname_and_status) do handle_result = fn {test_name, "REGRESSION"} -> test_name {test_name, "FAILED"} -> test_name {_, _} -> nil end Enum.map(testname_and_status, handle_result) |> Enum.reject(fn t -> t == nil end) end end
32.333333
94
0.643594
73755c810642d297bb983d2dd37d45e58f1bf207
198
exs
Elixir
priv/repo/migrations/20200302182818_add_suspended_boolean_to_user.exs
smartlogic/Challenge_gov
b4203d1fcfb742dd17ecfadb9e9c56ad836d4254
[ "CC0-1.0" ]
9
2020-02-26T20:24:38.000Z
2022-03-22T21:14:52.000Z
priv/repo/migrations/20200302182818_add_suspended_boolean_to_user.exs
smartlogic/Challenge_gov
b4203d1fcfb742dd17ecfadb9e9c56ad836d4254
[ "CC0-1.0" ]
15
2020-04-22T19:33:24.000Z
2022-03-26T15:11:17.000Z
priv/repo/migrations/20200302182818_add_suspended_boolean_to_user.exs
smartlogic/Challenge_gov
b4203d1fcfb742dd17ecfadb9e9c56ad836d4254
[ "CC0-1.0" ]
4
2020-04-27T22:58:57.000Z
2022-01-14T13:42:09.000Z
defmodule ChallengeGov.Repo.Migrations.AddSuspendedBooleanToUser do use Ecto.Migration def change do alter table(:users) do add :suspended, :boolean, default: false end end end
19.8
67
0.737374
73759812469a51b54cd9b6470a6396dbfca30adf
1,839
ex
Elixir
clients/document_ai/lib/google_api/document_ai/v1beta2/model/google_cloud_documentai_v1beta1_document_entity_relation.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
null
null
null
clients/document_ai/lib/google_api/document_ai/v1beta2/model/google_cloud_documentai_v1beta1_document_entity_relation.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
1
2020-12-18T09:25:12.000Z
2020-12-18T09:25:12.000Z
clients/document_ai/lib/google_api/document_ai/v1beta2/model/google_cloud_documentai_v1beta1_document_entity_relation.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
1
2020-10-04T10:12:44.000Z
2020-10-04T10:12:44.000Z
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.DocumentAI.V1beta2.Model.GoogleCloudDocumentaiV1beta1DocumentEntityRelation do @moduledoc """ Relationship between Entities. ## Attributes * `objectId` (*type:* `String.t`, *default:* `nil`) - Object entity id. * `relation` (*type:* `String.t`, *default:* `nil`) - Relationship description. * `subjectId` (*type:* `String.t`, *default:* `nil`) - Subject entity id. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :objectId => String.t(), :relation => String.t(), :subjectId => String.t() } field(:objectId) field(:relation) field(:subjectId) end defimpl Poison.Decoder, for: GoogleApi.DocumentAI.V1beta2.Model.GoogleCloudDocumentaiV1beta1DocumentEntityRelation do def decode(value, options) do GoogleApi.DocumentAI.V1beta2.Model.GoogleCloudDocumentaiV1beta1DocumentEntityRelation.decode( value, options ) end end defimpl Poison.Encoder, for: GoogleApi.DocumentAI.V1beta2.Model.GoogleCloudDocumentaiV1beta1DocumentEntityRelation do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
31.706897
98
0.725938
7375a95f24339d8147a3262b4bd594d089339ebf
9,601
exs
Elixir
test/epicenter_web/live/case_investigation_clinical_details_live_test.exs
geometricservices/epi-viewpoin
ecb5316ea0f3f7299d5ff63e2de588539005ac1c
[ "Apache-2.0" ]
5
2021-02-25T18:43:09.000Z
2021-02-27T06:00:35.000Z
test/epicenter_web/live/case_investigation_clinical_details_live_test.exs
geometricservices/epi-viewpoint
ecb5316ea0f3f7299d5ff63e2de588539005ac1c
[ "Apache-2.0" ]
3
2021-12-13T17:52:47.000Z
2021-12-17T01:35:31.000Z
test/epicenter_web/live/case_investigation_clinical_details_live_test.exs
geometricservices/epi-viewpoint
ecb5316ea0f3f7299d5ff63e2de588539005ac1c
[ "Apache-2.0" ]
1
2022-01-27T23:26:38.000Z
2022-01-27T23:26:38.000Z
defmodule EpicenterWeb.CaseInvestigationClinicalDetailsLiveTest do use EpicenterWeb.ConnCase, async: true alias Epicenter.Cases alias Epicenter.Test alias EpicenterWeb.Test.Pages import Epicenter.Test.RevisionAssertions setup :register_and_log_in_user setup %{user: user} do person = Test.Fixtures.person_attrs(user, "alice") |> Cases.create_person!() lab_result = Test.Fixtures.lab_result_attrs(person, user, "alice-test-result", ~D[2020-08-06]) |> Cases.create_lab_result!() case_investigation = Test.Fixtures.case_investigation_attrs(person, lab_result, user, "alice-case-investigation", %{ clinical_status: "asymptomatic", symptom_onset_on: ~D[2020-11-03], symptoms: ["cough", "headache"] }) |> Cases.create_case_investigation!() [person: person, user: user, case_investigation: case_investigation] end test "records an audit log entry", %{conn: conn, case_investigation: case_investigation, user: user} do case_investigation = case_investigation |> Cases.preload_person() AuditLogAssertions.expect_phi_view_logs(2) Pages.CaseInvestigationClinicalDetails.visit(conn, case_investigation) AuditLogAssertions.verify_phi_view_logged(user, case_investigation.person) end test "has a clinical details form", %{conn: conn, case_investigation: case_investigation} do Pages.CaseInvestigationClinicalDetails.visit(conn, case_investigation) |> Pages.CaseInvestigationClinicalDetails.assert_here() |> Pages.CaseInvestigationClinicalDetails.assert_clinical_status_selection(%{ "Unknown" => false, "Symptomatic" => false, "Asymptomatic" => true }) |> Pages.CaseInvestigationClinicalDetails.assert_symptom_onset_on_explanation_text("08/06/2020") |> Pages.CaseInvestigationClinicalDetails.assert_symptom_onset_on_value("11/03/2020") |> Pages.CaseInvestigationClinicalDetails.assert_symptoms_selection(%{ "Fever > 100.4F" => false, "Subjective fever (felt feverish)" => false, "Cough" => true, "Shortness of breath" => false, "Diarrhea/GI" => false, "Headache" => true, "Muscle ache" => false, "Chills" => false, "Sore throat" => false, "Vomiting" => false, "Abdominal pain" => false, "Nasal congestion" => false, "Loss of sense of smell" => false, "Loss of sense of taste" => false, "Fatigue" => false, "Other" => false }) |> Pages.CaseInvestigationClinicalDetails.assert_save_button_visible() end @tag :skip test "saving clinical details with progressive disclosure of 'Other' text box", %{ conn: conn, case_investigation: case_investigation, person: person, user: user } do Pages.CaseInvestigationClinicalDetails.visit(conn, case_investigation) |> Pages.submit_and_follow_redirect(conn, "#case-investigation-clinical-details-form", clinical_details_form: %{ "clinical_status" => "symptomatic", "symptom_onset_on" => "09/06/2020", "symptoms" => ["fever", "chills", "groggy"], "symptoms_other" => true } ) |> Pages.Profile.assert_here(person) assert_revision_count(case_investigation, 2) assert_recent_audit_log(case_investigation, user, %{ clinical_status: "symptomatic", symptom_onset_on: "2020-09-06", symptoms: ["fever", "chills", "groggy"] }) end # Fixes #176181002 - we had misnamed the key to check for in the params passed to handle_event("change", ...) test "changed symptoms are rendered correctly", %{conn: conn, case_investigation: case_investigation} do Pages.CaseInvestigationClinicalDetails.visit(conn, case_investigation) |> Pages.CaseInvestigationClinicalDetails.change_form(clinical_details_form: %{"symptoms" => ["cough"]}) |> Pages.CaseInvestigationClinicalDetails.assert_symptoms_selection(%{ "Fever > 100.4F" => false, "Subjective fever (felt feverish)" => false, "Cough" => true, "Shortness of breath" => false, "Diarrhea/GI" => false, "Headache" => false, "Muscle ache" => false, "Chills" => false, "Sore throat" => false, "Vomiting" => false, "Abdominal pain" => false, "Nasal congestion" => false, "Loss of sense of smell" => false, "Loss of sense of taste" => false, "Fatigue" => false, "Other" => false }) end test "removing the last symptom doesn't clear the rendered changeset", %{conn: conn, case_investigation: case_investigation} do Pages.CaseInvestigationClinicalDetails.visit(conn, case_investigation) |> Pages.CaseInvestigationClinicalDetails.change_form(clinical_details_form: %{"symptoms" => []}) |> Pages.CaseInvestigationClinicalDetails.assert_symptoms_selection(%{ "Fever > 100.4F" => false, "Subjective fever (felt feverish)" => false, "Cough" => false, "Shortness of breath" => false, "Diarrhea/GI" => false, "Headache" => false, "Muscle ache" => false, "Chills" => false, "Sore throat" => false, "Vomiting" => false, "Abdominal pain" => false, "Nasal congestion" => false, "Loss of sense of smell" => false, "Loss of sense of taste" => false, "Fatigue" => false, "Other" => false }) end test "saving clinical details", %{conn: conn, case_investigation: case_investigation, person: person, user: user} do Pages.CaseInvestigationClinicalDetails.visit(conn, case_investigation) |> Pages.submit_and_follow_redirect(conn, "#case-investigation-clinical-details-form", clinical_details_form: %{ "clinical_status" => "symptomatic", "symptom_onset_on" => "09/06/2020", "symptoms" => ["fever", "chills"] } ) |> Pages.Profile.assert_here(person) assert_revision_count(case_investigation, 2) assert_recent_audit_log(case_investigation, user, %{ clinical_status: "symptomatic", symptom_onset_on: "2020-09-06", symptoms: ["fever", "chills"] }) end @tag :skip test "saving clinical details with an 'Other' symptom", %{conn: conn, case_investigation: case_investigation, person: person, user: user} do Pages.CaseInvestigationClinicalDetails.visit(conn, case_investigation) |> Pages.submit_and_follow_redirect(conn, "#case-investigation-clinical-details-form", clinical_details_form: %{ "clinical_status" => "symptomatic", "symptom_onset_on" => "09/06/2020", "symptoms" => ["fever", "chills"], "symptoms_other" => true } ) |> Pages.Profile.assert_here(person) assert_revision_count(case_investigation, 2) assert_recent_audit_log(case_investigation, user, %{ clinical_status: "symptomatic", symptom_onset_on: "2020-09-06", symptoms: ["fever", "chills"] }) end test "saving empty clinical details", %{conn: conn, case_investigation: case_investigation, person: person, user: user} do Pages.CaseInvestigationClinicalDetails.visit(conn, case_investigation) |> Pages.submit_and_follow_redirect(conn, "#case-investigation-clinical-details-form", clinical_details_form: %{ "symptom_onset_on" => "", "symptoms" => [] } ) |> Pages.Profile.assert_here(person) case_investigation = Cases.get_case_investigation(case_investigation.id, user) assert Euclid.Exists.blank?(case_investigation.symptoms) assert case_investigation.symptom_onset_on == nil assert case_investigation.clinical_status == "asymptomatic" end test "validating date format", %{conn: conn, case_investigation: case_investigation} do Pages.CaseInvestigationClinicalDetails.visit(conn, case_investigation) |> Pages.submit_live("#case-investigation-clinical-details-form", clinical_details_form: %{ "clinical_status" => "symptomatic", "symptom_onset_on" => "09/32/2020", "symptoms" => ["fever", "chills"] } ) |> Pages.assert_validation_messages(%{"clinical_details_form[symptom_onset_on]" => "please enter dates as mm/dd/yyyy"}) end @tag :skip test "stripping out 'other' when submitting without other checked", %{conn: conn, case_investigation: case_investigation, user: user} do Pages.CaseInvestigationClinicalDetails.visit(conn, case_investigation) |> Pages.submit_and_follow_redirect(conn, "#case-investigation-clinical-details-form", clinical_details_form: %{ "clinical_status" => "symptomatic", "symptom_onset_on" => "09/02/2020", "symptoms" => ["fever", "groggy"] } ) assert %{symptoms: ["fever"]} = Cases.get_case_investigation(case_investigation.id, user) end describe "warning the user when navigation will erase their changes" do test "before the user changes anything", %{conn: conn, case_investigation: case_investigation} do Pages.CaseInvestigationClinicalDetails.visit(conn, case_investigation) |> Pages.refute_confirmation_prompt_active() end test "when the user changes something", %{conn: conn, case_investigation: case_investigation} do view = Pages.CaseInvestigationClinicalDetails.visit(conn, case_investigation) |> Pages.CaseInvestigationClinicalDetails.change_form(clinical_details_form: %{"clinical_status" => "symptomatic"}) |> Pages.assert_confirmation_prompt_active("Your updates have not been saved. Discard updates?") assert %{ "clinical_details_form[clinical_status]" => "symptomatic" } = Pages.form_state(view) end end end
39.673554
142
0.68722
7375af3103a4aab71e4645771935f3275d8efd42
1,736
ex
Elixir
lib/distcount_web.ex
cabol/distcount
b0b42f66dcc130ec6e349ab8b915cfb6f5b77c7b
[ "MIT" ]
null
null
null
lib/distcount_web.ex
cabol/distcount
b0b42f66dcc130ec6e349ab8b915cfb6f5b77c7b
[ "MIT" ]
null
null
null
lib/distcount_web.ex
cabol/distcount
b0b42f66dcc130ec6e349ab8b915cfb6f5b77c7b
[ "MIT" ]
null
null
null
defmodule DistcountWeb 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 DistcountWeb, :controller use DistcountWeb, :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: DistcountWeb import Plug.Conn alias DistcountWeb.Router.Helpers, as: Routes end end def view do quote do use Phoenix.View, root: "lib/distcount_web/templates", namespace: DistcountWeb # Import convenience functions from controllers import Phoenix.Controller, only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1] # Include shared imports and aliases for views unquote(view_helpers()) 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 end end defp view_helpers do quote do # Import basic rendering functionality (render, render_layout, etc) import Phoenix.View import DistcountWeb.ErrorHelpers alias DistcountWeb.Router.Helpers, as: Routes 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
22.842105
76
0.689516
7375d80f681794d96b540dc4f8dd3ecfc7d1578e
1,044
exs
Elixir
chapter13/issues/mix.exs
PaoloLaurenti/programming_elixir
b243097dafac7d95632ada1035e8ab62248bbff6
[ "MIT" ]
null
null
null
chapter13/issues/mix.exs
PaoloLaurenti/programming_elixir
b243097dafac7d95632ada1035e8ab62248bbff6
[ "MIT" ]
null
null
null
chapter13/issues/mix.exs
PaoloLaurenti/programming_elixir
b243097dafac7d95632ada1035e8ab62248bbff6
[ "MIT" ]
2
2018-03-22T01:47:28.000Z
2018-06-29T00:37:22.000Z
defmodule Issues.Mixfile do use Mix.Project def project do [ app: :issues, escript: escript_config(), version: "0.0.1", name: "Issues", source: "https://github.com/pragdave/issues", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, deps: deps() ] end # Configuration for the OTP application # # Type "mix help compile.app" for more information def application do [applications: [:logger, :httpoison]] end # Dependencies can be Hex packages: # # {:mydep, "~> 0.3.0"} # # Or git/path repositories: # # {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"} # # Type "mix help deps" for more examples and options defp deps do [ {:httpoison, "~> 0.9"}, {:poison, "~> 2.2"}, {:ex_doc, "~> 0.12"}, {:earmark, "~> 1.0", override: true} ] end defp escript_config do [ main_module: Issues.CLI ] end end
22.695652
77
0.538314
7375e2baaa79ac5ada58b86ae8266c416ccd33d2
10,979
ex
Elixir
lib/aws/generated/lookout_metrics.ex
justinludwig/aws-elixir
c66dfebecec62587dada50602c31c76d307d812c
[ "Apache-2.0" ]
null
null
null
lib/aws/generated/lookout_metrics.ex
justinludwig/aws-elixir
c66dfebecec62587dada50602c31c76d307d812c
[ "Apache-2.0" ]
null
null
null
lib/aws/generated/lookout_metrics.ex
justinludwig/aws-elixir
c66dfebecec62587dada50602c31c76d307d812c
[ "Apache-2.0" ]
null
null
null
# WARNING: DO NOT EDIT, AUTO-GENERATED CODE! # See https://github.com/aws-beam/aws-codegen for more details. defmodule AWS.LookoutMetrics do @moduledoc """ This is the *Amazon Lookout for Metrics API Reference*. For an introduction to the service with tutorials for getting started, visit [Amazon Lookout for Metrics Developer Guide](https://docs.aws.amazon.com/lookoutmetrics/latest/dev). """ alias AWS.Client alias AWS.Request def metadata do %AWS.ServiceMetadata{ abbreviation: nil, api_version: "2017-07-25", content_type: "application/x-amz-json-1.1", credential_scope: nil, endpoint_prefix: "lookoutmetrics", global?: false, protocol: "rest-json", service_id: "LookoutMetrics", signature_version: "v4", signing_name: "lookoutmetrics", target_prefix: nil } end @doc """ Activates an anomaly detector. """ def activate_anomaly_detector(%Client{} = client, input, options \\ []) do url_path = "/ActivateAnomalyDetector" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Runs a backtest for anomaly detection for the specified resource. """ def back_test_anomaly_detector(%Client{} = client, input, options \\ []) do url_path = "/BackTestAnomalyDetector" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Creates an alert for an anomaly detector. """ def create_alert(%Client{} = client, input, options \\ []) do url_path = "/CreateAlert" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Creates an anomaly detector. """ def create_anomaly_detector(%Client{} = client, input, options \\ []) do url_path = "/CreateAnomalyDetector" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Creates a dataset. """ def create_metric_set(%Client{} = client, input, options \\ []) do url_path = "/CreateMetricSet" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Deletes an alert. """ def delete_alert(%Client{} = client, input, options \\ []) do url_path = "/DeleteAlert" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Deletes a detector. Deleting an anomaly detector will delete all of its corresponding resources including any configured datasets and alerts. """ def delete_anomaly_detector(%Client{} = client, input, options \\ []) do url_path = "/DeleteAnomalyDetector" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Describes an alert. """ def describe_alert(%Client{} = client, input, options \\ []) do url_path = "/DescribeAlert" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Returns information about the status of the specified anomaly detection jobs. """ def describe_anomaly_detection_executions(%Client{} = client, input, options \\ []) do url_path = "/DescribeAnomalyDetectionExecutions" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Describes a detector. """ def describe_anomaly_detector(%Client{} = client, input, options \\ []) do url_path = "/DescribeAnomalyDetector" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Describes a dataset. """ def describe_metric_set(%Client{} = client, input, options \\ []) do url_path = "/DescribeMetricSet" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Returns details about a group of anomalous metrics. """ def get_anomaly_group(%Client{} = client, input, options \\ []) do url_path = "/GetAnomalyGroup" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Get feedback for an anomaly group. """ def get_feedback(%Client{} = client, input, options \\ []) do url_path = "/GetFeedback" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Returns a selection of sample records from an Amazon S3 datasource. """ def get_sample_data(%Client{} = client, input, options \\ []) do url_path = "/GetSampleData" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Lists the alerts attached to a detector. """ def list_alerts(%Client{} = client, input, options \\ []) do url_path = "/ListAlerts" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Lists the detectors in the current AWS Region. """ def list_anomaly_detectors(%Client{} = client, input, options \\ []) do url_path = "/ListAnomalyDetectors" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Returns a list of anomaly groups. """ def list_anomaly_group_summaries(%Client{} = client, input, options \\ []) do url_path = "/ListAnomalyGroupSummaries" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Gets a list of anomalous metrics for a measure in an anomaly group. """ def list_anomaly_group_time_series(%Client{} = client, input, options \\ []) do url_path = "/ListAnomalyGroupTimeSeries" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Lists the datasets in the current AWS Region. """ def list_metric_sets(%Client{} = client, input, options \\ []) do url_path = "/ListMetricSets" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Gets a list of [tags](https://docs.aws.amazon.com/lookoutmetrics/latest/dev/detectors-tags.html) for a detector, dataset, or alert. """ def list_tags_for_resource(%Client{} = client, resource_arn, options \\ []) do url_path = "/tags/#{URI.encode(resource_arn)}" headers = [] query_params = [] Request.request_rest( client, metadata(), :get, url_path, query_params, headers, nil, options, 200 ) end @doc """ Add feedback for an anomalous metric. """ def put_feedback(%Client{} = client, input, options \\ []) do url_path = "/PutFeedback" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Adds [tags](https://docs.aws.amazon.com/lookoutmetrics/latest/dev/detectors-tags.html) to a detector, dataset, or alert. """ def tag_resource(%Client{} = client, resource_arn, input, options \\ []) do url_path = "/tags/#{URI.encode(resource_arn)}" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, 204 ) end @doc """ Removes [tags](https://docs.aws.amazon.com/lookoutmetrics/latest/dev/detectors-tags.html) from a detector, dataset, or alert. """ def untag_resource(%Client{} = client, resource_arn, input, options \\ []) do url_path = "/tags/#{URI.encode(resource_arn)}" headers = [] {query_params, input} = [ {"TagKeys", "tagKeys"} ] |> Request.build_params(input) Request.request_rest( client, metadata(), :delete, url_path, query_params, headers, input, options, 204 ) end @doc """ Updates a detector. After activation, you can only change a detector's ingestion delay and description. """ def update_anomaly_detector(%Client{} = client, input, options \\ []) do url_path = "/UpdateAnomalyDetector" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end @doc """ Updates a dataset. """ def update_metric_set(%Client{} = client, input, options \\ []) do url_path = "/UpdateMetricSet" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, nil ) end end
19.194056
102
0.57355
7375e6d7ce20e6d5cefee8c43a9ff5c8369d258b
8,257
ex
Elixir
lib/data/chunk_reader.ex
bzzt/bigtable
215b104a60596dde6cd459efb73baf8bccdb6b50
[ "MIT" ]
17
2019-01-22T12:59:38.000Z
2021-12-13T10:41:52.000Z
lib/data/chunk_reader.ex
bzzt/bigtable
215b104a60596dde6cd459efb73baf8bccdb6b50
[ "MIT" ]
17
2019-01-27T18:11:33.000Z
2020-02-24T10:16:08.000Z
lib/data/chunk_reader.ex
bzzt/bigtable
215b104a60596dde6cd459efb73baf8bccdb6b50
[ "MIT" ]
3
2019-02-04T17:08:09.000Z
2021-04-07T07:13:53.000Z
defmodule Bigtable.ChunkReader do @moduledoc """ Reads chunks from `Google.Bigtable.V2.ReadRowsResponse` and parses them into complete cells grouped by rowkey. """ use Agent, restart: :temporary defmodule ReadCell do @moduledoc """ A finished cell produced by `Bigtable.ChunkReader`. """ @type t :: %__MODULE__{ label: binary(), row_key: binary(), family_name: Google.Protobuf.StringValue.t(), qualifier: Google.Protobuf.BytesValue.t(), timestamp: non_neg_integer, value: binary() } defstruct [ :label, :row_key, :family_name, :qualifier, :timestamp, :value ] end defmodule ReaderState do @moduledoc false defstruct [ :cur_key, :cur_label, :cur_fam, :cur_qual, :cur_val, :last_key, cur_row: %{}, cur_ts: 0, state: :new_row ] end @typedoc """ A map containging lists of `Bigtable.ChunkReader.ReadCell` keyed by row key. """ @type chunk_reader_result :: %{optional(binary()) => [ReadCell.t()]} def start_link(_) do GenServer.start_link(__MODULE__, %ReaderState{}, []) end @doc """ Opens a `Bigtable.ChunkReader`. """ @spec open() :: :ignore | {:error, any()} | {:ok, pid()} | {:ok, pid(), any()} def open do DynamicSupervisor.start_child(__MODULE__.Supervisor, __MODULE__) end @doc """ Closes a `Bigtable.ChunkReader` when provided its pid and returns the chunk_reader_result. """ @spec close(pid()) :: {:ok, chunk_reader_result} | {:error, binary()} def close(pid) do result = GenServer.call(pid, :close) DynamicSupervisor.terminate_child(__MODULE__.Supervisor, pid) result end @doc """ Processes a `Google.Bigtable.V2.ReadRowsResponse.CellChunk` given a `Bigtable.ChunkReader` pid. """ @spec process(pid(), Google.Bigtable.V2.ReadRowsResponse.CellChunk.t()) :: {:ok, chunk_reader_result} | {:error, binary()} def process(pid, cc) do GenServer.call(pid, {:process, cc}) end @doc false def init(state) do {:ok, state} end @doc false def handle_call(:close, _from, cr) do if cr.state == :new_row do {:reply, {:ok, cr.cur_row}, cr} else {:reply, {:error, "invalid state for end of stream #{cr.state}"}, cr} end end @doc false def handle_call({:process, cc}, _from, cr) do case handle_state(cr.state, cr, cc) do {:error, _msg} = result -> {:reply, result, cr} next_state -> {:reply, {:ok, next_state.cur_row}, next_state} end end defp handle_state(:new_row, cr, cc) do with :ok <- validate_new_row(cr, cc) do to_merge = %{ cur_key: cc.row_key, cur_fam: cc.family_name, cur_qual: cc.qualifier, cur_ts: cc.timestamp_micros } cr |> Map.merge(to_merge) |> handle_cell_value(cc) else e -> e end end defp handle_state(:cell_in_progress, cr, cc) do with :ok <- validate_cell_in_progress(cr, cc) do if reset_row?(cc) do reset_to_new_row(cr) else cr |> handle_cell_value(cc) end else e -> e end end defp handle_state(:row_in_progress, cr, cc) do with :ok <- validate_row_in_progress(cr, cc) do if reset_row?(cc) do reset_to_new_row(cr) else cr |> update_if_contains(cc, :family_name, :cur_fam) |> update_if_contains(cc, :qualifier, :cur_qual) |> update_if_contains(cc, :timestamp_micros, :cur_ts) |> handle_cell_value(cc) end else e -> e end end defp update_if_contains(cr, cc, cc_key, cr_key) do value = Map.get(cc, cc_key) if value != nil do Map.put(cr, cr_key, value) else cr end end defp validate_new_row(cr, cc) do cond do reset_row?(cc) -> {:error, "reset_row not allowed between rows"} !row_key?(cc) or !family?(cc) or !qualifier?(cc) -> {:error, "missing key field for new row #{inspect(cc)}"} cr.last_key != "" and cr.last_key >= cc.row_key -> {:error, "out of order row key: #{cr.last_key}, #{cc.row_key}"} true -> :ok end end defp validate_row_in_progress(cr, cc) do status = validate_row_status(cc) cond do status != :ok -> status row_key?(cc) and cc.row_key != cr.cur_key -> {:error, "received new row key #{cc.row_key} during existing row #{cr.cur_key}"} family?(cc) and !qualifier?(cc) -> {:error, "family name #{cc.family_name} specified without a qualifier"} true -> :ok end end defp validate_cell_in_progress(cr, cc) do status = validate_row_status(cc) cond do status != :ok -> status cr.cur_val == nil -> {:error, "no cached cell while CELL_IN_PROGRESS #{cc}"} !reset_row?(cc) and any_key_present?(cc) -> {:error, "cell key components found while CELL_IN_PROGRESS #{cc}"} true -> :ok end end defp validate_row_status(cc) do cond do reset_row?(cc) and (any_key_present?(cc) or value?(cc) or value_size?(cc) or labels?(cc)) -> {:error, "reset must not be specified with other fields #{inspect(cc)}"} commit_row?(cc) and value_size?(cc) -> {:error, "commit row found in between chunks in a cell"} true -> :ok end end defp handle_cell_value(cr, %{value_size: value_size} = cc) when value_size > 0 do next_value = if cr.cur_val == nil do <<>> <> cc.value else cr.cur_val <> cc.value end next_label = if has_property?(cr, :cur_label) do cr.cur_label else Map.get(cc, :labels, "") end cr |> Map.put(:cur_val, next_value) |> Map.put(:cur_label, next_label) |> Map.put(:state, :cell_in_progress) end defp handle_cell_value(cr, cc) do next_value = if cr.cur_val == nil do cc.value else cr.cur_val <> cc.value end next_label = if has_property?(cr, :cur_label) do cr.cur_label else Map.get(cc, :labels, "") end cr |> Map.put(:cur_val, next_value) |> Map.put(:cur_label, next_label) |> finish_cell(cc) end defp finish_cell(cr, cc) do label = case cr.cur_label do label when is_list(label) -> Enum.join(label, " ") label -> label end ri = %ReadCell{ label: label, qualifier: cr.cur_qual, row_key: cr.cur_key, family_name: cr.cur_fam, timestamp: cr.cur_ts, value: cr.cur_val } next_row = Map.update(cr.cur_row, cr.cur_key, [ri], fn prev -> [ri | prev] end) to_merge = if commit_row?(cc) do %{ last_key: cr.cur_key, state: :new_row } else %{ state: :row_in_progress } end next_state = Map.merge(to_merge, %{ cur_row: next_row, cur_label: nil, cur_val: nil }) Map.merge(cr, next_state) end defp reset_to_new_row(cr) do Map.merge(cr, %{ cur_key: nil, cur_fam: nil, cur_qual: nil, cur_val: nil, cur_row: %{}, cur_ts: 0, state: :new_row }) end defp any_key_present?(cc) do row_key?(cc) or family?(cc) or qualifier?(cc) or cc.timestamp_micros != 0 end defp value?(cc), do: has_property?(cc, :value) defp value_size?(cc), do: cc.value_size > 0 defp labels?(cc) do value = Map.get(cc, :labels) value != [] and value != nil and value != "" end defp row_key?(cc), do: has_property?(cc, :row_key) defp family?(cc), do: has_property?(cc, :family_name) defp qualifier?(cc), do: has_property?(cc, :qualifier) defp has_property?(cc, key) do val = Map.get(cc, key) val != nil and val != "" end defp reset_row?(cc), do: row_status(cc) == :reset_row defp commit_row?(cc), do: row_status(cc) == :commit_row defp row_status(cc) do case cc.row_status do {status, true} -> status _ -> nil end end end
22.621918
112
0.577449
73760a6613d3b3b944c481b99de273b6526bf391
2,151
ex
Elixir
lib/multi_tenancex_web/controllers/admin/company_controller.ex
dreamingechoes/multi_tenancex
cfe3feb6b7eb25559f9abaa4da89e4aafc9ad2ec
[ "MIT" ]
30
2018-06-27T17:51:53.000Z
2021-04-24T03:17:55.000Z
lib/multi_tenancex_web/controllers/admin/company_controller.ex
dreamingechoes/multi_tenancex
cfe3feb6b7eb25559f9abaa4da89e4aafc9ad2ec
[ "MIT" ]
null
null
null
lib/multi_tenancex_web/controllers/admin/company_controller.ex
dreamingechoes/multi_tenancex
cfe3feb6b7eb25559f9abaa4da89e4aafc9ad2ec
[ "MIT" ]
7
2018-07-24T17:56:14.000Z
2019-12-31T02:10:13.000Z
defmodule MultiTenancexWeb.Admin.CompanyController do use MultiTenancexWeb, :controller alias MultiTenancex.Companies alias MultiTenancex.Companies.Company def index(conn, _params) do companies = Companies.list_companies(conn.assigns.current_tenant) render(conn, "index.html", companies: companies) end def new(conn, _params) do changeset = Companies.change_company(%Company{}) render(conn, "new.html", changeset: changeset) end def create(conn, %{"company" => company_params}) do case Companies.create_company(company_params) do {:ok, company} -> conn |> put_flash(:info, "Company created successfully.") |> redirect(to: admin_company_path(conn, :show, company)) {:error, %Ecto.Changeset{} = changeset} -> render(conn, "new.html", changeset: changeset) end end def show(conn, %{"id" => id}) do company = Companies.get_company!(id, conn.assigns.current_tenant) render(conn, "show.html", company: company) end def edit(conn, %{"id" => id}) do company = Companies.get_company!(id, conn.assigns.current_tenant) changeset = Companies.change_company(company) render(conn, "edit.html", company: company, changeset: changeset) end def update(conn, %{"id" => id, "company" => company_params}) do company = Companies.get_company!(id, conn.assigns.current_tenant) case Companies.update_company( company, company_params, conn.assigns.current_tenant ) do {:ok, company} -> conn |> put_flash(:info, "Company updated successfully.") |> redirect(to: admin_company_path(conn, :show, company)) {:error, %Ecto.Changeset{} = changeset} -> render(conn, "edit.html", company: company, changeset: changeset) end end def delete(conn, %{"id" => id}) do company = Companies.get_company!(id, conn.assigns.current_tenant) {:ok, _company} = Companies.delete_company(company, conn.assigns.current_tenant) conn |> put_flash(:info, "Company deleted successfully.") |> redirect(to: admin_company_path(conn, :index)) end end
31.173913
73
0.667132
73765c9e8e8a5801e9cade790798361eb0dad2c9
534
ex
Elixir
lib/arrow_web/views/api/disruption_revision_view.ex
paulswartz/arrow
c1ba1ce52107c0ed94ce9bca2fef2bfeb606b8f9
[ "MIT" ]
null
null
null
lib/arrow_web/views/api/disruption_revision_view.ex
paulswartz/arrow
c1ba1ce52107c0ed94ce9bca2fef2bfeb606b8f9
[ "MIT" ]
null
null
null
lib/arrow_web/views/api/disruption_revision_view.ex
paulswartz/arrow
c1ba1ce52107c0ed94ce9bca2fef2bfeb606b8f9
[ "MIT" ]
null
null
null
defmodule ArrowWeb.API.DisruptionRevisionView do use ArrowWeb, :view use JaSerializer.PhoenixView attributes([:start_date, :end_date, :is_active, :inserted_at]) has_many :adjustments, serializer: ArrowWeb.API.AdjustmentView, include: true has_many :days_of_week, serializer: ArrowWeb.API.DayOfWeekView, include: true has_many :exceptions, serializer: ArrowWeb.API.ExceptionView, include: true has_many :trip_short_names, serializer: ArrowWeb.API.TripShortNameView, include: true end
23.217391
64
0.752809
7376838762751ea6220c4a8d900962b638c23d01
12,499
ex
Elixir
clients/compute/lib/google_api/compute/v1/api/routes.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/compute/lib/google_api/compute/v1/api/routes.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/compute/lib/google_api/compute/v1/api/routes.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
1
2020-11-10T16:58:27.000Z
2020-11-10T16:58:27.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.Compute.V1.Api.Routes do @moduledoc """ API calls for all endpoints tagged `Routes`. """ alias GoogleApi.Compute.V1.Connection alias GoogleApi.Gax.{Request, Response} @doc """ Deletes the specified Route resource. ## Parameters - connection (GoogleApi.Compute.V1.Connection): Connection to server - project (String.t): Project ID for this request. - route (String.t): Name of the Route resource to delete. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for the response. - :fields (String.t): Selector specifying which fields to include in a partial response. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :oauth_token (String.t): OAuth 2.0 token for the current user. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :quotaUser (String.t): An opaque string that represents a user for quota purposes. Must not exceed 40 characters. - :userIp (String.t): Deprecated. Please use quotaUser instead. - :requestId (String.t): An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). ## Returns {:ok, %GoogleApi.Compute.V1.Model.Operation{}} on success {:error, info} on failure """ @spec compute_routes_delete(Tesla.Env.client(), String.t(), String.t(), keyword()) :: {:ok, GoogleApi.Compute.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def compute_routes_delete(connection, project, route, opts \\ []) do optional_params = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :requestId => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/{project}/global/routes/{route}", %{ "project" => URI.encode_www_form(project), "route" => URI.encode_www_form(route) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Compute.V1.Model.Operation{}) end @doc """ Returns the specified Route resource. Gets a list of available routes by making a list() request. ## Parameters - connection (GoogleApi.Compute.V1.Connection): Connection to server - project (String.t): Project ID for this request. - route (String.t): Name of the Route resource to return. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for the response. - :fields (String.t): Selector specifying which fields to include in a partial response. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :oauth_token (String.t): OAuth 2.0 token for the current user. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :quotaUser (String.t): An opaque string that represents a user for quota purposes. Must not exceed 40 characters. - :userIp (String.t): Deprecated. Please use quotaUser instead. ## Returns {:ok, %GoogleApi.Compute.V1.Model.Route{}} on success {:error, info} on failure """ @spec compute_routes_get(Tesla.Env.client(), String.t(), String.t(), keyword()) :: {:ok, GoogleApi.Compute.V1.Model.Route.t()} | {:error, Tesla.Env.t()} def compute_routes_get(connection, project, route, opts \\ []) do optional_params = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query } request = Request.new() |> Request.method(:get) |> Request.url("/{project}/global/routes/{route}", %{ "project" => URI.encode_www_form(project), "route" => URI.encode_www_form(route) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Compute.V1.Model.Route{}) end @doc """ Creates a Route resource in the specified project using the data included in the request. ## Parameters - connection (GoogleApi.Compute.V1.Connection): Connection to server - project (String.t): Project ID for this request. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for the response. - :fields (String.t): Selector specifying which fields to include in a partial response. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :oauth_token (String.t): OAuth 2.0 token for the current user. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :quotaUser (String.t): An opaque string that represents a user for quota purposes. Must not exceed 40 characters. - :userIp (String.t): Deprecated. Please use quotaUser instead. - :requestId (String.t): An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). - :body (Route): ## Returns {:ok, %GoogleApi.Compute.V1.Model.Operation{}} on success {:error, info} on failure """ @spec compute_routes_insert(Tesla.Env.client(), String.t(), keyword()) :: {:ok, GoogleApi.Compute.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def compute_routes_insert(connection, project, opts \\ []) do optional_params = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :requestId => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/{project}/global/routes", %{ "project" => URI.encode_www_form(project) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Compute.V1.Model.Operation{}) end @doc """ Retrieves the list of Route resources available to the specified project. ## Parameters - connection (GoogleApi.Compute.V1.Connection): Connection to server - project (String.t): Project ID for this request. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for the response. - :fields (String.t): Selector specifying which fields to include in a partial response. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :oauth_token (String.t): OAuth 2.0 token for the current user. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :quotaUser (String.t): An opaque string that represents a user for quota purposes. Must not exceed 40 characters. - :userIp (String.t): Deprecated. Please use quotaUser instead. - :filter (String.t): A filter expression that filters resources listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be either &#x3D;, !&#x3D;, &gt;, or &lt;. For example, if you are filtering Compute Engine instances, you can exclude instances named example-instance by specifying name !&#x3D; example-instance. You can also filter nested fields. For example, you could specify scheduling.automaticRestart &#x3D; false to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example, (scheduling.automaticRestart &#x3D; true) (cpuPlatform &#x3D; \&quot;Intel Skylake\&quot;). By default, each expression is an AND expression. However, you can include AND and OR expressions explicitly. For example, (cpuPlatform &#x3D; \&quot;Intel Skylake\&quot;) OR (cpuPlatform &#x3D; \&quot;Intel Broadwell\&quot;) AND (scheduling.automaticRestart &#x3D; true). - :maxResults (integer()): The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. Acceptable values are 0 to 500, inclusive. (Default: 500) - :orderBy (String.t): Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using orderBy&#x3D;\&quot;creationTimestamp desc\&quot;. This sorts results based on the creationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by name or creationTimestamp desc is supported. - :pageToken (String.t): Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results. ## Returns {:ok, %GoogleApi.Compute.V1.Model.RouteList{}} on success {:error, info} on failure """ @spec compute_routes_list(Tesla.Env.client(), String.t(), keyword()) :: {:ok, GoogleApi.Compute.V1.Model.RouteList.t()} | {:error, Tesla.Env.t()} def compute_routes_list(connection, project, opts \\ []) do optional_params = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :filter => :query, :maxResults => :query, :orderBy => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/{project}/global/routes", %{ "project" => URI.encode_www_form(project) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(struct: %GoogleApi.Compute.V1.Model.RouteList{}) end end
53.643777
1,213
0.703096
737683db20038cae19173c873e7be51c4c539113
78
exs
Elixir
test/pelemay_test.exs
muramasa8191/pelemay
f6b51ad8acc9b6fc66280e238a67364293b2b7d5
[ "Apache-2.0" ]
null
null
null
test/pelemay_test.exs
muramasa8191/pelemay
f6b51ad8acc9b6fc66280e238a67364293b2b7d5
[ "Apache-2.0" ]
null
null
null
test/pelemay_test.exs
muramasa8191/pelemay
f6b51ad8acc9b6fc66280e238a67364293b2b7d5
[ "Apache-2.0" ]
null
null
null
defmodule PelemayTest do use ExUnit.Case, async: true doctest Pelemay end
15.6
30
0.782051
7376abb2b30ec50d85e6940ec2675926219f16e7
23,612
ex
Elixir
lib/uuid.ex
ryanwinchester/elixir-uuids
e51629e88331d82ce8099da7cdd5dd8263b69c0d
[ "Apache-2.0" ]
7
2020-10-15T01:39:48.000Z
2022-03-24T16:26:23.000Z
lib/uuid.ex
ryanwinchester/elixir-uuids
e51629e88331d82ce8099da7cdd5dd8263b69c0d
[ "Apache-2.0" ]
11
2020-10-14T17:44:23.000Z
2021-03-12T19:51:39.000Z
lib/uuid.ex
ryanwinchester/elixir-uuids
e51629e88331d82ce8099da7cdd5dd8263b69c0d
[ "Apache-2.0" ]
null
null
null
defmodule UUID do @moduledoc """ UUID generator and utilities for [Elixir](http://elixir-lang.org/). See [RFC 4122](http://www.ietf.org/rfc/rfc4122.txt). """ use Bitwise, only_operators: true alias UUID.Info @typedoc "One of representations of UUID." @type t :: str | raw | hex | urn | slug @typedoc "String representation of UUID." @type str :: <<_::288>> @typedoc "Raw binary representation of UUID." @type raw :: <<_::128>> @typedoc "Hex representation of UUID." @type hex :: <<_::256>> @typedoc "URN representation of UUID." @type urn :: <<_::360>> @typedoc "Slug representation of UUID." @type slug :: String.t() @typedoc "Type of UUID representation." @type type :: :default | :raw | :hex | :urn | :slug @typedoc "UUID version." @type version :: 1 | 3 | 4 | 5 | 6 @typedoc "Variant of UUID: see RFC for the details." @type variant :: :reserved_future | :reserved_microsoft | :rfc4122 | :reserved_ncs @typedoc """ Namespace for UUID v3 and v5 (with some predefined UUIDs as atom aliases). """ @type namespace :: :dns | :url | :oid | :x500 | nil | str @typedoc "Information about given UUID (see `info/1`)" @type info :: UUID.Info.t() # 15 Oct 1582 to 1 Jan 1970. @nanosec_intervals_offset 122_192_928_000_000_000 # Microseconds to nanoseconds factor. @nanosec_intervals_factor 10 # Variant, corresponds to variant 1 0 of RFC 4122. @variant10 2 # UUID identifiers. @uuid_v1 1 @uuid_v3 3 @uuid_v4 4 @uuid_v5 5 @uuid_v6 6 # UUID URN prefix. @urn "urn:uuid:" @spec info(str) :: {:ok, info} | {:error, String.t()} defdelegate info(uuid), to: Info, as: :new @spec info!(str) :: info defdelegate info!(uuid), to: Info, as: :new! @doc """ Convert binary UUID data to a string. Will raise an ArgumentError if the given binary is not valid UUID data, or the format argument is not one of: `:default`, `:hex`, `:urn`, or `:raw`. ## Examples iex> UUID.binary_to_string!(<<135, 13, 248, 232, 49, 7, 68, 135, ...> 131, 22, 129, 224, 137, 184, 194, 207>>) "870df8e8-3107-4487-8316-81e089b8c2cf" iex> UUID.binary_to_string!(<<142, 161, 81, 61, 248, 161, 77, 234, 155, ...> 234, 107, 143, 75, 91, 110, 115>>, :hex) "8ea1513df8a14dea9bea6b8f4b5b6e73" iex> UUID.binary_to_string!(<<239, 27, 26, 40, 238, 52, 17, 227, 136, ...> 19, 20, 16, 159, 241, 163, 4>>, :urn) "urn:uuid:ef1b1a28-ee34-11e3-8813-14109ff1a304" iex> UUID.binary_to_string!(<<39, 73, 196, 181, 29, 90, 74, 96, 157, ...> 47, 171, 144, 84, 164, 155, 52>>, :raw) <<39, 73, 196, 181, 29, 90, 74, 96, 157, 47, 171, 144, 84, 164, 155, 52>> """ @spec binary_to_string!(raw) :: str @spec binary_to_string!(raw, type) :: t def binary_to_string!(uuid, format \\ :default) def binary_to_string!(<<uuid::binary>>, format) do uuid_to_string(<<uuid::binary>>, format) end def binary_to_string!(_, _) do raise ArgumentError, message: "Invalid argument; Expected: <<uuid::128>>" end @doc """ Convert a UUID string to its binary data equivalent. Will raise an ArgumentError if the given string is not a UUID representation in a format like: * `"870df8e8-3107-4487-8316-81e089b8c2cf"` * `"8ea1513df8a14dea9bea6b8f4b5b6e73"` * `"urn:uuid:ef1b1a28-ee34-11e3-8813-14109ff1a304"` ## Examples iex> UUID.string_to_binary!("870df8e8-3107-4487-8316-81e089b8c2cf") <<135, 13, 248, 232, 49, 7, 68, 135, 131, 22, 129, 224, 137, 184, 194, 207>> iex> UUID.string_to_binary!("8ea1513df8a14dea9bea6b8f4b5b6e73") <<142, 161, 81, 61, 248, 161, 77, 234, 155, 234, 107, 143, 75, 91, 110, 115>> iex> UUID.string_to_binary!("urn:uuid:ef1b1a28-ee34-11e3-8813-14109ff1a304") <<239, 27, 26, 40, 238, 52, 17, 227, 136, 19, 20, 16, 159, 241, 163, 4>> iex> UUID.string_to_binary!(<<39, 73, 196, 181, 29, 90, 74, 96, 157, 47, ...> 171, 144, 84, 164, 155, 52>>) <<39, 73, 196, 181, 29, 90, 74, 96, 157, 47, 171, 144, 84, 164, 155, 52>> """ @spec string_to_binary!(str) :: raw def string_to_binary!(<<uuid::binary>>) do {_type, <<uuid::128>>} = uuid_string_to_hex_pair(uuid) <<uuid::128>> end def string_to_binary!(_) do raise ArgumentError, message: "Invalid argument; Expected: String" end @doc """ Generate a new UUID v1. This version uses a combination of one or more of: unix epoch, random bytes, pid hash, and hardware address. ## Examples iex> UUID.uuid1() "cdfdaf44-ee35-11e3-846b-14109ff1a304" iex> UUID.uuid1(:default) "cdfdaf44-ee35-11e3-846b-14109ff1a304" iex> UUID.uuid1(:hex) "cdfdaf44ee3511e3846b14109ff1a304" iex> UUID.uuid1(:urn) "urn:uuid:cdfdaf44-ee35-11e3-846b-14109ff1a304" iex> UUID.uuid1(:raw) <<205, 253, 175, 68, 238, 53, 17, 227, 132, 107, 20, 16, 159, 241, 163, 4>> iex> UUID.uuid1(:slug) "zf2vRO41EeOEaxQQn_GjBA" """ @spec uuid1() :: str @spec uuid1(type) :: t def uuid1(format \\ :default) do uuid1(uuid1_clockseq(), uuid1_node(), format) end @doc """ Generate a new UUID v1, with an existing clock sequence and node address. This version uses a combination of one or more of: unix epoch, random bytes, pid hash, and hardware address. ## Examples iex> UUID.uuid1() "cdfdaf44-ee35-11e3-846b-14109ff1a304" iex> UUID.uuid1(:default) "cdfdaf44-ee35-11e3-846b-14109ff1a304" iex> UUID.uuid1(:hex) "cdfdaf44ee3511e3846b14109ff1a304" iex> UUID.uuid1(:urn) "urn:uuid:cdfdaf44-ee35-11e3-846b-14109ff1a304" iex> UUID.uuid1(:raw) <<205, 253, 175, 68, 238, 53, 17, 227, 132, 107, 20, 16, 159, 241, 163, 4>> iex> UUID.uuid1(:slug) "zf2vRO41EeOEaxQQn_GjBA" """ @spec uuid1(clock_seq :: <<_::14>>, node :: <<_::48>>) :: str @spec uuid1(clock_seq :: <<_::14>>, node :: <<_::48>>, type) :: t def uuid1(clock_seq, node, format \\ :default) def uuid1(<<clock_seq::14>>, <<node::48>>, format) do <<time_hi::12, time_mid::16, time_low::32>> = uuid1_time() <<clock_seq_hi::6, clock_seq_low::8>> = <<clock_seq::14>> <<time_low::32, time_mid::16, @uuid_v1::4, time_hi::12, @variant10::2, clock_seq_hi::6, clock_seq_low::8, node::48>> |> uuid_to_string(format) end def uuid1(_, _, _) do raise ArgumentError, message: "Invalid argument; Expected: <<clock_seq::14>>, <<node::48>>" end @doc """ Generate a new UUID v3. This version uses an MD5 hash of fixed value chosen based on a namespace atom - see Appendix C of [RFC 4122](http://www.ietf.org/rfc/rfc4122.txt) and a name value. Can also be given an existing UUID String instead of a namespace atom. Accepted arguments are: `:dns`|`:url`|`:oid`|`:x500`|`:nil` OR uuid, String ## Examples iex> UUID.uuid3(:dns, "my.domain.com") "03bf0706-b7e9-33b8-aee5-c6142a816478" iex> UUID.uuid3(:dns, "my.domain.com", :default) "03bf0706-b7e9-33b8-aee5-c6142a816478" iex> UUID.uuid3(:dns, "my.domain.com", :hex) "03bf0706b7e933b8aee5c6142a816478" iex> UUID.uuid3(:dns, "my.domain.com", :urn) "urn:uuid:03bf0706-b7e9-33b8-aee5-c6142a816478" iex> UUID.uuid3(:dns, "my.domain.com", :raw) <<3, 191, 7, 6, 183, 233, 51, 184, 174, 229, 198, 20, 42, 129, 100, 120>> iex> UUID.uuid3("cdfdaf44-ee35-11e3-846b-14109ff1a304", "my.domain.com") "8808f33a-3e11-3708-919e-15fba88908db" iex> UUID.uuid3(:dns, "my.domain.com", :slug) "A78HBrfpM7iu5cYUKoFkeA" """ @spec uuid3(namespace, name :: binary) :: str @spec uuid3(namespace, name :: binary, type) :: t def uuid3(namespace_or_uuid, name, format \\ :default) def uuid3(:dns, <<name::binary>>, format) do namebased_uuid(:md5, <<0x6BA7B8109DAD11D180B400C04FD430C8::128, name::binary>>) |> uuid_to_string(format) end def uuid3(:url, <<name::binary>>, format) do namebased_uuid(:md5, <<0x6BA7B8119DAD11D180B400C04FD430C8::128, name::binary>>) |> uuid_to_string(format) end def uuid3(:oid, <<name::binary>>, format) do namebased_uuid(:md5, <<0x6BA7B8129DAD11D180B400C04FD430C8::128, name::binary>>) |> uuid_to_string(format) end def uuid3(:x500, <<name::binary>>, format) do namebased_uuid(:md5, <<0x6BA7B8149DAD11D180B400C04FD430C8::128, name::binary>>) |> uuid_to_string(format) end def uuid3(nil, <<name::binary>>, format) do namebased_uuid(:md5, <<0::128, name::binary>>) |> uuid_to_string(format) end def uuid3(<<uuid::binary>>, <<name::binary>>, format) do {_type, <<uuid::128>>} = uuid_string_to_hex_pair(uuid) namebased_uuid(:md5, <<uuid::128, name::binary>>) |> uuid_to_string(format) end def uuid3(_, _, _) do raise ArgumentError, message: "Invalid argument; Expected: :dns|:url|:oid|:x500|:nil OR String, String" end @doc """ Generate a new UUID v4. This version uses pseudo-random bytes generated by the `crypto` module. ## Examples iex> UUID.uuid4() "fb49a0ec-d60c-4d20-9264-3b4cfe272106" iex> UUID.uuid4(:default) "fb49a0ec-d60c-4d20-9264-3b4cfe272106" iex> UUID.uuid4(:hex) "fb49a0ecd60c4d2092643b4cfe272106" iex> UUID.uuid4(:urn) "urn:uuid:fb49a0ec-d60c-4d20-9264-3b4cfe272106" iex> UUID.uuid4(:raw) <<251, 73, 160, 236, 214, 12, 77, 32, 146, 100, 59, 76, 254, 39, 33, 6>> iex> UUID.uuid4(:slug) "-0mg7NYMTSCSZDtM_ichBg" """ @spec uuid4() :: str @spec uuid4(type | :strong | :weak) :: t def uuid4(), do: uuid4(:default) # For backwards compatibility. def uuid4(:strong), do: uuid4(:default) # For backwards compatibility. def uuid4(:weak), do: uuid4(:default) def uuid4(format) do <<u0::48, _::4, u1::12, _::2, u2::62>> = :crypto.strong_rand_bytes(16) <<u0::48, @uuid_v4::4, u1::12, @variant10::2, u2::62>> |> uuid_to_string(format) end @doc """ Generate a new UUID v5. This version uses an SHA1 hash of fixed value chosen based on a namespace atom - see Appendix C of [RFC 4122](http://www.ietf.org/rfc/rfc4122.txt) and a name value. Can also be given an existing UUID String instead of a namespace atom. Accepted arguments are: `:dns`|`:url`|`:oid`|`:x500`|`:nil` OR uuid, String ## Examples iex> UUID.uuid5(:dns, "my.domain.com") "016c25fd-70e0-56fe-9d1a-56e80fa20b82" iex> UUID.uuid5(:dns, "my.domain.com", :default) "016c25fd-70e0-56fe-9d1a-56e80fa20b82" iex> UUID.uuid5(:dns, "my.domain.com", :hex) "016c25fd70e056fe9d1a56e80fa20b82" iex> UUID.uuid5(:dns, "my.domain.com", :urn) "urn:uuid:016c25fd-70e0-56fe-9d1a-56e80fa20b82" iex> UUID.uuid5(:dns, "my.domain.com", :raw) <<1, 108, 37, 253, 112, 224, 86, 254, 157, 26, 86, 232, 15, 162, 11, 130>> iex> UUID.uuid5("fb49a0ec-d60c-4d20-9264-3b4cfe272106", "my.domain.com") "822cab19-df58-5eb4-98b5-c96c15c76d32" iex> UUID.uuid5("fb49a0ec-d60c-4d20-9264-3b4cfe272106", "my.domain.com", :slug) "giyrGd9YXrSYtclsFcdtMg" """ @spec uuid5(namespace, binary) :: str @spec uuid5(namespace, name :: binary, type) :: t def uuid5(namespace_or_uuid, name, format \\ :default) def uuid5(:dns, <<name::binary>>, format) do namebased_uuid(:sha1, <<0x6BA7B8109DAD11D180B400C04FD430C8::128, name::binary>>) |> uuid_to_string(format) end def uuid5(:url, <<name::binary>>, format) do namebased_uuid(:sha1, <<0x6BA7B8119DAD11D180B400C04FD430C8::128, name::binary>>) |> uuid_to_string(format) end def uuid5(:oid, <<name::binary>>, format) do namebased_uuid(:sha1, <<0x6BA7B8129DAD11D180B400C04FD430C8::128, name::binary>>) |> uuid_to_string(format) end def uuid5(:x500, <<name::binary>>, format) do namebased_uuid(:sha1, <<0x6BA7B8149DAD11D180B400C04FD430C8::128, name::binary>>) |> uuid_to_string(format) end def uuid5(nil, <<name::binary>>, format) do namebased_uuid(:sha1, <<0::128, name::binary>>) |> uuid_to_string(format) end def uuid5(<<uuid::binary>>, <<name::binary>>, format) do {_type, <<uuid::128>>} = uuid_string_to_hex_pair(uuid) namebased_uuid(:sha1, <<uuid::128, name::binary>>) |> uuid_to_string(format) end def uuid5(_, _, _) do raise ArgumentError, message: "Invalid argument; Expected: :dns|:url|:oid|:x500|:nil OR String, String" end @doc """ Generate a new UUID v6. This version uses a combination of one or more of: unix epoch, random bytes, pid hash, and hardware address. Accepts a `node_type` argument that can be either `:mac_address` or `:random_bytes`. Defaults to `:random_bytes`. See the [RFC draft, section 3.3](https://tools.ietf.org/html/draft-peabody-dispatch-new-uuid-format-00#section-3.3) for more information on the node parts. ## Examples iex> UUID.uuid6() "1eb0d28f-da4c-6eb2-adc1-0242ac120002" iex> UUID.uuid6(:random_bytes, :default) "1eb0d297-eb1e-62a6-a37f-a55eda5dd6e4" iex> UUID.uuid6(:random_bytes, :hex) "1eb0d298502563fcadcd25e5d0a44c1a" iex> UUID.uuid6(:random_bytes, :urn) "urn:uuid:1eb0d298-ca10-6914-ab0e-7d7e1e6e1808" iex> UUID.uuid6(:random_bytes, :raw) <<30, 176, 210, 153, 52, 23, 102, 230, 164, 146, 99, 66, 4, 72, 220, 114>> iex> UUID.uuid6(:random_bytes, :slug) "HrDSmab8ZnqR4SKw4LN-UA" """ @spec uuid6() :: str @spec uuid6(:random_bytes | :mac_address) :: str @spec uuid6(:random_bytes | :mac_address, type) :: t def uuid6(node_type \\ :random_bytes, format \\ :default) when node_type in [:mac_address, :random_bytes] do uuid6(uuid1_clockseq(), uuid6_node(node_type), format) end @doc """ Generate a new UUID v6, with an existing clock sequence and node address. This version uses a combination of one or more of: unix epoch, random bytes, pid hash, and hardware address. """ def uuid6(<<clock_seq::14>>, <<node::48>>, format) do <<time_hi::12, time_mid::16, time_low::32>> = uuid1_time() <<time_low1::20, time_low2::12>> = <<time_low::32>> <<clock_seq_hi::6, clock_seq_low::8>> = <<clock_seq::14>> <<time_hi::12, time_mid::16, time_low1::20, @uuid_v6::4, time_low2::12, @variant10::2, clock_seq_hi::6, clock_seq_low::8, node::48>> |> uuid_to_string(format) end def uuid6(_, _, _) do raise ArgumentError, message: "Invalid argument; Expected: <<clock_seq::14>>, <<node::48>>" end @doc """ Convert a UUID v1 to a UUID v6 in the same format. ## Examples iex> UUID.uuid1_to_uuid6("dafc431a-0d21-11eb-adc1-0242ac120002") "1eb0d21d-afc4-631a-adc1-0242ac120002" iex> UUID.uuid1_to_uuid6("2vxDGg0hEeutwQJCrBIAAg") "HrDSHa_EYxqtwQJCrBIAAg" iex> UUID.uuid1_to_uuid6(<<218, 252, 67, 26, 13, 33, 17, 235, 173, 193, 2, 66, 172, 18, 0, 2>>) <<30, 176, 210, 29, 175, 196, 99, 26, 173, 193, 2, 66, 172, 18, 0, 2>> """ def uuid1_to_uuid6(uuid1) do {format, ub1} = uuid_string_to_hex_pair(uuid1) <<time_low::32, time_mid::16, @uuid_v1::4, time_hi::12, rest::binary>> = ub1 <<time_low1::20, time_low2::12>> = <<time_low::32>> <<time_hi::12, time_mid::16, time_low1::20, @uuid_v6::4, time_low2::12, rest::binary>> |> uuid_to_string(format) end @doc """ Convert a UUID v6 to a UUID v1 in the same format. ## Examples iex> UUID.uuid6_to_uuid1("1eb0d21d-afc4-631a-adc1-0242ac120002") "dafc431a-0d21-11eb-adc1-0242ac120002" iex> UUID.uuid6_to_uuid1("HrDSHa_EYxqtwQJCrBIAAg") "2vxDGg0hEeutwQJCrBIAAg" iex> UUID.uuid6_to_uuid1(<<30, 176, 210, 29, 175, 196, 99, 26, 173, 193, 2, 66, 172, 18, 0, 2>>) <<218, 252, 67, 26, 13, 33, 17, 235, 173, 193, 2, 66, 172, 18, 0, 2>> """ def uuid6_to_uuid1(uuid6) do {format, ub6} = uuid_string_to_hex_pair(uuid6) <<time_hi::12, time_mid::16, time_low1::20, @uuid_v6::4, time_low2::12, rest::binary>> = ub6 <<time_low::32>> = <<time_low1::20, time_low2::12>> <<time_low::32, time_mid::16, @uuid_v1::4, time_hi::12, rest::binary>> |> uuid_to_string(format) end @doc """ Validate a RFC4122 UUID. """ @spec valid?(binary, 0..6 | String.t()) :: boolean def valid?(uuid, version \\ "[0-6]") def valid?(uuid, version) when version in 0..6 or version == "[0-6]" do case info(uuid) do {:ok, info} -> ~r/^[0-9a-f]{8}-[0-9a-f]{4}-#{version}[0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i |> Regex.match?(uuid_to_string_default(info.binary)) {:error, _} -> false end end def valid?(_, _), do: false @doc """ Identify the UUID variant according to section 4.1.1 of RFC 4122. ## Examples iex> UUID.variant(<<1, 1, 1>>) :reserved_future iex> UUID.variant(<<1, 1, 0>>) :reserved_microsoft iex> UUID.variant(<<1, 0, 0>>) :rfc4122 iex> UUID.variant(<<0, 1, 1>>) :reserved_ncs iex> UUID.variant(<<1>>) ** (ArgumentError) Invalid argument; Not valid variant bits """ @spec variant(binary) :: variant() def variant(<<1, 1, 1>>), do: :reserved_future def variant(<<1, 1, _v>>), do: :reserved_microsoft def variant(<<1, 0, _v>>), do: :rfc4122 def variant(<<0, _v::2-binary>>), do: :reserved_ncs def variant(_), do: raise(ArgumentError, message: "Invalid argument; Not valid variant bits") # ---------------------------------------------------------------------------- # Internal utility functions. # ---------------------------------------------------------------------------- # Convert UUID bytes to String. defp uuid_to_string(<<_::128>> = u, :default) do uuid_to_string_default(u) end defp uuid_to_string(<<_::128>> = u, :hex) do IO.iodata_to_binary(for <<part::4 <- u>>, do: e(part)) end defp uuid_to_string(<<_::128>> = u, :urn) do @urn <> uuid_to_string(u, :default) end defp uuid_to_string(<<_::128>> = u, :raw) do u end defp uuid_to_string(<<_::128>> = u, :slug) do Base.url_encode64(u, padding: false) end defp uuid_to_string(_u, format) when format in [:default, :hex, :urn, :slug] do raise ArgumentError, message: "Invalid binary data; Expected: <<uuid::128>>" end defp uuid_to_string(_u, format) do raise ArgumentError, message: "Invalid format #{format}; Expected: :default|:hex|:urn|:slug" end defp uuid_to_string_default(<<_::128>> = uuid) do <<a1::4, a2::4, a3::4, a4::4, a5::4, a6::4, a7::4, a8::4, b1::4, b2::4, b3::4, b4::4, c1::4, c2::4, c3::4, c4::4, d1::4, d2::4, d3::4, d4::4, e1::4, e2::4, e3::4, e4::4, e5::4, e6::4, e7::4, e8::4, e9::4, e10::4, e11::4, e12::4>> = uuid <<e(a1), e(a2), e(a3), e(a4), e(a5), e(a6), e(a7), e(a8), ?-, e(b1), e(b2), e(b3), e(b4), ?-, e(c1), e(c2), e(c3), e(c4), ?-, e(d1), e(d2), e(d3), e(d4), ?-, e(e1), e(e2), e(e3), e(e4), e(e5), e(e6), e(e7), e(e8), e(e9), e(e10), e(e11), e(e12)>> end @compile {:inline, e: 1} defp e(0), do: ?0 defp e(1), do: ?1 defp e(2), do: ?2 defp e(3), do: ?3 defp e(4), do: ?4 defp e(5), do: ?5 defp e(6), do: ?6 defp e(7), do: ?7 defp e(8), do: ?8 defp e(9), do: ?9 defp e(10), do: ?a defp e(11), do: ?b defp e(12), do: ?c defp e(13), do: ?d defp e(14), do: ?e defp e(15), do: ?f @doc """ Extract the type (:default etc) and pure byte value from a UUID String. """ @spec uuid_string_to_hex_pair(t) :: {type, raw} def uuid_string_to_hex_pair(<<_::128>> = uuid) do {:raw, uuid} end def uuid_string_to_hex_pair(<<uuid_in::binary>>) do uuid = String.downcase(uuid_in) {type, hex_str} = case uuid do <<u0::64, ?-, u1::32, ?-, u2::32, ?-, u3::32, ?-, u4::96>> -> {:default, <<u0::64, u1::32, u2::32, u3::32, u4::96>>} <<u::256>> -> {:hex, <<u::256>>} <<@urn, u0::64, ?-, u1::32, ?-, u2::32, ?-, u3::32, ?-, u4::96>> -> {:urn, <<u0::64, u1::32, u2::32, u3::32, u4::96>>} _ -> case uuid_in do _ when byte_size(uuid_in) == 22 -> case Base.url_decode64(uuid_in <> "==") do {:ok, decoded} -> {:slug, Base.encode16(decoded)} _ -> raise ArgumentError, message: "Invalid argument; Not a valid UUID: #{uuid}" end _ -> raise ArgumentError, message: "Invalid argument; Not a valid UUID: #{uuid}" end end try do {type, hex_str_to_binary(hex_str)} catch _, _ -> raise ArgumentError, message: "Invalid argument; Not a valid UUID: #{uuid}" end end # Get unix epoch as a 60-bit timestamp. defp uuid1_time() do {mega_sec, sec, micro_sec} = :os.timestamp() epoch = mega_sec * 1_000_000_000_000 + sec * 1_000_000 + micro_sec timestamp = @nanosec_intervals_offset + @nanosec_intervals_factor * epoch <<timestamp::60>> end # Generate random clock sequence. defp uuid1_clockseq() do <<rnd::14, _::2>> = :crypto.strong_rand_bytes(2) <<rnd::14>> end # Get local IEEE 802 (MAC) address, or a random node id if it can't be found. defp uuid1_node() do {:ok, ifs0} = :inet.getifaddrs() uuid1_node(ifs0) end defp uuid1_node([{_if_name, if_config} | rest]) do case :lists.keyfind(:hwaddr, 1, if_config) do false -> uuid1_node(rest) {:hwaddr, hw_addr} -> if length(hw_addr) != 6 or Enum.all?(hw_addr, fn n -> n == 0 end) do uuid1_node(rest) else :erlang.list_to_binary(hw_addr) end end end defp uuid1_node(_) do <<rnd_hi::7, _::1, rnd_low::40>> = :crypto.strong_rand_bytes(6) <<rnd_hi::7, 1::1, rnd_low::40>> end defp uuid6_node(:mac_address) do uuid1_node() end defp uuid6_node(:random_bytes) do :crypto.strong_rand_bytes(6) end # Generate a hash of the given data. defp namebased_uuid(:md5, data) do md5 = :crypto.hash(:md5, data) compose_namebased_uuid(@uuid_v3, md5) end defp namebased_uuid(:sha1, data) do <<sha1::128, _::32>> = :crypto.hash(:sha, data) compose_namebased_uuid(@uuid_v5, <<sha1::128>>) end # Format the given hash as a UUID. defp compose_namebased_uuid(version, hash) do <<time_low::32, time_mid::16, _::4, time_hi::12, _::2, clock_seq_hi::6, clock_seq_low::8, node::48>> = hash <<time_low::32, time_mid::16, version::4, time_hi::12, @variant10::2, clock_seq_hi::6, clock_seq_low::8, node::48>> end defp hex_str_to_binary( <<a1, a2, a3, a4, a5, a6, a7, a8, b1, b2, b3, b4, c1, c2, c3, c4, d1, d2, d3, d4, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12>> ) do <<d(a1)::4, d(a2)::4, d(a3)::4, d(a4)::4, d(a5)::4, d(a6)::4, d(a7)::4, d(a8)::4, d(b1)::4, d(b2)::4, d(b3)::4, d(b4)::4, d(c1)::4, d(c2)::4, d(c3)::4, d(c4)::4, d(d1)::4, d(d2)::4, d(d3)::4, d(d4)::4, d(e1)::4, d(e2)::4, d(e3)::4, d(e4)::4, d(e5)::4, d(e6)::4, d(e7)::4, d(e8)::4, d(e9)::4, d(e10)::4, d(e11)::4, d(e12)::4>> end @compile {:inline, d: 1} defp d(?0), do: 0 defp d(?1), do: 1 defp d(?2), do: 2 defp d(?3), do: 3 defp d(?4), do: 4 defp d(?5), do: 5 defp d(?6), do: 6 defp d(?7), do: 7 defp d(?8), do: 8 defp d(?9), do: 9 defp d(?A), do: 10 defp d(?B), do: 11 defp d(?C), do: 12 defp d(?D), do: 13 defp d(?E), do: 14 defp d(?F), do: 15 defp d(?a), do: 10 defp d(?b), do: 11 defp d(?c), do: 12 defp d(?d), do: 13 defp d(?e), do: 14 defp d(?f), do: 15 defp d(_), do: throw(:error) end
30.664935
117
0.60626
7376b9ed6a5b2d584cc1cbcaa8d9753d61962a9b
1,746
ex
Elixir
clients/bigtable_admin/lib/google_api/bigtable_admin/v2/model/restore_info.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/bigtable_admin/lib/google_api/bigtable_admin/v2/model/restore_info.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/bigtable_admin/lib/google_api/bigtable_admin/v2/model/restore_info.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "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.BigtableAdmin.V2.Model.RestoreInfo do @moduledoc """ Information about a table restore. ## Attributes * `backupInfo` (*type:* `GoogleApi.BigtableAdmin.V2.Model.BackupInfo.t`, *default:* `nil`) - Information about the backup used to restore the table. The backup may no longer exist. * `sourceType` (*type:* `String.t`, *default:* `nil`) - The type of the restore source. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :backupInfo => GoogleApi.BigtableAdmin.V2.Model.BackupInfo.t() | nil, :sourceType => String.t() | nil } field(:backupInfo, as: GoogleApi.BigtableAdmin.V2.Model.BackupInfo) field(:sourceType) end defimpl Poison.Decoder, for: GoogleApi.BigtableAdmin.V2.Model.RestoreInfo do def decode(value, options) do GoogleApi.BigtableAdmin.V2.Model.RestoreInfo.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.BigtableAdmin.V2.Model.RestoreInfo do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
34.92
184
0.73425
7376bba19fb82bdcf594655f2e9d0f3e35bdc8ba
283
exs
Elixir
backend/priv/repo/migrations/20190801185906_add_batch_size_and_spawn_columns.exs
ui-icts/aptamer-web
a28502c22a4e55ab1fbae8bbeaa6b11c9a477c06
[ "MIT" ]
null
null
null
backend/priv/repo/migrations/20190801185906_add_batch_size_and_spawn_columns.exs
ui-icts/aptamer-web
a28502c22a4e55ab1fbae8bbeaa6b11c9a477c06
[ "MIT" ]
7
2019-02-08T18:28:49.000Z
2022-02-12T06:44:59.000Z
backend/priv/repo/migrations/20190801185906_add_batch_size_and_spawn_columns.exs
ui-icts/aptamer-web
a28502c22a4e55ab1fbae8bbeaa6b11c9a477c06
[ "MIT" ]
null
null
null
defmodule Aptamer.Repo.Migrations.AddBatchSizeAndSpawnColumns do use Ecto.Migration def change do alter table(:create_graph_options) do add(:spawn, :boolean, default: true, null: false) add(:batch_size, :integer, default: 10_000, null: false) end end end
23.583333
64
0.720848
7376e5a7f301575543efb894e1364fb081639119
1,477
ex
Elixir
pub_sub_test/lib/pub_sub_test_web/endpoint.ex
KeenMate/phoenix-websocket-auction
412148ad5621b511c0690b9395f4b6c9ce3a3352
[ "MIT" ]
null
null
null
pub_sub_test/lib/pub_sub_test_web/endpoint.ex
KeenMate/phoenix-websocket-auction
412148ad5621b511c0690b9395f4b6c9ce3a3352
[ "MIT" ]
null
null
null
pub_sub_test/lib/pub_sub_test_web/endpoint.ex
KeenMate/phoenix-websocket-auction
412148ad5621b511c0690b9395f4b6c9ce3a3352
[ "MIT" ]
null
null
null
defmodule PubSubTestWeb.Endpoint do use Phoenix.Endpoint, otp_app: :pub_sub_test # The session will be stored in the cookie and signed, # this means its contents can be read but not tampered with. # Set :encryption_salt if you would also like to encrypt it. @session_options [ store: :cookie, key: "_pub_sub_test_key", signing_salt: "5UgIZ6W1" ] socket "/socket", PubSubTestWeb.UserSocket, websocket: true, longpoll: false socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]] # Serve at "/" the static files from "priv/static" directory. # # You should set gzip to true if you are running phx.digest # when deploying your static files in production. plug Plug.Static, at: "/", from: :pub_sub_test, gzip: false, only: ~w(css fonts images js favicon.ico robots.txt) # Code reloading can be explicitly enabled under the # :code_reloader configuration of your endpoint. if code_reloading? do plug Phoenix.CodeReloader end plug Phoenix.LiveDashboard.RequestLogger, param_key: "request_logger", cookie_key: "request_logger" plug Plug.RequestId plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint] plug Plug.Parsers, parsers: [:urlencoded, :multipart, :json], pass: ["*/*"], json_decoder: Phoenix.json_library() plug Plug.MethodOverride plug Plug.Head plug Plug.Session, @session_options plug PubSubTestWeb.Router end
28.403846
97
0.716994
7376f1541cd9d1d625d013e26ead2e4a5d391780
2,396
ex
Elixir
lib/knock.ex
aglassman/knock-elixir
2bd813f2e34d635dbd2634d6b0961dadeff02f8d
[ "MIT" ]
11
2021-05-10T10:31:17.000Z
2022-03-22T18:29:31.000Z
lib/knock.ex
aglassman/knock-elixir
2bd813f2e34d635dbd2634d6b0961dadeff02f8d
[ "MIT" ]
1
2021-11-04T21:34:34.000Z
2021-11-04T21:34:34.000Z
lib/knock.ex
aglassman/knock-elixir
2bd813f2e34d635dbd2634d6b0961dadeff02f8d
[ "MIT" ]
3
2021-11-01T22:36:56.000Z
2022-03-24T09:50:19.000Z
defmodule Knock do @moduledoc """ Official SDK for interacting with Knock. ## Example usage ### As a module The recommended way to configure Knock is as a module in your application. Doing so will allow you to customize the options via configuration in your app. ```elixir # lib/my_app/knock.ex defmodule MyApp.Knock do use Knock, otp_app: :my_app end # config/runtime.exs config :my_app, MyApp.KnockClient, api_key: System.get_env("KNOCK_API_KEY") ``` In your application you can now execute commands on your configured Knock instance. ```elixir client = MyApp.Knock.client() {:ok, user} = Knock.Users.get_user(client, "user_1") ``` ### Invoking directly Optionally you can forgo implementing your own Knock module and create client instances manually: ```elixir client = Knock.Client.new(api_key: "sk_test_12345") ``` ### Customizing options Out of the box the client will specify Tesla and Jason as the HTTP adapter and JSON client, respectively. However, you can customize this at will: ```elixir config :my_app, Knock, adapter: Tesla.Adapter.Finch, json_client: JSX ``` You can read more about the availble adapters in the [Tesla documentation](https://hexdocs.pm/tesla/readme.html#adapters) """ defmacro __using__(opts) do quote do @app_name Keyword.fetch!(unquote(opts), :otp_app) @api_key_env_var "KNOCK_API_KEY" alias Knock.Client @doc """ Creates a new client, reading the configuration set for this applicaton and module in the process """ def client(overrides \\ []) do overrides |> fetch_options() |> Client.new() end defp fetch_options(overrides) do Application.get_env(@app_name, __MODULE__, []) |> maybe_resolve_api_key() |> Keyword.merge(overrides) end defp maybe_resolve_api_key(opts) do case Keyword.get(opts, :api_key) do api_key when is_binary(api_key) -> opts {:system, var_name} -> Keyword.put(opts, :api_key, System.get_env(var_name)) _ -> Keyword.put(opts, :api_key, System.get_env(@api_key_env_var)) end end end end @doc """ Issues a notify call, triggering a workflow with the given key. """ defdelegate notify(client, key, properties), to: Knock.Workflows, as: :trigger end
25.763441
123
0.670701
7376f5397fe76bd40d50e5e7fcb4fd956f912799
1,040
ex
Elixir
bricks/lib/errors/unknown_options.ex
jjl/bricks.ex
318db55c0b316fe88c701a962d8a3fd24019130e
[ "Apache-2.0" ]
null
null
null
bricks/lib/errors/unknown_options.ex
jjl/bricks.ex
318db55c0b316fe88c701a962d8a3fd24019130e
[ "Apache-2.0" ]
null
null
null
bricks/lib/errors/unknown_options.ex
jjl/bricks.ex
318db55c0b316fe88c701a962d8a3fd24019130e
[ "Apache-2.0" ]
null
null
null
# Copyright (c) 2018 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 Bricks.Error.UnknownOptions do @moduledoc """ Some unrecognised options were provided """ @enforce_keys [:keys] defstruct @enforce_keys alias Bricks.Error.UnknownOptions @typedoc "Some unrecognised options were provided" @type t :: %UnknownOptions{ keys: [term()] } @spec new([term()]) :: t() @doc "Creates a new `UnknownOptions` from the given `keys`" def new(keys), do: %UnknownOptions{keys: keys} end
31.515152
74
0.720192
7376fe06cda2437a4cff6dcd62cd1091a9b762f0
473
ex
Elixir
lib/absinthe_trace_reporter/context.ex
maartenvanvliet/absinthe_trace_reporter
237d508286b63f09862aec11accfe183b0792876
[ "MIT" ]
11
2018-12-13T08:40:48.000Z
2020-11-10T00:06:18.000Z
lib/absinthe_trace_reporter/context.ex
maartenvanvliet/absinthe_trace_reporter
237d508286b63f09862aec11accfe183b0792876
[ "MIT" ]
14
2019-02-27T04:25:35.000Z
2021-12-20T04:02:05.000Z
lib/absinthe_trace_reporter/context.ex
maartenvanvliet/absinthe_trace_reporter
237d508286b63f09862aec11accfe183b0792876
[ "MIT" ]
2
2019-03-23T18:44:11.000Z
2020-05-27T14:07:41.000Z
defmodule AbsintheTraceReporter.Context do def init(opts), do: opts def call(conn, _) do info = build_trace_info(conn) conn = Absinthe.Plug.put_options(conn, %{a: 1}) options = Map.merge(conn.private[:absinthe], info) conn = Absinthe.Plug.put_options(conn, context: options) end def build_trace_info(conn) do %{ trace_info: %{ path: conn.request_path, host: conn.host, method: conn.method } } end end
22.52381
60
0.638478
73771b3e817fe6cdb63d74d1048cb3fc23529277
1,822
exs
Elixir
test/core/sup_tree_core/executor_pool/usage_reporter_test.exs
sylph01/antikythera
47a93f3d4c70975f7296725c9bde2ea823867436
[ "Apache-2.0" ]
144
2018-04-27T07:24:49.000Z
2022-03-15T05:19:37.000Z
test/core/sup_tree_core/executor_pool/usage_reporter_test.exs
sylph01/antikythera
47a93f3d4c70975f7296725c9bde2ea823867436
[ "Apache-2.0" ]
123
2018-05-01T02:54:43.000Z
2022-01-28T01:30:52.000Z
test/core/sup_tree_core/executor_pool/usage_reporter_test.exs
sylph01/antikythera
47a93f3d4c70975f7296725c9bde2ea823867436
[ "Apache-2.0" ]
14
2018-05-01T02:30:47.000Z
2022-02-21T04:38:56.000Z
# Copyright(c) 2015-2021 ACCESS CO., LTD. All rights reserved. defmodule AntikytheraCore.ExecutorPool.UsageReporterTest do use Croma.TestCase alias Antikythera.Time alias Antikythera.Test.ProcessHelper alias Antikythera.Test.GenServerHelper alias AntikytheraCore.ExecutorPool alias AntikytheraCore.ExecutorPool.Setting, as: EPoolSetting alias AntikytheraCore.Metrics.AggregateStrategy.Gauge @epool_id {:gear, :testgear} setup do {:ok, exec_pool_pid} = ExecutorPool.start_link(@epool_id, self(), EPoolSetting.default()) {_, pid, _, _} = Supervisor.which_children(exec_pool_pid) |> Enum.find(&match?({UsageReporter, _, :worker, _}, &1)) ExecutorPoolHelper.wait_until_async_job_queue_added(@epool_id) on_exit(fn -> ExecutorPoolHelper.kill_and_wait(@epool_id, fn -> :auto_killed_and_do_nothing end) end) {:ok, [pid: pid]} end test "should report usage metrics of its sibling PoolSup.Multi and PoolSup processes", context do t0 = Time.now() ProcessHelper.flush() send(context[:pid], :timeout) {t, data_list, @epool_id} = GenServerHelper.receive_cast_message() assert t0 <= t assert Enum.any?(data_list, &match?({"epool_working_action_runner_count", Gauge, 0}, &1)) assert Enum.any?(data_list, &match?({"epool_working_action_runner_%", Gauge, 0.0}, &1)) assert Enum.any?(data_list, &match?({"epool_working_job_runner_count", Gauge, 0}, &1)) assert Enum.any?(data_list, &match?({"epool_working_job_runner_%", Gauge, 0.0}, &1)) assert Enum.any?(data_list, &match?({"epool_websocket_connections_count", Gauge, 0}, &1)) assert Enum.any?(data_list, &match?({"epool_websocket_connections_%", Gauge, 0.0}, &1)) assert Enum.any?(data_list, &match?({"epool_websocket_rejected_count", Gauge, 0}, &1)) end end
39.608696
93
0.717344
73775aab048d1c6dc7f89b2b9dfaada69a98f8a4
256
ex
Elixir
lib/liquex/render/tag.ex
merchant-ly/liquex
3ba72f82e9c2c57f11ef045a2028a5fc1add0d93
[ "MIT" ]
19
2020-02-29T01:37:11.000Z
2022-03-15T06:45:20.000Z
lib/liquex/render/tag.ex
merchant-ly/liquex
3ba72f82e9c2c57f11ef045a2028a5fc1add0d93
[ "MIT" ]
19
2020-09-02T19:35:08.000Z
2022-03-31T21:42:16.000Z
lib/liquex/render/tag.ex
merchant-ly/liquex
3ba72f82e9c2c57f11ef045a2028a5fc1add0d93
[ "MIT" ]
4
2020-10-20T08:22:43.000Z
2022-01-19T17:21:32.000Z
defmodule Liquex.Render.Tag do @moduledoc false @behaviour Liquex.Render @impl Liquex.Render def render({{:custom_tag, module}, contents}, context) when is_atom(module), do: module.render(contents, context) def render(_, _), do: false end
21.333333
78
0.71875
73775b50c1369e15886e08a19f6cda13ed9d4696
128,197
ex
Elixir
clients/app_engine/lib/google_api/app_engine/v1/api/apps.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/app_engine/lib/google_api/app_engine/v1/api/apps.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/app_engine/lib/google_api/app_engine/v1/api/apps.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.AppEngine.V1.Api.Apps do @moduledoc """ API calls for all endpoints tagged `Apps`. """ alias GoogleApi.AppEngine.V1.Connection alias GoogleApi.Gax.{Request, Response} @doc """ Creates an App Engine application for a Google Cloud Platform project. Required fields: id - The ID of the target Cloud Platform project. location - The region (https://cloud.google.com/appengine/docs/locations) where you want the App Engine application located.For more information about App Engine applications, see Managing Projects, Applications, and Billing (https://cloud.google.com/appengine/docs/standard/python/console/). ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.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"). * `:body` (*type:* `GoogleApi.AppEngine.V1.Model.Application.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_create(Tesla.Env.client(), keyword(), keyword()) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_create(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, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/apps", %{}) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Operation{}]) end @doc """ Gets information about an application. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the Application resource to get. Example: apps/myapp. * `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.AppEngine.V1.Model.Application{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_get(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.AppEngine.V1.Model.Application.t()} | {:error, Tesla.Env.t()} def appengine_apps_get(connection, apps_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Application{}]) end @doc """ Updates the specified Application resource. You can update the following fields: auth_domain - Google authentication domain for controlling user access to the application. default_cookie_expiration - Cookie expiration policy for the application. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the Application resource to update. Example: apps/myapp. * `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`) - Standard field mask for the set of fields to be updated. * `:body` (*type:* `GoogleApi.AppEngine.V1.Model.Application.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_patch(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_patch(connection, apps_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :updateMask => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v1/apps/{appsId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Operation{}]) end @doc """ Recreates the required App Engine features for the specified App Engine application, for example a Cloud Storage bucket or App Engine service account. Use this method if you receive an error message about a missing feature, for example, Error retrieving the App Engine service account. If you have deleted your App Engine service account, this will not be able to recreate it. Instead, you should attempt to use the IAM undelete API if possible at https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/undelete?apix_params=%7B"name"%3A"projects%2F-%2FserviceAccounts%2Funique_id"%2C"resource"%3A%7B%7D%7D . If the deletion was recent, the numeric ID can be found in the Cloud Console Activity Log. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the application to repair. Example: apps/myapp * `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.AppEngine.V1.Model.RepairApplicationRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_repair(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_repair(connection, apps_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/apps/{appsId}:repair", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Operation{}]) end @doc """ Uploads the specified SSL certificate. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `parent`. Name of the parent Application resource. Example: apps/myapp. * `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.AppEngine.V1.Model.AuthorizedCertificate.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.AuthorizedCertificate{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_authorized_certificates_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.AuthorizedCertificate.t()} | {:error, Tesla.Env.t()} def appengine_apps_authorized_certificates_create( connection, apps_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/apps/{appsId}/authorizedCertificates", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.AuthorizedCertificate{}]) end @doc """ Deletes the specified SSL certificate. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource to delete. Example: apps/myapp/authorizedCertificates/12345. * `authorized_certificates_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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.AppEngine.V1.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_authorized_certificates_delete( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Empty.t()} | {:error, Tesla.Env.t()} def appengine_apps_authorized_certificates_delete( connection, apps_id, authorized_certificates_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v1/apps/{appsId}/authorizedCertificates/{authorizedCertificatesId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "authorizedCertificatesId" => URI.encode(authorized_certificates_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Empty{}]) end @doc """ Gets the specified SSL certificate. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource requested. Example: apps/myapp/authorizedCertificates/12345. * `authorized_certificates_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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"). * `:view` (*type:* `String.t`) - Controls the set of fields returned in the GET response. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.AuthorizedCertificate{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_authorized_certificates_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.AuthorizedCertificate.t()} | {:error, Tesla.Env.t()} def appengine_apps_authorized_certificates_get( connection, apps_id, authorized_certificates_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :view => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/authorizedCertificates/{authorizedCertificatesId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "authorizedCertificatesId" => URI.encode(authorized_certificates_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.AuthorizedCertificate{}]) end @doc """ Lists all SSL certificates the user is authorized to administer. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `parent`. Name of the parent Application resource. Example: apps/myapp. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:pageSize` (*type:* `integer()`) - Maximum results to return per page. * `:pageToken` (*type:* `String.t`) - Continuation token for fetching the next page of results. * `:view` (*type:* `String.t`) - Controls the set of fields returned in the LIST response. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.ListAuthorizedCertificatesResponse{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_authorized_certificates_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.ListAuthorizedCertificatesResponse.t()} | {:error, Tesla.Env.t()} def appengine_apps_authorized_certificates_list( connection, apps_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :pageSize => :query, :pageToken => :query, :view => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/authorizedCertificates", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.AppEngine.V1.Model.ListAuthorizedCertificatesResponse{}] ) end @doc """ Updates the specified SSL certificate. To renew a certificate and maintain its existing domain mappings, update certificate_data with a new certificate. The new certificate must be applicable to the same domains as the original certificate. The certificate display_name may also be updated. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource to update. Example: apps/myapp/authorizedCertificates/12345. * `authorized_certificates_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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`) - Standard field mask for the set of fields to be updated. Updates are only supported on the certificate_raw_data and display_name fields. * `:body` (*type:* `GoogleApi.AppEngine.V1.Model.AuthorizedCertificate.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.AuthorizedCertificate{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_authorized_certificates_patch( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.AuthorizedCertificate.t()} | {:error, Tesla.Env.t()} def appengine_apps_authorized_certificates_patch( connection, apps_id, authorized_certificates_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :updateMask => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v1/apps/{appsId}/authorizedCertificates/{authorizedCertificatesId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "authorizedCertificatesId" => URI.encode(authorized_certificates_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.AuthorizedCertificate{}]) end @doc """ Lists all domains the user is authorized to administer. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `parent`. Name of the parent Application resource. Example: apps/myapp. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:pageSize` (*type:* `integer()`) - Maximum results to return per page. * `:pageToken` (*type:* `String.t`) - Continuation token for fetching the next page of results. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.ListAuthorizedDomainsResponse{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_authorized_domains_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.ListAuthorizedDomainsResponse.t()} | {:error, Tesla.Env.t()} def appengine_apps_authorized_domains_list( connection, apps_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/authorizedDomains", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.AppEngine.V1.Model.ListAuthorizedDomainsResponse{}] ) end @doc """ Maps a domain to an application. A user must be authorized to administer a domain in order to map it to an application. For a list of available authorized domains, see AuthorizedDomains.ListAuthorizedDomains. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `parent`. Name of the parent Application resource. Example: apps/myapp. * `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"). * `:overrideStrategy` (*type:* `String.t`) - Whether the domain creation should override any existing mappings for this domain. By default, overrides are rejected. * `:body` (*type:* `GoogleApi.AppEngine.V1.Model.DomainMapping.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_domain_mappings_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_domain_mappings_create( connection, apps_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :overrideStrategy => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/apps/{appsId}/domainMappings", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Operation{}]) end @doc """ Deletes the specified domain mapping. A user must be authorized to administer the associated domain in order to delete a DomainMapping resource. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource to delete. Example: apps/myapp/domainMappings/example.com. * `domain_mappings_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_domain_mappings_delete( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_domain_mappings_delete( connection, apps_id, domain_mappings_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v1/apps/{appsId}/domainMappings/{domainMappingsId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "domainMappingsId" => URI.encode(domain_mappings_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Operation{}]) end @doc """ Gets the specified domain mapping. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource requested. Example: apps/myapp/domainMappings/example.com. * `domain_mappings_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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.AppEngine.V1.Model.DomainMapping{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_domain_mappings_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.DomainMapping.t()} | {:error, Tesla.Env.t()} def appengine_apps_domain_mappings_get( connection, apps_id, domain_mappings_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/domainMappings/{domainMappingsId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "domainMappingsId" => URI.encode(domain_mappings_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.DomainMapping{}]) end @doc """ Lists the domain mappings on an application. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `parent`. Name of the parent Application resource. Example: apps/myapp. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:pageSize` (*type:* `integer()`) - Maximum results to return per page. * `:pageToken` (*type:* `String.t`) - Continuation token for fetching the next page of results. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.ListDomainMappingsResponse{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_domain_mappings_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.AppEngine.V1.Model.ListDomainMappingsResponse.t()} | {:error, Tesla.Env.t()} def appengine_apps_domain_mappings_list(connection, apps_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/domainMappings", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.AppEngine.V1.Model.ListDomainMappingsResponse{}] ) end @doc """ Updates the specified domain mapping. To map an SSL certificate to a domain mapping, update certificate_id to point to an AuthorizedCertificate resource. A user must be authorized to administer the associated domain in order to update a DomainMapping resource. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource to update. Example: apps/myapp/domainMappings/example.com. * `domain_mappings_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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`) - Standard field mask for the set of fields to be updated. * `:body` (*type:* `GoogleApi.AppEngine.V1.Model.DomainMapping.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_domain_mappings_patch( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_domain_mappings_patch( connection, apps_id, domain_mappings_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :updateMask => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v1/apps/{appsId}/domainMappings/{domainMappingsId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "domainMappingsId" => URI.encode(domain_mappings_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Operation{}]) end @doc """ Replaces the entire firewall ruleset in one bulk operation. This overrides and replaces the rules of an existing firewall with the new rules.If the final rule does not match traffic with the '*' wildcard IP range, then an "allow all" rule is explicitly added to the end of the list. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the Firewall collection to set. Example: apps/myapp/firewall/ingressRules. * `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.AppEngine.V1.Model.BatchUpdateIngressRulesRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.BatchUpdateIngressRulesResponse{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_firewall_ingress_rules_batch_update( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.BatchUpdateIngressRulesResponse.t()} | {:error, Tesla.Env.t()} def appengine_apps_firewall_ingress_rules_batch_update( connection, apps_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/apps/{appsId}/firewall/ingressRules:batchUpdate", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.AppEngine.V1.Model.BatchUpdateIngressRulesResponse{}] ) end @doc """ Creates a firewall rule for the application. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `parent`. Name of the parent Firewall collection in which to create a new rule. Example: apps/myapp/firewall/ingressRules. * `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.AppEngine.V1.Model.FirewallRule.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.FirewallRule{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_firewall_ingress_rules_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.FirewallRule.t()} | {:error, Tesla.Env.t()} def appengine_apps_firewall_ingress_rules_create( connection, apps_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/apps/{appsId}/firewall/ingressRules", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.FirewallRule{}]) end @doc """ Deletes the specified firewall rule. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the Firewall resource to delete. Example: apps/myapp/firewall/ingressRules/100. * `ingress_rules_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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.AppEngine.V1.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_firewall_ingress_rules_delete( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Empty.t()} | {:error, Tesla.Env.t()} def appengine_apps_firewall_ingress_rules_delete( connection, apps_id, ingress_rules_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v1/apps/{appsId}/firewall/ingressRules/{ingressRulesId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "ingressRulesId" => URI.encode(ingress_rules_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Empty{}]) end @doc """ Gets the specified firewall rule. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the Firewall resource to retrieve. Example: apps/myapp/firewall/ingressRules/100. * `ingress_rules_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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.AppEngine.V1.Model.FirewallRule{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_firewall_ingress_rules_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.FirewallRule.t()} | {:error, Tesla.Env.t()} def appengine_apps_firewall_ingress_rules_get( connection, apps_id, ingress_rules_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/firewall/ingressRules/{ingressRulesId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "ingressRulesId" => URI.encode(ingress_rules_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.FirewallRule{}]) end @doc """ Lists the firewall rules of an application. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `parent`. Name of the Firewall collection to retrieve. Example: apps/myapp/firewall/ingressRules. * `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"). * `:matchingAddress` (*type:* `String.t`) - A valid IP Address. If set, only rules matching this address will be returned. The first returned rule will be the rule that fires on requests from this IP. * `:pageSize` (*type:* `integer()`) - Maximum results to return per page. * `:pageToken` (*type:* `String.t`) - Continuation token for fetching the next page of results. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.ListIngressRulesResponse{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_firewall_ingress_rules_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.ListIngressRulesResponse.t()} | {:error, Tesla.Env.t()} def appengine_apps_firewall_ingress_rules_list( connection, apps_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :matchingAddress => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/firewall/ingressRules", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.ListIngressRulesResponse{}]) end @doc """ Updates the specified firewall rule. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the Firewall resource to update. Example: apps/myapp/firewall/ingressRules/100. * `ingress_rules_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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`) - Standard field mask for the set of fields to be updated. * `:body` (*type:* `GoogleApi.AppEngine.V1.Model.FirewallRule.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.FirewallRule{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_firewall_ingress_rules_patch( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.FirewallRule.t()} | {:error, Tesla.Env.t()} def appengine_apps_firewall_ingress_rules_patch( connection, apps_id, ingress_rules_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :updateMask => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v1/apps/{appsId}/firewall/ingressRules/{ingressRulesId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "ingressRulesId" => URI.encode(ingress_rules_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.FirewallRule{}]) end @doc """ Gets information about a location. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Resource name for the location. * `locations_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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.AppEngine.V1.Model.Location{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_locations_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Location.t()} | {:error, Tesla.Env.t()} def appengine_apps_locations_get( connection, apps_id, locations_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/locations/{locationsId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "locationsId" => URI.encode(locations_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Location{}]) end @doc """ Lists information about the supported locations for this service. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. 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`) - 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.AppEngine.V1.Model.ListLocationsResponse{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_locations_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.AppEngine.V1.Model.ListLocationsResponse.t()} | {:error, Tesla.Env.t()} def appengine_apps_locations_list(connection, apps_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :filter => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/locations", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.ListLocationsResponse{}]) 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.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. The name of the operation resource. * `operations_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_operations_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_operations_get( connection, apps_id, operations_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/operations/{operationsId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "operationsId" => URI.encode(operations_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.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.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. 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.AppEngine.V1.Model.ListOperationsResponse{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_operations_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.AppEngine.V1.Model.ListOperationsResponse.t()} | {:error, Tesla.Env.t()} def appengine_apps_operations_list(connection, apps_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :filter => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/operations", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.ListOperationsResponse{}]) end @doc """ Deletes the specified service and all enclosed versions. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource requested. Example: apps/myapp/services/default. * `services_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_services_delete( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_services_delete( connection, apps_id, services_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v1/apps/{appsId}/services/{servicesId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "servicesId" => URI.encode(services_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Operation{}]) end @doc """ Gets the current configuration of the specified service. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource requested. Example: apps/myapp/services/default. * `services_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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.AppEngine.V1.Model.Service{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_services_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Service.t()} | {:error, Tesla.Env.t()} def appengine_apps_services_get( connection, apps_id, services_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/services/{servicesId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "servicesId" => URI.encode(services_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Service{}]) end @doc """ Lists all the services in the application. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `parent`. Name of the parent Application resource. Example: apps/myapp. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:pageSize` (*type:* `integer()`) - Maximum results to return per page. * `:pageToken` (*type:* `String.t`) - Continuation token for fetching the next page of results. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.ListServicesResponse{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_services_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.AppEngine.V1.Model.ListServicesResponse.t()} | {:error, Tesla.Env.t()} def appengine_apps_services_list(connection, apps_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/services", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.ListServicesResponse{}]) end @doc """ Updates the configuration of the specified service. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource to update. Example: apps/myapp/services/default. * `services_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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"). * `:migrateTraffic` (*type:* `boolean()`) - Set to true to gradually shift traffic to one or more versions that you specify. By default, traffic is shifted immediately. For gradual traffic migration, the target versions must be located within instances that are configured for both warmup requests (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#InboundServiceType) and automatic scaling (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#AutomaticScaling). You must specify the shardBy (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services#ShardBy) field in the Service resource. Gradual traffic migration is not supported in the App Engine flexible environment. For examples, see Migrating and Splitting Traffic (https://cloud.google.com/appengine/docs/admin-api/migrating-splitting-traffic). * `:updateMask` (*type:* `String.t`) - Standard field mask for the set of fields to be updated. * `:body` (*type:* `GoogleApi.AppEngine.V1.Model.Service.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_services_patch( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_services_patch( connection, apps_id, services_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :migrateTraffic => :query, :updateMask => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v1/apps/{appsId}/services/{servicesId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "servicesId" => URI.encode(services_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Operation{}]) end @doc """ Deploys code and resource files to a new version. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `parent`. Name of the parent resource to create this version under. Example: apps/myapp/services/default. * `services_id` (*type:* `String.t`) - Part of `parent`. See documentation of `appsId`. * `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.AppEngine.V1.Model.Version.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_services_versions_create( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_services_versions_create( connection, apps_id, services_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/apps/{appsId}/services/{servicesId}/versions", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "servicesId" => URI.encode(services_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Operation{}]) end @doc """ Deletes an existing Version resource. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource requested. Example: apps/myapp/services/default/versions/v1. * `services_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `versions_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_services_versions_delete( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_services_versions_delete( connection, apps_id, services_id, versions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "servicesId" => URI.encode(services_id, &URI.char_unreserved?/1), "versionsId" => URI.encode(versions_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Operation{}]) end @doc """ Gets the specified Version resource. By default, only a BASIC_VIEW will be returned. Specify the FULL_VIEW parameter to get the full resource. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource requested. Example: apps/myapp/services/default/versions/v1. * `services_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `versions_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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"). * `:view` (*type:* `String.t`) - Controls the set of fields returned in the Get response. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.Version{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_services_versions_get( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Version.t()} | {:error, Tesla.Env.t()} def appengine_apps_services_versions_get( connection, apps_id, services_id, versions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :view => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "servicesId" => URI.encode(services_id, &URI.char_unreserved?/1), "versionsId" => URI.encode(versions_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Version{}]) end @doc """ Lists the versions of a service. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `parent`. Name of the parent Service resource. Example: apps/myapp/services/default. * `services_id` (*type:* `String.t`) - Part of `parent`. See documentation of `appsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:pageSize` (*type:* `integer()`) - Maximum results to return per page. * `:pageToken` (*type:* `String.t`) - Continuation token for fetching the next page of results. * `:view` (*type:* `String.t`) - Controls the set of fields returned in the List response. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.ListVersionsResponse{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_services_versions_list( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.ListVersionsResponse.t()} | {:error, Tesla.Env.t()} def appengine_apps_services_versions_list( connection, apps_id, services_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :pageSize => :query, :pageToken => :query, :view => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/services/{servicesId}/versions", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "servicesId" => URI.encode(services_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.ListVersionsResponse{}]) end @doc """ Updates the specified Version resource. You can specify the following fields depending on the App Engine environment and type of scaling that the version resource uses:Standard environment instance_class (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.instance_class)automatic scaling in the standard environment: automatic_scaling.min_idle_instances (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) automatic_scaling.max_idle_instances (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) automaticScaling.standard_scheduler_settings.max_instances (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) automaticScaling.standard_scheduler_settings.min_instances (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) automaticScaling.standard_scheduler_settings.target_cpu_utilization (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) automaticScaling.standard_scheduler_settings.target_throughput_utilization (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings)basic scaling or manual scaling in the standard environment: serving_status (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status)Flexible environment serving_status (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status)automatic scaling in the flexible environment: automatic_scaling.min_total_instances (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) automatic_scaling.max_total_instances (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) automatic_scaling.cool_down_period_sec (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) automatic_scaling.cpu_utilization.target_utilization (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource to update. Example: apps/myapp/services/default/versions/1. * `services_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `versions_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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`) - Standard field mask for the set of fields to be updated. * `:body` (*type:* `GoogleApi.AppEngine.V1.Model.Version.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_services_versions_patch( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_services_versions_patch( connection, apps_id, services_id, versions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :updateMask => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "servicesId" => URI.encode(services_id, &URI.char_unreserved?/1), "versionsId" => URI.encode(versions_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Operation{}]) end @doc """ Enables debugging on a VM instance. This allows you to use the SSH command to connect to the virtual machine where the instance lives. While in "debug mode", the instance continues to serve live traffic. You should delete the instance when you are done debugging and then allow the system to take over and determine if another instance should be started.Only applicable for instances in App Engine flexible environment. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource requested. Example: apps/myapp/services/default/versions/v1/instances/instance-1. * `services_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `versions_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `instances_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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.AppEngine.V1.Model.DebugInstanceRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_services_versions_instances_debug( Tesla.Env.client(), String.t(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_services_versions_instances_debug( connection, apps_id, services_id, versions_id, instances_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}/instances/{instancesId}:debug", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "servicesId" => URI.encode(services_id, &URI.char_unreserved?/1), "versionsId" => URI.encode(versions_id, &URI.char_unreserved?/1), "instancesId" => URI.encode(instances_id, &URI.char_unreserved?/1) } ) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Operation{}]) end @doc """ Stops a running instance. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource requested. Example: apps/myapp/services/default/versions/v1/instances/instance-1. * `services_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `versions_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `instances_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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.AppEngine.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_services_versions_instances_delete( Tesla.Env.client(), String.t(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Operation.t()} | {:error, Tesla.Env.t()} def appengine_apps_services_versions_instances_delete( connection, apps_id, services_id, versions_id, instances_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:delete) |> Request.url( "/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}/instances/{instancesId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "servicesId" => URI.encode(services_id, &URI.char_unreserved?/1), "versionsId" => URI.encode(versions_id, &URI.char_unreserved?/1), "instancesId" => URI.encode(instances_id, &URI.char_unreserved?/1) } ) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Operation{}]) end @doc """ Gets instance information. ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `name`. Name of the resource requested. Example: apps/myapp/services/default/versions/v1/instances/instance-1. * `services_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `versions_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `instances_id` (*type:* `String.t`) - Part of `name`. See documentation of `appsId`. * `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.AppEngine.V1.Model.Instance{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_services_versions_instances_get( Tesla.Env.client(), String.t(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.Instance.t()} | {:error, Tesla.Env.t()} def appengine_apps_services_versions_instances_get( connection, apps_id, services_id, versions_id, instances_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url( "/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}/instances/{instancesId}", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "servicesId" => URI.encode(services_id, &URI.char_unreserved?/1), "versionsId" => URI.encode(versions_id, &URI.char_unreserved?/1), "instancesId" => URI.encode(instances_id, &URI.char_unreserved?/1) } ) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.Instance{}]) end @doc """ Lists the instances of a version.Tip: To aggregate details about instances over time, see the Stackdriver Monitoring API (https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). ## Parameters * `connection` (*type:* `GoogleApi.AppEngine.V1.Connection.t`) - Connection to server * `apps_id` (*type:* `String.t`) - Part of `parent`. Name of the parent Version resource. Example: apps/myapp/services/default/versions/v1. * `services_id` (*type:* `String.t`) - Part of `parent`. See documentation of `appsId`. * `versions_id` (*type:* `String.t`) - Part of `parent`. See documentation of `appsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:pageSize` (*type:* `integer()`) - Maximum results to return per page. * `:pageToken` (*type:* `String.t`) - Continuation token for fetching the next page of results. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.AppEngine.V1.Model.ListInstancesResponse{}}` on success * `{:error, info}` on failure """ @spec appengine_apps_services_versions_instances_list( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.AppEngine.V1.Model.ListInstancesResponse.t()} | {:error, Tesla.Env.t()} def appengine_apps_services_versions_instances_list( connection, apps_id, services_id, versions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/apps/{appsId}/services/{servicesId}/versions/{versionsId}/instances", %{ "appsId" => URI.encode(apps_id, &URI.char_unreserved?/1), "servicesId" => URI.encode(services_id, &URI.char_unreserved?/1), "versionsId" => URI.encode(versions_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.AppEngine.V1.Model.ListInstancesResponse{}]) end end
47.515567
916
0.622183
7377b34359c4d90f23e64dc53b0b8452cfdffbfc
1,065
ex
Elixir
lib/sass/compiler.ex
scottdavis/sass-ex
bf6312907acf9d87daec18344f3fbd625ea55114
[ "MIT" ]
6
2016-12-26T01:07:10.000Z
2022-01-28T09:33:53.000Z
lib/sass/compiler.ex
scottdavis/sass-ex
bf6312907acf9d87daec18344f3fbd625ea55114
[ "MIT" ]
null
null
null
lib/sass/compiler.ex
scottdavis/sass-ex
bf6312907acf9d87daec18344f3fbd625ea55114
[ "MIT" ]
4
2017-09-18T12:42:28.000Z
2021-03-24T11:45:30.000Z
defmodule Sass.Compiler do @moduledoc """ Connection to the NIF for sass """ @on_load { :init, 0 } @nifname 'sass_nif' defp app do :sass end @doc """ Loads the sass.so library """ def init do :ok = :erlang.load_nif(nif_path(), 0) end @doc """ A noop that gets overwritten by the NIF compile """ def compile(_,_) do exit(:nif_library_not_loaded) end @doc """ A noop that gets overwritten by the NIF compile_file """ def compile_file(_,_) do exit(:nif_library_not_loaded) end @doc """ A noop that gets overwritten by the NIF compile_file """ def version() do exit(:nif_library_not_loaded) end @doc false defp nif_path do case :code.priv_dir(app()) do {:error, :bad_name} -> case :filelib.is_dir(:filename.join(['..', '..', 'priv'])) do true -> :filename.join(['..', '..', 'priv', @nifname]) _ -> :filename.join(['priv', @nifname]) end dir -> :filename.join(dir, @nifname) end end end
19.017857
69
0.570892
7377ca8a571c099eb2818b229a4ae63266434954
523
exs
Elixir
string_compression/test/string_compression/day09_test.exs
alex-dukhno/elixir-tdd-katas
57e25fc275c4274c889f2b3760276cc8a393de9e
[ "MIT" ]
null
null
null
string_compression/test/string_compression/day09_test.exs
alex-dukhno/elixir-tdd-katas
57e25fc275c4274c889f2b3760276cc8a393de9e
[ "MIT" ]
null
null
null
string_compression/test/string_compression/day09_test.exs
alex-dukhno/elixir-tdd-katas
57e25fc275c4274c889f2b3760276cc8a393de9e
[ "MIT" ]
null
null
null
defmodule StringCompression.Day09Test do use ExUnit.Case, async: true alias StringCompression.Day09, as: StringCompression test "compress empty string", do: assert StringCompression.compress("") == "" test "compress single char string", do: assert StringCompression.compress("a") == "1a" test "compress string of unique chars", do: assert StringCompression.compress("abc") == "1a1b1c" test "compress string of doubled chars", do: assert StringCompression.compress("aabbcc") == "2a2b2c" end
29.055556
59
0.722753
737809c146619b7a265bc6d437b0b6b022032a9f
3,457
ex
Elixir
clients/dlp/lib/google_api/dlp/v2/model/google_privacy_dlp_v2_content_location.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
clients/dlp/lib/google_api/dlp/v2/model/google_privacy_dlp_v2_content_location.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
clients/dlp/lib/google_api/dlp/v2/model/google_privacy_dlp_v2_content_location.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2ContentLocation do @moduledoc """ Findings container location data. ## Attributes - containerName (String.t): Name of the container where the finding is located. The top level name is the source file name or table name. Names of some common storage containers are formatted as follows: * BigQuery tables: &#x60;&lt;project_id&gt;:&lt;dataset_id&gt;.&lt;table_id&gt;&#x60; * Cloud Storage files: &#x60;gs://&lt;bucket&gt;/&lt;path&gt;&#x60; * Datastore namespace: &lt;namespace&gt; Nested names could be absent if the embedded object has no string identifier (for an example an image contained within a document). Defaults to: `null`. - containerTimestamp (DateTime.t): Findings container modification timestamp, if applicable. For Google Cloud Storage contains last file modification timestamp. For BigQuery table contains last_modified_time property. For Datastore - not populated. Defaults to: `null`. - containerVersion (String.t): Findings container version, if available (\&quot;generation\&quot; for Google Cloud Storage). Defaults to: `null`. - documentLocation (GooglePrivacyDlpV2DocumentLocation): Location data for document files. Defaults to: `null`. - imageLocation (GooglePrivacyDlpV2ImageLocation): Location within an image&#39;s pixels. Defaults to: `null`. - recordLocation (GooglePrivacyDlpV2RecordLocation): Location within a row or record of a database table. Defaults to: `null`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :containerName => any(), :containerTimestamp => DateTime.t(), :containerVersion => any(), :documentLocation => GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2DocumentLocation.t(), :imageLocation => GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2ImageLocation.t(), :recordLocation => GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2RecordLocation.t() } field(:containerName) field(:containerTimestamp, as: DateTime) field(:containerVersion) field(:documentLocation, as: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2DocumentLocation) field(:imageLocation, as: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2ImageLocation) field(:recordLocation, as: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2RecordLocation) end defimpl Poison.Decoder, for: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2ContentLocation do def decode(value, options) do GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2ContentLocation.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2ContentLocation do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
54.873016
556
0.763379
73784011d49a3af1a11fa1ba007400db377e3675
2,101
ex
Elixir
lib/store/peer.ex
ElixiumNetwork/elixium_core
85014da4b0683ab8ec86c893b7c1146161da114a
[ "MIT" ]
164
2018-06-23T01:17:51.000Z
2021-08-19T03:16:31.000Z
lib/store/peer.ex
alexdovzhanyn/ultradark
85014da4b0683ab8ec86c893b7c1146161da114a
[ "MIT" ]
37
2018-06-28T18:07:27.000Z
2019-08-22T18:43:43.000Z
lib/store/peer.ex
alexdovzhanyn/ultradark
85014da4b0683ab8ec86c893b7c1146161da114a
[ "MIT" ]
26
2018-06-22T00:58:34.000Z
2021-08-19T03:16:40.000Z
defmodule Elixium.Store.Peer do use Elixium.Store @moduledoc """ Store and load data related to peers that a node has communicated with. This includes authentication data """ @store_dir "peers" def initialize do initialize(@store_dir) end def reorder_peers(ip) do transact @store_dir do fn ref -> {:ok, peers} = Exleveldb.get(ref, "known_peers") peers = :erlang.binary_to_term(peers) peer = Enum.find(peers, &(elem(&1, 0) == ip)) Exleveldb.put(ref, "known_peers", :erlang.term_to_binary([peer | peers -- [peer]])) end end end @spec save_known_peer({charlist, integer}) :: none def save_known_peer(peer) do transact @store_dir do fn ref -> case Exleveldb.get(ref, "known_peers") do {:ok, peers} -> peers = Enum.uniq([peer | :erlang.binary_to_term(peers)]) Exleveldb.put(ref, "known_peers", :erlang.term_to_binary(peers)) :not_found -> Exleveldb.put(ref, "known_peers", :erlang.term_to_binary([peer])) end end end end def load_known_peers do transact @store_dir do fn ref -> case Exleveldb.get(ref, "known_peers") do {:ok, peers} -> :erlang.binary_to_term(peers) :not_found -> [] end end end end @spec find_potential_peers :: List | :not_found def find_potential_peers do case load_known_peers() do [] -> seed_peers() peers -> peers end end @doc """ Returns a list of seed peers based on config """ @spec seed_peers :: List def seed_peers do :elixium_core |> Application.get_env(:seed_peers) |> Enum.map(&peerstring_to_tuple/1) end # Converts from a colon delimited string to a tuple containing the # ip and port. "127.0.0.1:3000" becomes {'127.0.0.1', 3000} defp peerstring_to_tuple(peer) do [ip, port] = String.split(peer, ":") ip = String.to_charlist(ip) port = case Integer.parse(port) do {port, _} -> port :error -> nil end {ip, port} end end
24.149425
91
0.609234
73785856b31d3b2193bb2e0fc4ffc99a5de689f2
315
ex
Elixir
lib/elirc/controllers/bot.ex
rockerBOO/elirc_twitch
6399f717c012df10df7914c216f5d3f9c425844c
[ "MIT" ]
20
2015-06-18T03:30:58.000Z
2021-01-11T19:55:00.000Z
lib/elirc/controllers/bot.ex
rockerBOO/elirc_twitch
6399f717c012df10df7914c216f5d3f9c425844c
[ "MIT" ]
1
2015-06-24T01:03:31.000Z
2015-06-24T12:41:21.000Z
lib/elirc/controllers/bot.ex
rockerBOO/elirc_twitch
6399f717c012df10df7914c216f5d3f9c425844c
[ "MIT" ]
7
2015-06-22T14:25:12.000Z
2016-01-21T03:39:02.000Z
defmodule Elirc.BotController do def msg(event, state, data) do end def echo(msg, state, data) do IO.puts "catch_all" IO.inspect data IO.inspect msg {:reply, {:text, ""}, state} end def echo(message, state) do # IO.inspect message {:reply, {:text, message}, state} end end
15
37
0.622222
73785e82949b26b1380fe69791bf9f6d06d0b730
100
ex
Elixir
test/examples/guard_fail_pattern.ex
staring-frog/dialyxir
b78735f75b325238b7db20d9eed22f018cca5f26
[ "Apache-2.0" ]
1,455
2015-01-03T02:53:19.000Z
2022-03-12T00:31:25.000Z
test/examples/guard_fail_pattern.ex
staring-frog/dialyxir
b78735f75b325238b7db20d9eed22f018cca5f26
[ "Apache-2.0" ]
330
2015-05-14T13:53:13.000Z
2022-03-29T17:12:23.000Z
test/examples/guard_fail_pattern.ex
staring-frog/dialyxir
b78735f75b325238b7db20d9eed22f018cca5f26
[ "Apache-2.0" ]
146
2015-02-03T18:19:43.000Z
2022-03-07T10:05:20.000Z
defmodule Dialyxir.Examples.GuardFailPattern do def ok(n = 0) when not n < 1 do :ok end end
16.666667
47
0.69
7378709d2fe0d87abc2c409b9c7c91ed304ebf3c
1,143
ex
Elixir
lib/air_vantage/operations/system.ex
pvp-technologies/ex_vantage
3f04dbc5c952f0c44a06132992e9112a1e367915
[ "MIT" ]
null
null
null
lib/air_vantage/operations/system.ex
pvp-technologies/ex_vantage
3f04dbc5c952f0c44a06132992e9112a1e367915
[ "MIT" ]
null
null
null
lib/air_vantage/operations/system.ex
pvp-technologies/ex_vantage
3f04dbc5c952f0c44a06132992e9112a1e367915
[ "MIT" ]
null
null
null
defmodule AirVantage.Operations.System do @moduledoc """ The system is the core representation used in AirVantage to define and interact with a real system. A system is composed of: - a gateway: the physical module enabling the connectivity of the system - a subscription: a subscription is the configuration of the connectivity defined with the operator - one or several applications: an application defines a piece of logic executing on the system. It can be a firmware, a software, etc. """ import AirVantage.Request alias AirVantage.Error @doc """ Returns a paginated list of systems with their complete details. It is possible to filter out the result list using criteria parameters. Though system creation date is not publicly exposed, the default sort order is based on the creation date. """ @spec find(String.t(), String.t()) :: {:ok, map} | {:error, Error.t()} def find(fields, gateway) do params = %{ "fields" => fields, "gateway" => gateway } new_request() |> put_method(:get) |> put_endpoint("/v1/systems") |> put_params(params) |> make_request() end end
36.870968
136
0.709536
7378975e434468350ba966cc2c6b091f0a8f2b24
1,015
ex
Elixir
src/mailer/lib/mailer_web/router.ex
alexjoybc/elixir-kafka-phoenix
c3d20415f980455081102f3bd4287647bf2292ba
[ "Apache-2.0" ]
null
null
null
src/mailer/lib/mailer_web/router.ex
alexjoybc/elixir-kafka-phoenix
c3d20415f980455081102f3bd4287647bf2292ba
[ "Apache-2.0" ]
null
null
null
src/mailer/lib/mailer_web/router.ex
alexjoybc/elixir-kafka-phoenix
c3d20415f980455081102f3bd4287647bf2292ba
[ "Apache-2.0" ]
null
null
null
defmodule MailerWeb.Router do use MailerWeb, :router pipeline :api do plug :accepts, ["json"] end scope "/api", MailerWeb do pipe_through :api resources "/businesses", BusinessController, except: [:new, :edit] end pipeline :browser do plug(:accepts, ["html"]) end scope "/", MailerWeb do pipe_through :browser get "/", DefaultController, :index 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 [:fetch_session, :protect_from_forgery] live_dashboard "/dashboard", metrics: MailerWeb.Telemetry end end end
26.710526
70
0.699507
7378b5e4a98744842f064ff693983129ebbcb55f
878
ex
Elixir
Phoenix_Sockets/example1/test/support/conn_case.ex
shubhamagiwal/DOSFall2017
3c1522c4163f57402f147b50614d4051b05a080f
[ "MIT" ]
3
2019-10-28T21:02:55.000Z
2020-10-01T02:29:37.000Z
Phoenix_Sockets/example1/test/support/conn_case.ex
shubhamagiwal/DOSFall2017
3c1522c4163f57402f147b50614d4051b05a080f
[ "MIT" ]
null
null
null
Phoenix_Sockets/example1/test/support/conn_case.ex
shubhamagiwal/DOSFall2017
3c1522c4163f57402f147b50614d4051b05a080f
[ "MIT" ]
4
2019-10-12T19:41:58.000Z
2021-09-24T20:24:47.000Z
defmodule Example1Web.ConnCase do @moduledoc """ This module defines the test case to be used by tests that require setting up a connection. Such tests rely on `Phoenix.ConnTest` and also import other functionality to make it easier to build common datastructures and query the data layer. 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 # Import conveniences for testing with connections use Phoenix.ConnTest import Example1Web.Router.Helpers # The default endpoint for testing @endpoint Example1Web.Endpoint end end setup _tags do {:ok, conn: Phoenix.ConnTest.build_conn()} end end
25.085714
58
0.730068
7378b736722a2035407466e52bdf3e835824f603
1,196
ex
Elixir
lib/mix/tasks/eunit.ex
radixpool/mix-erlang-tasks
d8709b47f67b505519fcb0567a41c6657c0f300b
[ "MIT" ]
18
2015-04-02T12:13:09.000Z
2021-01-16T15:51:42.000Z
lib/mix/tasks/eunit.ex
radixpool/mix-erlang-tasks
d8709b47f67b505519fcb0567a41c6657c0f300b
[ "MIT" ]
3
2015-08-31T12:58:12.000Z
2016-12-31T01:10:10.000Z
lib/mix/tasks/eunit.ex
radixpool/mix-erlang-tasks
d8709b47f67b505519fcb0567a41c6657c0f300b
[ "MIT" ]
11
2015-04-02T12:13:29.000Z
2022-01-31T14:41:15.000Z
defmodule Mix.Tasks.Eunit do use Mix.Task @shortdoc "Run the project's EUnit test suite" @moduledoc """ # Command line options * `--verbose`, `-v` - verbose mode * other options supported by `compile*` tasks """ def run(args) do {opts, args, rem_opts} = OptionParser.parse(args, strict: [verbose: :boolean], aliases: [v: :verbose]) new_args = args ++ MixErlangTasks.Util.filter_opts(rem_opts) # use a different env from :test because compilation options differ Mix.env :etest compile_opts = [{:d,:TEST}|Mix.Project.config[:erlc_options]] System.put_env "ERL_COMPILER_OPTIONS", format_compile_opts(compile_opts) Mix.Task.run "compile", new_args # This is run independently, so that the test modules don't end up in the # .app file ebin_test = Path.join([Mix.Project.app_path, "test_beams"]) MixErlangTasks.Util.compile_files(Path.wildcard("etest/**/*_tests.erl"), ebin_test) options = if Keyword.get(opts, :verbose, false), do: [:verbose], else: [] :eunit.test {:application, Mix.Project.config[:app]}, options end defp format_compile_opts(opts) do :io_lib.format("~p", [opts]) |> List.to_string end end
30.666667
106
0.685619
7378cdd32351eb06834f5a2becaa431f772afc96
4,694
ex
Elixir
clients/you_tube/lib/google_api/you_tube/v3/model/comment_snippet.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
clients/you_tube/lib/google_api/you_tube/v3/model/comment_snippet.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
clients/you_tube/lib/google_api/you_tube/v3/model/comment_snippet.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "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.YouTube.V3.Model.CommentSnippet do @moduledoc """ Basic details about a comment, such as its author and text. ## Attributes * `authorChannelId` (*type:* `GoogleApi.YouTube.V3.Model.CommentSnippetAuthorChannelId.t`, *default:* `nil`) - * `authorChannelUrl` (*type:* `String.t`, *default:* `nil`) - Link to the author's YouTube channel, if any. * `authorDisplayName` (*type:* `String.t`, *default:* `nil`) - The name of the user who posted the comment. * `authorProfileImageUrl` (*type:* `String.t`, *default:* `nil`) - The URL for the avatar of the user who posted the comment. * `canRate` (*type:* `boolean()`, *default:* `nil`) - Whether the current viewer can rate this comment. * `channelId` (*type:* `String.t`, *default:* `nil`) - The id of the corresponding YouTube channel. In case of a channel comment this is the channel the comment refers to. In case of a video comment it's the video's channel. * `likeCount` (*type:* `integer()`, *default:* `nil`) - The total number of likes this comment has received. * `moderationStatus` (*type:* `String.t`, *default:* `nil`) - The comment's moderation status. Will not be set if the comments were requested through the id filter. * `parentId` (*type:* `String.t`, *default:* `nil`) - The unique id of the parent comment, only set for replies. * `publishedAt` (*type:* `DateTime.t`, *default:* `nil`) - The date and time when the comment was originally published. * `textDisplay` (*type:* `String.t`, *default:* `nil`) - The comment's text. The format is either plain text or HTML dependent on what has been requested. Even the plain text representation may differ from the text originally posted in that it may replace video links with video titles etc. * `textOriginal` (*type:* `String.t`, *default:* `nil`) - The comment's original raw text as initially posted or last updated. The original text will only be returned if it is accessible to the viewer, which is only guaranteed if the viewer is the comment's author. * `updatedAt` (*type:* `DateTime.t`, *default:* `nil`) - The date and time when the comment was last updated. * `videoId` (*type:* `String.t`, *default:* `nil`) - The ID of the video the comment refers to, if any. * `viewerRating` (*type:* `String.t`, *default:* `nil`) - The rating the viewer has given to this comment. For the time being this will never return RATE_TYPE_DISLIKE and instead return RATE_TYPE_NONE. This may change in the future. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :authorChannelId => GoogleApi.YouTube.V3.Model.CommentSnippetAuthorChannelId.t(), :authorChannelUrl => String.t(), :authorDisplayName => String.t(), :authorProfileImageUrl => String.t(), :canRate => boolean(), :channelId => String.t(), :likeCount => integer(), :moderationStatus => String.t(), :parentId => String.t(), :publishedAt => DateTime.t(), :textDisplay => String.t(), :textOriginal => String.t(), :updatedAt => DateTime.t(), :videoId => String.t(), :viewerRating => String.t() } field(:authorChannelId, as: GoogleApi.YouTube.V3.Model.CommentSnippetAuthorChannelId) field(:authorChannelUrl) field(:authorDisplayName) field(:authorProfileImageUrl) field(:canRate) field(:channelId) field(:likeCount) field(:moderationStatus) field(:parentId) field(:publishedAt, as: DateTime) field(:textDisplay) field(:textOriginal) field(:updatedAt, as: DateTime) field(:videoId) field(:viewerRating) end defimpl Poison.Decoder, for: GoogleApi.YouTube.V3.Model.CommentSnippet do def decode(value, options) do GoogleApi.YouTube.V3.Model.CommentSnippet.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.YouTube.V3.Model.CommentSnippet do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
52.741573
294
0.693651
73790589499e035e086cc53a696d6cedc5ef0d39
6,331
exs
Elixir
config/config.exs
wvffle/analytics
2c0fd55bc67f74af1fe1e2641678d44e9fee61d5
[ "MIT" ]
1
2020-10-08T13:33:04.000Z
2020-10-08T13:33:04.000Z
config/config.exs
wvffle/analytics
2c0fd55bc67f74af1fe1e2641678d44e9fee61d5
[ "MIT" ]
null
null
null
config/config.exs
wvffle/analytics
2c0fd55bc67f74af1fe1e2641678d44e9fee61d5
[ "MIT" ]
null
null
null
use Mix.Config base_url = System.get_env("BASE_URL", "http://localhost:8000") |> URI.parse config :plausible, admin_user: System.get_env("ADMIN_USER_NAME", "admin"), admin_email: System.get_env("ADMIN_USER_EMAIL", "[email protected]"), mailer_email: System.get_env("MAILER_EMAIL", "[email protected]"), admin_pwd: System.get_env("ADMIN_USER_PWD", "!@d3in"), ecto_repos: [Plausible.Repo, Plausible.ClickhouseRepo], environment: System.get_env("ENVIRONMENT", "dev") disable_auth = String.to_existing_atom(System.get_env("DISABLE_AUTH", "false")) config :plausible, :selfhost, disable_authentication: disable_auth, disable_subscription: String.to_existing_atom(System.get_env("DISABLE_SUBSCRIPTION", "false")), disable_registration: if(disable_auth, do: true, else: String.to_existing_atom(System.get_env("DISABLE_REGISTRATION", "false")) ) # Configures the endpoint config :plausible, PlausibleWeb.Endpoint, url: [ host: base_url.host, scheme: base_url.scheme, port: base_url.port ], http: [ port: String.to_integer(System.get_env("PORT", "8000")) ], secret_key_base: System.get_env( "SECRET_KEY_BASE", "/NJrhNtbyCVAsTyvtk1ZYCwfm981Vpo/0XrVwjJvemDaKC/vsvBRevLwsc6u8RCg" ), render_errors: [ view: PlausibleWeb.ErrorView, accepts: ~w(html json) ], pubsub: [name: Plausible.PubSub, adapter: Phoenix.PubSub.PG2] config :sentry, dsn: System.get_env("SENTRY_DSN"), included_environments: [:prod, :staging], environment_name: String.to_atom(System.get_env("ENVIRONMENT", "dev")), enable_source_code_context: true, root_source_code_path: File.cwd!(), tags: %{app_version: System.get_env("APP_VERSION", "0.0.1")}, context_lines: 5 # Configures Elixir's Logger config :logger, :console, format: "$time $metadata[$level] $message\n", metadata: [:request_id] # Use Jason for JSON parsing in Phoenix config :phoenix, :json_library, Jason config :ua_inspector, database_path: "priv/ua_inspector" config :ref_inspector, database_path: "priv/ref_inspector" config :plausible, paddle_api: Plausible.Billing.PaddleApi, google_api: Plausible.Google.Api config :plausible, # 30 minutes session_timeout: 1000 * 60 * 30, session_length_minutes: 30 config :plausible, :paddle, vendor_id: "49430", vendor_auth_code: System.get_env("PADDLE_VENDOR_AUTH_CODE") config :plausible, Plausible.ClickhouseRepo, loggers: [Ecto.LogEntry], url: System.get_env( "CLICKHOUSE_DATABASE_URL", "http://127.0.0.1:8123/plausible_test" ) config :plausible, Plausible.Repo, timeout: 300_000, connect_timeout: 300_000, handshake_timeout: 300_000, url: System.get_env( "DATABASE_URL", "postgres://postgres:[email protected]:5432/plausible_dev?currentSchema=default" ) cron_enabled = String.to_existing_atom(System.get_env("CRON_ENABLED", "false")) base_cron = [ # Daily at midnight {"0 0 * * *", Plausible.Workers.RotateSalts} ] extra_cron = [ # hourly {"0 * * * *", Plausible.Workers.SendSiteSetupEmails}, #  hourly {"0 * * * *", Plausible.Workers.ScheduleEmailReports}, # Daily at midnight {"0 0 * * *", Plausible.Workers.FetchTweets}, # Daily at midday {"0 12 * * *", Plausible.Workers.SendTrialNotifications}, # Daily at midday {"0 12 * * *", Plausible.Workers.SendCheckStatsEmails}, # Every 10 minutes {"*/10 * * * *", Plausible.Workers.ProvisionSslCertificates} ] base_queues = [rotate_salts: 1] extra_queues = [ provision_ssl_certificates: 1, fetch_tweets: 1, check_stats_emails: 1, site_setup_emails: 1, trial_notification_emails: 1, schedule_email_reports: 1, send_email_reports: 1 ] config :plausible, Oban, repo: Plausible.Repo, queues: if(cron_enabled, do: base_queues ++ extra_queues, else: base_queues), crontab: if(cron_enabled, do: base_cron ++ extra_cron, else: base_cron) config :plausible, :google, client_id: System.get_env("GOOGLE_CLIENT_ID"), client_secret: System.get_env("GOOGLE_CLIENT_SECRET") config :plausible, :slack, webhook: System.get_env("SLACK_WEBHOOK") mailer_adapter = System.get_env("MAILER_ADAPTER", "Bamboo.LocalAdapter") case mailer_adapter do "Bamboo.PostmarkAdapter" -> config :plausible, Plausible.Mailer, adapter: :"Elixir.#{mailer_adapter}", api_key: System.get_env("POSTMARK_API_KEY") "Bamboo.SMTPAdapter" -> config :plausible, Plausible.Mailer, adapter: :"Elixir.#{mailer_adapter}", server: System.fetch_env!("SMTP_HOST_ADDR"), hostname: System.get_env("HOST", "localhost"), port: System.fetch_env!("SMTP_HOST_PORT"), username: System.fetch_env!("SMTP_USER_NAME"), password: System.fetch_env!("SMTP_USER_PWD"), tls: :if_available, allowed_tls_versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"], ssl: System.get_env("SMTP_HOST_SSL_ENABLED") || false, retries: System.get_env("SMTP_RETRIES") || 2, no_mx_lookups: System.get_env("SMTP_MX_LOOKUPS_ENABLED") || true, auth: :if_available "Bamboo.LocalAdapter" -> config :plausible, Plausible.Mailer, adapter: :"Elixir.#{mailer_adapter}" _ -> raise "Unknown mailer_adapter; expected SMTPAdapter or PostmarkAdapter" end config :plausible, :twitter, consumer_key: System.get_env("TWITTER_CONSUMER_KEY"), consumer_secret: System.get_env("TWITTER_CONSUMER_SECRET"), token: System.get_env("TWITTER_ACCESS_TOKEN"), token_secret: System.get_env("TWITTER_ACCESS_TOKEN_SECRET") config :plausible, :custom_domain_server, user: System.get_env("CUSTOM_DOMAIN_SERVER_USER"), password: System.get_env("CUSTOM_DOMAIN_SERVER_PASSWORD"), ip: System.get_env("CUSTOM_DOMAIN_SERVER_IP") config :plausible, PlausibleWeb.Firewall, blocklist: System.get_env("IP_BLOCKLIST", "") |> String.split(",") |> Enum.map(&String.trim/1) config :plausible, :hcaptcha, sitekey: System.get_env("HCAPTCHA_SITEKEY"), secret: System.get_env("HCAPTCHA_SECRET") config :geolix, databases: [ %{ id: :country, adapter: Geolix.Adapter.MMDB2, source: "priv/geolix/GeoLite2-Country.mmdb" } ] # 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"
30.882927
97
0.715685
737922e351b1f1e543871f1111b3f0414092589c
693
ex
Elixir
lib/bolt_sips/error.ex
Badiapp/bolt_sips
ea5e1ae3295700a9f9b0324d26d953845da17050
[ "Apache-2.0" ]
null
null
null
lib/bolt_sips/error.ex
Badiapp/bolt_sips
ea5e1ae3295700a9f9b0324d26d953845da17050
[ "Apache-2.0" ]
null
null
null
lib/bolt_sips/error.ex
Badiapp/bolt_sips
ea5e1ae3295700a9f9b0324d26d953845da17050
[ "Apache-2.0" ]
null
null
null
defmodule Bolt.Sips.Error do @moduledoc """ represents an error message """ alias __MODULE__ @type t :: %__MODULE__{} defstruct [:code, :message] def new(%Boltex.Error{code: code, connection_id: cid, function: f, message: message, type: t}) do {:error, struct(Error, %{ code: code, message: "Details: #{message}; connection_id: #{inspect(cid)}, function: #{inspect(f)}, type: #{ inspect(t) }" })} end def new({:ignored, f} = _r), do: new({:error, f}) def new({:failure, %{"code" => code, "message" => message}} = _r) do {:error, struct(Error, %{code: code, message: message})} end def new(r), do: r end
23.896552
99
0.572872
73792b3eaf8d3561587dca6d73e9119e0e933ff3
19,567
ex
Elixir
clients/you_tube/lib/google_api/you_tube/v3/api/watermarks.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/you_tube/lib/google_api/you_tube/v3/api/watermarks.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/you_tube/lib/google_api/you_tube/v3/api/watermarks.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "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.YouTube.V3.Api.Watermarks do @moduledoc """ API calls for all endpoints tagged `Watermarks`. """ alias GoogleApi.YouTube.V3.Connection alias GoogleApi.Gax.{Request, Response} @library_version Mix.Project.config() |> Keyword.get(:version, "") @doc """ Allows upload of watermark image and setting it for a channel. ## Parameters * `connection` (*type:* `GoogleApi.YouTube.V3.Connection.t`) - Connection to server * `channel_id` (*type:* `String.t`) - * `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"). * `:onBehalfOfContentOwner` (*type:* `String.t`) - *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. * `:body` (*type:* `GoogleApi.YouTube.V3.Model.InvideoBranding.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %{}}` on success * `{:error, info}` on failure """ @spec youtube_watermarks_set(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, nil} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def youtube_watermarks_set(connection, channel_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :onBehalfOfContentOwner => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/youtube/v3/watermarks/set", %{}) |> Request.add_param(:query, :channelId, channel_id) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [decode: false]) end @doc """ Allows upload of watermark image and setting it for a channel. ## Parameters * `connection` (*type:* `GoogleApi.YouTube.V3.Connection.t`) - Connection to server * `channel_id` (*type:* `String.t`) - * `upload_type` (*type:* `String.t`) - Upload type. Must be "multipart". * `metadata` (*type:* `GoogleApi.YouTube.V3.Model.InvideoBranding.t`) - object metadata * `data` (*type:* `iodata`) - Content to upload, as a string or iolist * `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"). * `:onBehalfOfContentOwner` (*type:* `String.t`) - *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %{}}` on success * `{:error, info}` on failure """ @spec youtube_watermarks_set_iodata( Tesla.Env.client(), String.t(), String.t(), GoogleApi.YouTube.V3.Model.InvideoBranding.t(), iodata, keyword(), keyword() ) :: {:ok, nil} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def youtube_watermarks_set_iodata( connection, channel_id, upload_type, metadata, data, 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, :onBehalfOfContentOwner => :query } request = Request.new() |> Request.method(:post) |> Request.url("/upload/youtube/v3/watermarks/set", %{}) |> Request.add_param(:query, :channelId, channel_id) |> Request.add_param(:query, :uploadType, upload_type) |> Request.add_param(:body, :metadata, metadata) |> Request.add_param(:body, :data, data) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [decode: false]) end @doc """ Allows upload of watermark image and setting it for a channel. ## Parameters * `connection` (*type:* `GoogleApi.YouTube.V3.Connection.t`) - Connection to server * `channel_id` (*type:* `String.t`) - * `upload_type` (*type:* `String.t`) - Upload type. Must be "resumable". * `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"). * `:onBehalfOfContentOwner` (*type:* `String.t`) - *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. * `:body` (*type:* `GoogleApi.YouTube.V3.Model.InvideoBranding.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %{}}` on success * `{:error, info}` on failure """ @spec youtube_watermarks_set_resumable( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, nil} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def youtube_watermarks_set_resumable( connection, channel_id, upload_type, 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, :onBehalfOfContentOwner => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/resumable/upload/youtube/v3/watermarks/set", %{}) |> Request.add_param(:query, :channelId, channel_id) |> Request.add_param(:query, :uploadType, upload_type) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [decode: false]) end @doc """ Allows upload of watermark image and setting it for a channel. ## Parameters * `connection` (*type:* `GoogleApi.YouTube.V3.Connection.t`) - Connection to server * `channel_id` (*type:* `String.t`) - * `upload_type` (*type:* `String.t`) - Upload type. Must be "multipart". * `metadata` (*type:* `GoogleApi.YouTube.V3.Model.InvideoBranding.t`) - object metadata * `data` (*type:* `String.t`) - Path to file containing content to upload * `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"). * `:onBehalfOfContentOwner` (*type:* `String.t`) - *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %{}}` on success * `{:error, info}` on failure """ @spec youtube_watermarks_set_simple( Tesla.Env.client(), String.t(), String.t(), GoogleApi.YouTube.V3.Model.InvideoBranding.t(), String.t(), keyword(), keyword() ) :: {:ok, nil} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def youtube_watermarks_set_simple( connection, channel_id, upload_type, metadata, data, 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, :onBehalfOfContentOwner => :query } request = Request.new() |> Request.method(:post) |> Request.url("/upload/youtube/v3/watermarks/set", %{}) |> Request.add_param(:query, :channelId, channel_id) |> Request.add_param(:query, :uploadType, upload_type) |> Request.add_param(:body, :metadata, metadata) |> Request.add_param(:file, :data, data) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [decode: false]) end @doc """ Allows removal of channel watermark. ## Parameters * `connection` (*type:* `GoogleApi.YouTube.V3.Connection.t`) - Connection to server * `channel_id` (*type:* `String.t`) - * `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"). * `:onBehalfOfContentOwner` (*type:* `String.t`) - *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %{}}` on success * `{:error, info}` on failure """ @spec youtube_watermarks_unset(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, nil} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def youtube_watermarks_unset(connection, channel_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :onBehalfOfContentOwner => :query } request = Request.new() |> Request.method(:post) |> Request.url("/youtube/v3/watermarks/unset", %{}) |> Request.add_param(:query, :channelId, channel_id) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [decode: false]) end end
51.901857
729
0.645883
737941f8cd9bdf3c8746669200937772c0d88a0e
378
ex
Elixir
lib/bike_brigade/messaging/scheduled_message.ex
bikebrigade/dispatch
eb622fe4f6dab7c917d678d3d7a322a01f97da44
[ "Apache-2.0" ]
28
2021-10-11T01:53:53.000Z
2022-03-24T17:45:55.000Z
lib/bike_brigade/messaging/scheduled_message.ex
bikebrigade/dispatch
eb622fe4f6dab7c917d678d3d7a322a01f97da44
[ "Apache-2.0" ]
20
2021-10-21T08:12:31.000Z
2022-03-31T13:35:53.000Z
lib/bike_brigade/messaging/scheduled_message.ex
bikebrigade/dispatch
eb622fe4f6dab7c917d678d3d7a322a01f97da44
[ "Apache-2.0" ]
null
null
null
defmodule BikeBrigade.Messaging.ScheduledMessage do use BikeBrigade.Schema alias BikeBrigade.Delivery.Campaign import Ecto.Changeset schema "scheduled_messages" do field :send_at, :utc_datetime belongs_to :campaign, Campaign timestamps() end def changeset(struct, params \\ %{}) do struct |> cast(params, [:send_at, :campaign_id]) end end
18.9
51
0.722222
7379722eb64fc6941203f6a17192cb7d2fc10085
519
exs
Elixir
config/test.exs
jeojoe/catapalt-chat
1a8c94bb38535d517837e1e9c53d2e8de0f2b7ae
[ "Apache-2.0" ]
null
null
null
config/test.exs
jeojoe/catapalt-chat
1a8c94bb38535d517837e1e9c53d2e8de0f2b7ae
[ "Apache-2.0" ]
null
null
null
config/test.exs
jeojoe/catapalt-chat
1a8c94bb38535d517837e1e9c53d2e8de0f2b7ae
[ "Apache-2.0" ]
null
null
null
use Mix.Config # We don't run a server during test. If one is required, # you can enable the server option below. config :catapalt_chat, CatapaltChat.Endpoint, http: [port: 4001], server: false # Print only warnings and errors during test config :logger, level: :warn # Configure your database config :catapalt_chat, CatapaltChat.Repo, adapter: Ecto.Adapters.Postgres, username: "postgres", password: "postgres", database: "catapalt_chat_test", hostname: "localhost", pool: Ecto.Adapters.SQL.Sandbox
25.95
56
0.747592
737990185d7cdbb1da3d544d34bc29586b6ffcfa
41
exs
Elixir
.dialyzer_ignore.exs
ambareesha7/node-zaryn
136e542801bf9b6fa4a015d3464609fdf3dacee8
[ "Apache-2.0" ]
1
2021-07-06T19:47:14.000Z
2021-07-06T19:47:14.000Z
.dialyzer_ignore.exs
ambareesha7/node-zaryn
136e542801bf9b6fa4a015d3464609fdf3dacee8
[ "Apache-2.0" ]
null
null
null
.dialyzer_ignore.exs
ambareesha7/node-zaryn
136e542801bf9b6fa4a015d3464609fdf3dacee8
[ "Apache-2.0" ]
null
null
null
[ {"lib/zaryn/utils.ex", :call, 537} ]
10.25
36
0.536585
7379937adbcc4dbf51b9125d5975fc63597ec25f
302
exs
Elixir
test/versionary/plug/phoenix_error_handler_test.exs
kianmeng/versionary
227b035e23c65394e7dec39dba252bf5bb7843e7
[ "MIT" ]
35
2017-04-05T19:47:08.000Z
2022-02-12T22:05:17.000Z
test/versionary/plug/phoenix_error_handler_test.exs
kianmeng/versionary
227b035e23c65394e7dec39dba252bf5bb7843e7
[ "MIT" ]
16
2017-03-23T14:36:53.000Z
2021-09-23T17:31:46.000Z
test/versionary/plug/phoenix_error_handler_test.exs
kianmeng/versionary
227b035e23c65394e7dec39dba252bf5bb7843e7
[ "MIT" ]
6
2017-03-19T03:04:34.000Z
2021-08-10T14:05:27.000Z
defmodule Versionary.Plug.PhoenixErrorHandlerTest do use ExUnit.Case use Plug.Test alias Versionary.Plug.PhoenixErrorHandler test "respond with a status of 406" do assert_raise(Phoenix.NotAcceptableError, fn() -> conn(:get, "/") |> PhoenixErrorHandler.call end) end end
21.571429
52
0.718543
7379a4e9f84c996901cfa11e6d5868248eb8bc70
1,114
exs
Elixir
test/elastix/alias_test.exs
macoshita/elastix
cfffda3319ec095dcc3f62141ade74e7ccf117d5
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
test/elastix/alias_test.exs
macoshita/elastix
cfffda3319ec095dcc3f62141ade74e7ccf117d5
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
test/elastix/alias_test.exs
macoshita/elastix
cfffda3319ec095dcc3f62141ade74e7ccf117d5
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
defmodule Elastix.AliasTest do use ExUnit.Case alias Elastix.Alias alias Elastix.Index @test_url Elastix.config(:test_url) @test_index Elastix.config(:test_index) setup do Index.delete(@test_url, @test_index) :ok end test "aliases actions on existing index should respond with 200" do assert {:ok, %{status_code: _}} = Index.create(@test_url, @test_index, %{}) assert {:ok, %{status_code: 200}} = Alias.post(@test_url, [ %{add: %{index: @test_index, alias: "alias1"}}, %{remove: %{index: @test_index, alias: "alias1"}} ]) end test "remove unkown alias on existing index should respond with 404" do assert {:ok, %{status_code: _}} = Index.create(@test_url, @test_index, %{}) assert {:ok, %{status_code: 404}} = Alias.post(@test_url, [%{remove: %{index: @test_index, alias: "alias1"}}]) end test "alias actions on unknown index should respond with 404" do assert {:ok, %{status_code: 404}} = Alias.post(@test_url, [%{add: %{index: @test_index, alias: "alias1"}}]) end end
30.108108
87
0.620287
7379a5c0ca420d8cc459dec00cd936d8cead6de0
754
exs
Elixir
kousa/test/broth/user/get_bots_test.exs
LeonardSSH/dogehouse
584055ad407bc37fa35cdf36ebb271622e29d436
[ "MIT" ]
9
2021-03-17T03:56:18.000Z
2021-09-24T22:45:14.000Z
kousa/test/broth/user/get_bots_test.exs
LeonardSSH/dogehouse
584055ad407bc37fa35cdf36ebb271622e29d436
[ "MIT" ]
12
2021-07-06T12:51:13.000Z
2022-03-16T12:38:18.000Z
kousa/test/broth/user/get_bots_test.exs
LeonardSSH/dogehouse
584055ad407bc37fa35cdf36ebb271622e29d436
[ "MIT" ]
4
2021-07-15T20:33:50.000Z
2022-03-27T12:46:47.000Z
defmodule BrothTest.User.GetBotsTest do use ExUnit.Case, async: true use KousaTest.Support.EctoSandbox alias Beef.Schemas.User alias BrothTest.WsClient alias BrothTest.WsClientFactory alias KousaTest.Support.Factory require WsClient setup do user = Factory.create(User) client_ws = WsClientFactory.create_client_for(user) {:ok, user: user, client_ws: client_ws} end describe "the user:get_bots operation" do test "gets bots", t do WsClient.do_call(t.client_ws, "user:create_bot", %{ "username" => "marvin" }) ref = WsClient.send_call(t.client_ws, "user:get_bots", %{}) WsClient.assert_reply("user:get_bots:reply", ref, %{"bots" => [%{"username" => "marvin"}]}) end end end
24.322581
97
0.68435
7379a5c11183ba6af53123049b45b9e1af4bc7db
2,343
ex
Elixir
lib/absinthe_permission/middleware/has_permission.ex
kianmeng/absinthe_permission
5085045c04582d9b9e461ec2e36d6511ba5555fa
[ "MIT" ]
16
2020-10-28T16:12:00.000Z
2022-01-31T17:03:47.000Z
lib/absinthe_permission/middleware/has_permission.ex
kianmeng/absinthe_permission
5085045c04582d9b9e461ec2e36d6511ba5555fa
[ "MIT" ]
null
null
null
lib/absinthe_permission/middleware/has_permission.ex
kianmeng/absinthe_permission
5085045c04582d9b9e461ec2e36d6511ba5555fa
[ "MIT" ]
1
2020-10-30T11:45:30.000Z
2020-10-30T11:45:30.000Z
defmodule AbsinthePermission.Middleware.HasPermission do @behaviour Absinthe.Middleware alias AbsinthePermission.PolicyChecker # check permission def call( %{ state: :unresolved, arguments: arguments, context: %{current_user: _current_user, permissions: user_perms} = context } = res, _config ) do meta = case Absinthe.Type.meta(res.definition.schema_node) do m when m == %{} -> type = Absinthe.Schema.lookup_type(res.schema, res.definition.schema_node.type) Absinthe.Type.meta(type) m -> m end perm = Map.get(meta, :required_permission) case PolicyChecker.has_permission?(perm, user_perms) do false -> res |> Absinthe.Resolution.put_result({:error, "Unauthorized"}) true -> conditions = Map.get(meta, :pre_op_policies, []) result = PolicyChecker.should_we_allow?(Map.to_list(arguments), conditions, context) case result do false -> res |> Absinthe.Resolution.put_result({:error, "Unauthorized"}) true -> res end end end # sanitize def call( %{ state: :resolved, arguments: args, context: %{current_user: _current_user, permissions: user_perms} = context } = res, _config ) do meta = Absinthe.Type.meta(res.definition.schema_node) access_perms = Map.get(meta, :post_op_policies) case access_perms do nil -> res _v -> req_perms = access_perms |> Enum.map(&Keyword.get(&1, :required_permission)) |> MapSet.new() no_perms = MapSet.difference(req_perms, MapSet.new(user_perms)) |> Enum.to_list() case no_perms do [] -> res _ps -> fs = access_perms |> Enum.filter(&(Keyword.get(&1, :required_permission) in no_perms)) |> Enum.flat_map(fn p -> {_, conds} = Keyword.pop(p, :required_permission) conds end) val = PolicyChecker.reject(res.value, fs, Map.to_list(args), context) %{res | value: val} end end end # white list some paths and deny all others. def call(res, _config), do: res end
26.033333
92
0.571063
7379b0751bda8a8ce5a2720d0dd3c660c014b1b8
3,680
exs
Elixir
test/consumer_test.exs
esl/buildex_jobs
928d36541c25fa0ad998278cc7fe609644562140
[ "Apache-2.0" ]
2
2020-05-28T12:23:00.000Z
2021-03-11T23:23:57.000Z
test/consumer_test.exs
esl/buildex_jobs
928d36541c25fa0ad998278cc7fe609644562140
[ "Apache-2.0" ]
null
null
null
test/consumer_test.exs
esl/buildex_jobs
928d36541c25fa0ad998278cc7fe609644562140
[ "Apache-2.0" ]
2
2021-03-11T23:27:28.000Z
2022-03-06T10:20:51.000Z
defmodule RepoJobs.ConsumerTest do # async: false to appease the ExUnit.CaptureLog use ExUnit.Case, async: false import ExUnit.CaptureLog alias ExRabbitPool.FakeRabbitMQ alias ExRabbitPool.Worker.{RabbitConnection, SetupQueue} alias RepoJobs.Consumer @queue "test.queue" setup do n = :rand.uniform(100) pool_id = String.to_atom("test_pool#{n}") caller = self() rabbitmq_config = [ channels: 1, port: String.to_integer(System.get_env("POLLER_RMQ_PORT") || "5672"), queues: [ [ queue_name: @queue, exchange: "", queue_options: [auto_delete: true], exchange_options: [auto_delete: true] ] ], adapter: FakeRabbitMQ, caller: caller, reconnect: 10 ] rabbitmq_conn_pool = [ name: {:local, pool_id}, worker_module: RabbitConnection, size: 1, max_overflow: 0 ] Application.put_env(:buildex_jobs, :rabbitmq_config, rabbitmq_config) Application.put_env(:buildex_jobs, :queue, @queue) Application.put_env(:buildex_jobs, :exchange, "") start_supervised!(%{ id: ExRabbitPool.PoolSupervisorTest, start: {ExRabbitPool.PoolSupervisor, :start_link, [ [rabbitmq_config: rabbitmq_config, connection_pools: [rabbitmq_conn_pool]], ExRabbitPool.PoolSupervisorTest ]}, type: :supervisor }) start_supervised!({SetupQueue, {pool_id, rabbitmq_config}}) {:ok, pool_id: pool_id} end test "handles :basic_consume_ok message from the broker", %{pool_id: pool_id} do pid = start_supervised!({Consumer, {self(), pool_id}}) send(pid, {:basic_consume_ok, %{consumer_tag: "tag"}}) assert_receive :basic_consume_ok end test "handles :basic_cancel message from the broker", %{pool_id: pool_id} do log = capture_log(fn -> pid = start_supervised!({Consumer, pool_id}, restart: :temporary) ref = Process.monitor(pid) send(pid, {:basic_cancel, %{consumer_tag: "tag"}}) assert_receive {:DOWN, ^ref, :process, ^pid, :normal} end) assert log =~ "[consumer] consumer was cancelled by the broker (basic_cancel)" end test "handles :basic_cancel_ok message from the broker", %{pool_id: pool_id} do log = capture_log(fn -> pid = start_supervised!({Consumer, pool_id}, restart: :temporary) ref = Process.monitor(pid) send(pid, {:basic_cancel_ok, %{consumer_tag: "tag"}}) assert_receive {:DOWN, ^ref, :process, ^pid, :normal} end) assert log =~ "[consumer] consumer was cancelled by the broker (basic_cancel_ok)" end test "checks out a channel from the pool and doesn't return it back", %{pool_id: pool_id} do pid = start_supervised!({Consumer, pool_id}) assert %{channel: channel, consumer_tag: "tag"} = Consumer.state(pid) conn_worker = :poolboy.checkout(pool_id) :ok = :poolboy.checkin(pool_id, conn_worker) assert %{channels: [], monitors: monitors} = RabbitConnection.state(conn_worker) assert Map.has_key?(monitors, channel.pid) end test "handles errors when trying to get a channel", %{pool_id: pool_id} do conn_worker = ExRabbitPool.get_connection_worker(pool_id) {:ok, channel} = ExRabbitPool.checkout_channel(conn_worker) log = capture_log(fn -> pid = start_supervised!({Consumer, pool_id}) :timer.sleep(20) ExRabbitPool.checkin_channel(conn_worker, channel) :timer.sleep(20) assert %{channel: ^channel} = Consumer.state(pid) end) assert log =~ "[consumer] error getting channel reason: :out_of_channels" end end
31.724138
94
0.657337
7379d6af3c7e58ac4f89f1ba39b414eab9a30516
1,751
exs
Elixir
mix.exs
JeffyMesquita/elixirHeat
3ec3c59021e90058f00c2eb288a5e6c286e96342
[ "MIT" ]
null
null
null
mix.exs
JeffyMesquita/elixirHeat
3ec3c59021e90058f00c2eb288a5e6c286e96342
[ "MIT" ]
null
null
null
mix.exs
JeffyMesquita/elixirHeat
3ec3c59021e90058f00c2eb288a5e6c286e96342
[ "MIT" ]
null
null
null
defmodule ElixirHeat.MixProject do use Mix.Project def project do [ app: :elixirHeat, version: "0.1.0", elixir: "~> 1.7", 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: {ElixirHeat.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.5.8"}, {:phoenix_ecto, "~> 4.1"}, {:ecto_sql, "~> 3.4"}, {:postgrex, ">= 0.0.0"}, {:phoenix_live_dashboard, "~> 0.4"}, {:telemetry_metrics, "~> 0.4"}, {:telemetry_poller, "~> 0.4"}, {:gettext, "~> 0.11"}, {:jason, "~> 1.0"}, {:plug_cowboy, "~> 2.0"} ] end # Aliases are shortcuts or tasks specific to the current project. # For example, to install project dependencies and perform other setup tasks, run: # # $ mix setup # # See the documentation for `Mix` for more info on aliases. defp aliases do [ setup: ["deps.get", "ecto.setup", "cmd npm install --prefix assets"], "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], "ecto.reset": ["ecto.drop", "ecto.setup"], test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"] ] end end
27.359375
84
0.585951
737a0a9a87963ee8f6633790e78607cd33a192e2
3,661
ex
Elixir
lib/changelog_web/meta/title.ex
boneskull/changelog.com
2fa2e356bb0e8fcf038c46a4a947fef98822e37d
[ "MIT" ]
null
null
null
lib/changelog_web/meta/title.ex
boneskull/changelog.com
2fa2e356bb0e8fcf038c46a4a947fef98822e37d
[ "MIT" ]
null
null
null
lib/changelog_web/meta/title.ex
boneskull/changelog.com
2fa2e356bb0e8fcf038c46a4a947fef98822e37d
[ "MIT" ]
null
null
null
defmodule ChangelogWeb.Meta.Title do alias ChangelogWeb.{AuthView, EpisodeView, LiveView, NewsItemView, NewsSourceView, PageView, PersonView, PodcastView, PostView, TopicView, SearchView} @suffix "News and podcasts for developers | Changelog" def page_title(assigns), do: assigns |> get |> put_suffix # no need for the suffix on these def share_title(assigns), do: assigns |> get defp put_suffix(nil), do: @suffix defp put_suffix(title), do: title <> " | " <> @suffix # Search views defp get(%{view_module: SearchView, view_template: "search.html", query: ""}), do: "Search" defp get(%{view_module: SearchView, view_template: "search.html", query: query}), do: "Search results for #{query}" # Live page defp get(%{view_module: LiveView}), do: "Live and upcoming shows" # News item - show defp get(%{view_module: NewsItemView, view_template: "show.html", item: item}) do item.headline end # News - submit defp get(%{view_module: NewsItemView, view_template: "new.html"}), do: "Submit news" # Sign up - subscribe defp get(%{view_module: PersonView, view_template: "subscribe.html"}), do: "Subscribe to Changelog" # Sign up - join community defp get(%{view_module: PersonView, view_template: "join.html"}), do: "Join the community" # Sign in defp get(%{view_module: AuthView}), do: "Sign In" # Source index defp get(%{view_module: NewsSourceView, view_template: "index.html"}), do: "All news sources" # Source show pages defp get(%{view_module: NewsSourceView, view_template: "show.html", source: source}) do "Developer news from #{source.name}" end # Topic index defp get(%{view_module: TopicView, view_template: "index.html"}), do: "All news topics" # Topic show pages defp get(%{view_module: TopicView, topic: topic, tab: "news"}) do "Developer news about #{topic.name}" end defp get(%{view_module: TopicView, topic: topic, tab: "podcasts"}) do "Developer podcasts about #{topic.name}" end defp get(%{view_module: TopicView, topic: topic}) do "Developer news and podcasts about #{topic.name}" end # Pages defp get(%{view_module: PageView, view_template: template}) do case template do "community.html" -> "Changelog developer community" "coc.html" -> "Code of conduct" "home.html" -> nil "weekly.html" -> "Subscribe to Changelog Weekly" "nightly.html" -> "Subscribe to Changelog Nightly" "sponsor_story.html" -> "Partner story" _else -> template |> String.replace(".html", "") |> String.split("_") |> Enum.map(fn(s) -> String.capitalize(s) end) |> Enum.join(" ") end end # Podcasts index defp get(%{view_module: PodcastView, view_template: "index.html"}), do: "All Changelog podcasts" # Podcast homepages defp get(%{view_module: PodcastView, podcast: podcast, tab: "recommended"}) do "Recommended episodes of #{podcast.name}" end defp get(%{view_module: PodcastView, podcast: podcast}) do if Enum.any?(podcast.hosts) do "#{podcast.name} with #{PersonView.comma_separated_names(podcast.hosts)}" else podcast.name end end # Episode page defp get(%{view_module: EpisodeView, view_template: "show.html", podcast: podcast, episode: episode}) do "#{podcast.name} #{EpisodeView.numbered_title(episode, "#")} #{episode.subtitle}" end # Posts index (blog) defp get(%{view_module: PostView, view_template: "index.html"}), do: "Blog" # Post show page defp get(%{view_module: PostView, post: post}), do: post.title defp get(_), do: nil end
33.898148
117
0.665119
737a4a5e56c4d84d9fa54aa6909037b883f09fb1
640
ex
Elixir
lib/exkeychain_web/views/account_view.ex
ctxhaard/exkeychain
1109316f182ab35d0f01a5607260afd35b87e7ff
[ "Apache-2.0" ]
1
2021-02-15T08:56:17.000Z
2021-02-15T08:56:17.000Z
lib/exkeychain_web/views/account_view.ex
ctxhaard/exkeychain
1109316f182ab35d0f01a5607260afd35b87e7ff
[ "Apache-2.0" ]
null
null
null
lib/exkeychain_web/views/account_view.ex
ctxhaard/exkeychain
1109316f182ab35d0f01a5607260afd35b87e7ff
[ "Apache-2.0" ]
null
null
null
defmodule ExkeychainWeb.AccountView do use ExkeychainWeb, :view def render("authentication.json", _) do %{ status: "ok" } end def render("index.json", %{accounts: accounts}) do %{ data: render_many(accounts, ExkeychainWeb.AccountView, "account.json")} end def render("show.json", %{account: account}) do %{ data: render_one(account, ExkeychainWeb.AccountView, "account.json")} end def render("update.json", %{account: {:account, map}}) do %{ id: map.id } end def render("delete.json", %{ id: id}) do %{ id: id} end def render("account.json", %{ account: account }) do account end end
22.857143
78
0.646875
737a7b23956ef164e86293c62c55d91bffd1b90f
215
ex
Elixir
web/serializers/ticket_serializer.ex
Pianist038801/SprintPoker
ae14f79b8cd4254a1c5f5fef698db1cf2d20cf9c
[ "MIT" ]
null
null
null
web/serializers/ticket_serializer.ex
Pianist038801/SprintPoker
ae14f79b8cd4254a1c5f5fef698db1cf2d20cf9c
[ "MIT" ]
null
null
null
web/serializers/ticket_serializer.ex
Pianist038801/SprintPoker
ae14f79b8cd4254a1c5f5fef698db1cf2d20cf9c
[ "MIT" ]
null
null
null
defimpl Poison.Encoder, for: SprintPoker.Ticket do def encode(ticket, options) do %{ id: ticket.id, name: ticket.name, points: ticket.points } |> Poison.Encoder.encode(options) end end
21.5
50
0.651163
737a7e063acca17c296069efcf34e1e35aeee275
735
ex
Elixir
lib/crew/persons/person_tagging.ex
anamba/crew
c25f6a1d6ddbe0b58da9d556ff53a641c4d2a7b1
[ "BSL-1.0" ]
null
null
null
lib/crew/persons/person_tagging.ex
anamba/crew
c25f6a1d6ddbe0b58da9d556ff53a641c4d2a7b1
[ "BSL-1.0" ]
5
2020-07-20T01:49:01.000Z
2021-09-08T00:17:04.000Z
lib/crew/persons/person_tagging.ex
anamba/crew
c25f6a1d6ddbe0b58da9d556ff53a641c4d2a7b1
[ "BSL-1.0" ]
null
null
null
defmodule Crew.Persons.PersonTagging do use Ecto.Schema import Ecto.Changeset alias Crew.Persons.{Person, PersonTag} @foreign_key_type :binary_id schema "person_taggings" do belongs_to :person, Person belongs_to :tag, PersonTag, foreign_key: :person_tag_id field :name, :string field :value, :string field :value_i, :integer # to allow mass-created records to be edited/deleted together as well field :batch_id, :binary_id field :batch_note, :string timestamps() end @doc false def changeset(person_tagging, attrs) do person_tagging |> cast(attrs, [:person_id, :person_tag_id, :name, :value, :value_i]) |> validate_required([:person_id, :person_tag_id]) end end
23.709677
73
0.711565
737a84b972c79b4f56e0e693f1a9fc54a58a43f1
2,500
exs
Elixir
test/utils_test.exs
ospaarmann/exdgraph
4a80822c4f4c8521f5df71e9bdf7238b302f9786
[ "Apache-2.0" ]
108
2018-02-23T15:20:09.000Z
2021-05-26T11:48:17.000Z
test/utils_test.exs
ospaarmann/exdgraph
4a80822c4f4c8521f5df71e9bdf7238b302f9786
[ "Apache-2.0" ]
28
2018-02-25T09:30:38.000Z
2021-12-22T03:57:39.000Z
test/utils_test.exs
ospaarmann/exdgraph
4a80822c4f4c8521f5df71e9bdf7238b302f9786
[ "Apache-2.0" ]
14
2018-03-01T17:19:56.000Z
2021-03-02T16:57:58.000Z
defmodule ExDgraph.Utils.Test do use ExUnit.Case, async: true doctest ExDgraph.Utils alias ExDgraph.Utils test "as_rendered/1 float" do assert Utils.as_rendered(3.14) == "3.14" end test "as_rendered/1 bool" do assert Utils.as_rendered(true) == "true" end test "as_rendered/1 int" do assert Utils.as_rendered(1) == "1" end test "as_rendered/1 string" do assert Utils.as_rendered("beef") == "beef" end test "as_rendered/1 date" do {:ok, written_on} = Date.new(2017, 8, 5) assert Utils.as_rendered(written_on) == "2017-08-05T00:00:00.0+00:00" end test "as_rendered/1 datetime" do {:ok, written_at, 0} = DateTime.from_iso8601("2017-08-05T22:32:36.000+00:00") assert Utils.as_rendered(written_at) == "2017-08-05T22:32:36.000+00:00" end test "as_rendered/1 geo (json)" do assert Utils.as_rendered([-111.925278, 33.501324]) == "[-111.925278,33.501324]" end test "as_literal/2 float" do assert Utils.as_literal(3.14, :float) == {:ok, "3.14"} end test "as_literal/2 bool" do assert Utils.as_literal(true, :bool) == {:ok, "true"} end test "as_literal/2 int" do assert Utils.as_literal(1, :int) == {:ok, "1"} end test "as_literal/2 string" do assert Utils.as_literal("beef", :string) == {:ok, "\"beef\""} end test "as_literal/2 date" do {:ok, written_on} = Date.new(2017, 8, 5) assert Utils.as_literal(written_on, :date) == {:ok, "2017-08-05T00:00:00.0+00:00"} end test "as_literal/2 datetime" do {:ok, written_at, 0} = DateTime.from_iso8601("2017-08-05T22:32:36.000+00:00") assert Utils.as_literal(written_at, :datetime) == {:ok, "2017-08-05T22:32:36.000+00:00"} end test "as_literal/2 geo (json)" do assert Utils.as_literal([-111.925278, 33.501324], :geo) == {:ok, "[-111.925278,33.501324]"} end test "as_literal/2 type error" do assert Utils.as_literal("Eef", :int) == {:error, {:invalidly_typed_value, "Eef", :int}} end test "as_literal/2 uid" do assert Utils.as_literal("beef", :uid) == {:ok, "<beef>"} end test "has_struct?/1 returns false for non-struct-modules" do assert Utils.has_struct?(Path) == false end test "has_struct?/1 returns false for non-struct-atoms" do assert Utils.has_struct?(:ok) == false end test "has_struct?/1 returns true for struct-having-modules" do assert Utils.has_struct?(URI) == true end end # Copyright (c) 2017 Jason Goldberger # Source https://github.com/elbow-jason/dgraph_ex
27.777778
95
0.6608
737ac7ab2707638e256f23f345773a1a0d6ac5d8
471
exs
Elixir
config/test.exs
rob05c/tox
f54847ca058ad24b909341ad65d595a4069d2471
[ "Apache-2.0" ]
2
2016-11-16T17:24:21.000Z
2019-02-15T05:38:27.000Z
config/test.exs
rob05c/tox
f54847ca058ad24b909341ad65d595a4069d2471
[ "Apache-2.0" ]
null
null
null
config/test.exs
rob05c/tox
f54847ca058ad24b909341ad65d595a4069d2471
[ "Apache-2.0" ]
null
null
null
use Mix.Config # We don't run a server during test. If one is required, # you can enable the server option below. config :tox, Tox.Endpoint, http: [port: 4001], server: false # Print only warnings and errors during test config :logger, level: :warn # Configure your database config :tox, Tox.Repo, adapter: Ecto.Adapters.Postgres, username: "postgres", password: "postgres", database: "tox_test", hostname: "localhost", pool: Ecto.Adapters.SQL.Sandbox
23.55
56
0.721868
737af09573b5a68f789656c8381b2ad9a0708c29
134
ex
Elixir
debian/neheglqt.cron.d.ex
rzr/neheglqt
b80cbb859ec76e80c74ac646b94fafa44259431d
[ "Linux-OpenIB" ]
1
2021-02-06T01:34:45.000Z
2021-02-06T01:34:45.000Z
debian/neheglqt.cron.d.ex
rzr/neheglqt
b80cbb859ec76e80c74ac646b94fafa44259431d
[ "Linux-OpenIB" ]
null
null
null
debian/neheglqt.cron.d.ex
rzr/neheglqt
b80cbb859ec76e80c74ac646b94fafa44259431d
[ "Linux-OpenIB" ]
null
null
null
# # Regular cron jobs for the neheglqt package # 0 4 * * * root [ -x /usr/bin/neheglqt_maintenance ] && /usr/bin/neheglqt_maintenance
26.8
84
0.708955
737afc84d4daec1bb8e8a40497ccbcc41a6fd8f1
1,907
ex
Elixir
client/lib/collector/collector.ex
vfournie/udp-playground
c180004344d5b673730dae04848294902e6a75ee
[ "MIT" ]
null
null
null
client/lib/collector/collector.ex
vfournie/udp-playground
c180004344d5b673730dae04848294902e6a75ee
[ "MIT" ]
null
null
null
client/lib/collector/collector.ex
vfournie/udp-playground
c180004344d5b673730dae04848294902e6a75ee
[ "MIT" ]
null
null
null
defmodule UdpClient.Collector do use GenServer require Logger ## Client API def start_link() do GenServer.start_link(__MODULE__, :ok, name: __MODULE__) end def inc_counter(counter) do GenServer.call(__MODULE__, {:inc_counter, counter}) end def get_raw_stats() do GenServer.call(__MODULE__, :get_raw_stats) end def display_stats() do GenServer.call(__MODULE__, :display_stats) end ## Server Callbacks def init(:ok) do {:ok, %{}} end def handle_call({:inc_counter, counter}, _from, state) do :ets.update_counter(:udp_stats, counter, 1, {1, 0}) {:reply, :ok, state} end def handle_call(:get_raw_stats, _from, state) do stats = :ets.match(:udp_stats, :"$1") {:reply, stats, state} end def handle_call(:display_stats, _from, state) do dump_stats() {:reply, :ok, state} end # Private defp dump_stats() do pong_values = :ets.match(:udp_stats, {{:pong, :"_", :"_"}, :"$1"}) |> Enum.flat_map(&(&1)) pong_count = Enum.count(pong_values) {pong_min, pong_max, pong_mean} = case pong_count > 0 do true -> pong_min = Enum.min(pong_values) pong_max = Enum.max(pong_values) pong_mean = (Enum.sum(pong_values) / pong_count) |> trunc {pong_min, pong_max, pong_mean} _ -> {0, 0, 0} end IO.puts( """ Stats: #{inspect pong_count}\t\tUDP Pong packets received: Min round trip duration (in ms):\t#{inspect pong_min} ms Mean round trip duration (in ms):\t#{inspect pong_mean} ms Max round trip duration (in ms):\t#{inspect pong_max} ms """ ) end end
25.77027
98
0.543262
737b173208e2771ef61de59e41320505a5e25be0
7,903
ex
Elixir
lib/elixir/lib/calendar/iso.ex
TurtleAI/elixir
2fb41ebef4d06315dd6c05ee00899572b27ee50a
[ "Apache-2.0" ]
null
null
null
lib/elixir/lib/calendar/iso.ex
TurtleAI/elixir
2fb41ebef4d06315dd6c05ee00899572b27ee50a
[ "Apache-2.0" ]
null
null
null
lib/elixir/lib/calendar/iso.ex
TurtleAI/elixir
2fb41ebef4d06315dd6c05ee00899572b27ee50a
[ "Apache-2.0" ]
null
null
null
defmodule Calendar.ISO do @moduledoc """ A calendar implementation that follows to ISO8601. This calendar implements the proleptic Gregorian calendar and is therefore compatible with the calendar used in most countries today. The proleptic means the Gregorian rules for leap years are applied for all time, consequently the dates give different results before the year 1583 from when the Gregorian calendar was adopted. """ @behaviour Calendar @unix_epoch :calendar.datetime_to_gregorian_seconds {{1970, 1, 1}, {0, 0, 0}} @type year :: 0..9999 @type month :: 1..12 @type day :: 1..31 @doc """ Returns the last day of the month for the given year. ## Examples iex> Calendar.ISO.last_day_of_month(1900, 1) 31 iex> Calendar.ISO.last_day_of_month(1900, 2) 28 iex> Calendar.ISO.last_day_of_month(2000, 2) 29 iex> Calendar.ISO.last_day_of_month(2001, 2) 28 iex> Calendar.ISO.last_day_of_month(2004, 2) 29 iex> Calendar.ISO.last_day_of_month(2004, 4) 30 """ @spec last_day_of_month(year, month) :: 28..31 def last_day_of_month(year, month) def last_day_of_month(year, 2) do if leap_year?(year), do: 29, else: 28 end def last_day_of_month(_, month) when month in [4, 6, 9, 11], do: 30 def last_day_of_month(_, month) when month in 1..12, do: 31 @doc """ Returns if the given year is a leap year. ## Examples iex> Calendar.ISO.leap_year?(2000) true iex> Calendar.ISO.leap_year?(2001) false iex> Calendar.ISO.leap_year?(2004) true iex> Calendar.ISO.leap_year?(1900) false """ @spec leap_year?(year) :: boolean() def leap_year?(year) when is_integer(year) and year >= 0 do rem(year, 4) === 0 and (rem(year, 100) > 0 or rem(year, 400) === 0) end @doc """ Calculates the day of the week from the given `year`, `month`, and `day`. It is an integer from 1 to 7, where 1 is Monday and 7 is Sunday. ## Examples iex> Calendar.ISO.day_of_week(2016, 10, 31) 1 iex> Calendar.ISO.day_of_week(2016, 11, 01) 2 iex> Calendar.ISO.day_of_week(2016, 11, 02) 3 iex> Calendar.ISO.day_of_week(2016, 11, 03) 4 iex> Calendar.ISO.day_of_week(2016, 11, 04) 5 iex> Calendar.ISO.day_of_week(2016, 11, 05) 6 iex> Calendar.ISO.day_of_week(2016, 11, 06) 7 """ @spec day_of_week(year, month, day) :: 1..7 def day_of_week(year, month, day) when is_integer(year) and is_integer(month) and is_integer(day) do :calendar.day_of_the_week(year, month, day) end @doc """ Converts the given date into a string. """ def date_to_string(year, month, day) do zero_pad(year, 4) <> "-" <> zero_pad(month, 2) <> "-" <> zero_pad(day, 2) end @doc """ Converts the datetime (without time zone) into a string. """ def naive_datetime_to_string(year, month, day, hour, minute, second, microsecond) do date_to_string(year, month, day) <> " " <> time_to_string(hour, minute, second, microsecond) end @doc """ Convers the datetime (with time zone) into a string. """ def datetime_to_string(year, month, day, hour, minute, second, microsecond, time_zone, zone_abbr, utc_offset, std_offset) do date_to_string(year, month, day) <> " " <> time_to_string(hour, minute, second, microsecond) <> offset_to_string(utc_offset, std_offset, time_zone) <> zone_to_string(utc_offset, std_offset, zone_abbr, time_zone) end defp offset_to_string(0, 0, "Etc/UTC"), do: "Z" defp offset_to_string(utc, std, _zone) do total = utc + std second = abs(total) minute = second |> rem(3600) |> div(60) hour = second |> div(3600) sign(total) <> zero_pad(hour, 2) <> ":" <> zero_pad(minute, 2) end defp zone_to_string(0, 0, _abbr, "Etc/UTC"), do: "" defp zone_to_string(_, _, abbr, zone), do: " " <> abbr <> " " <> zone defp sign(total) when total < 0, do: "-" defp sign(_), do: "+" defp zero_pad(val, count) do num = Integer.to_string(val) :binary.copy("0", count - byte_size(num)) <> num end ## Helpers @doc false def time_to_string(hour, minute, second, {_, 0}) do time_to_string(hour, minute, second) end def time_to_string(hour, minute, second, {microsecond, precision}) do time_to_string(hour, minute, second) <> "." <> (microsecond |> zero_pad(6) |> binary_part(0, precision)) end defp time_to_string(hour, minute, second) do zero_pad(hour, 2) <> ":" <> zero_pad(minute, 2) <> ":" <> zero_pad(second, 2) end @doc false def date(year, month, day) when is_integer(year) and is_integer(month) and is_integer(day) do if :calendar.valid_date(year, month, day) and year <= 9999 do {:ok, %Date{year: year, month: month, day: day}} else {:error, :invalid_date} end end @doc false def from_unix(integer, unit) when is_integer(integer) do total = System.convert_time_unit(integer, unit, :microsecond) if total < -@unix_epoch * 1_000_000 do {:error, :invalid_unix_time} else microsecond = rem(total, 1_000_000) precision = precision_for_unit(unit) {date, time} = :calendar.gregorian_seconds_to_datetime(@unix_epoch + div(total, 1_000_000)) {:ok, date, time, {microsecond, precision}} end end defp precision_for_unit(unit) do subsecond = div System.convert_time_unit(1, :second, unit), 10 precision_for_unit(subsecond, 0) end defp precision_for_unit(0, precision), do: precision defp precision_for_unit(_, 6), do: 6 defp precision_for_unit(number, precision), do: precision_for_unit(div(number, 10), precision + 1) @doc false def date_to_iso8601(year, month, day) do date_to_string(year, month, day) end @doc false def time_to_iso8601(hour, minute, second, microsecond) do time_to_string(hour, minute, second, microsecond) end @doc false def naive_datetime_to_iso8601(year, month, day, hour, minute, second, microsecond) do date_to_string(year, month, day) <> "T" <> time_to_string(hour, minute, second, microsecond) end @doc false def datetime_to_iso8601(year, month, day, hour, minute, second, microsecond, time_zone, _zone_abbr, utc_offset, std_offset) do date_to_string(year, month, day) <> "T" <> time_to_string(hour, minute, second, microsecond) <> offset_to_string(utc_offset, std_offset, time_zone) end @doc false def parse_microsecond("." <> rest) do case parse_microsecond(rest, 0, "") do {"", 0, _} -> :error {microsecond, precision, rest} when precision in 1..6 -> pad = String.duplicate("0", 6 - byte_size(microsecond)) {{String.to_integer(microsecond <> pad), precision}, rest} {microsecond, _precision, rest} -> {{String.to_integer(binary_part(microsecond, 0, 6)), 6}, rest} end end def parse_microsecond(rest) do {{0, 0}, rest} end defp parse_microsecond(<<h, t::binary>>, precision, acc) when h in ?0..?9, do: parse_microsecond(t, precision + 1, <<acc::binary, h>>) defp parse_microsecond(rest, precision, acc), do: {acc, precision, rest} @doc false def parse_offset(""), do: {nil, ""} def parse_offset("Z"), do: {0, ""} def parse_offset("-00:00"), do: :error def parse_offset(<<?+, hour::2-bytes, ?:, min::2-bytes, rest::binary>>), do: parse_offset(1, hour, min, rest) def parse_offset(<<?-, hour::2-bytes, ?:, min::2-bytes, rest::binary>>), do: parse_offset(-1, hour, min, rest) def parse_offset(_), do: :error defp parse_offset(sign, hour, min, rest) do with {hour, ""} when hour < 24 <- Integer.parse(hour), {min, ""} when min < 60 <- Integer.parse(min) do {((hour * 60) + min) * 60 * sign, rest} else _ -> :error end end end
30.992157
97
0.644818
737b275b70749dd065cd660c3043ebf972733993
668
ex
Elixir
lib/sentinel.ex
hexedpackets/sentinel
578b6a92832c0a81fd15eac3f3064579ecfbf9bd
[ "MIT" ]
null
null
null
lib/sentinel.ex
hexedpackets/sentinel
578b6a92832c0a81fd15eac3f3064579ecfbf9bd
[ "MIT" ]
6
2019-05-01T21:20:34.000Z
2019-05-01T21:30:14.000Z
lib/sentinel.ex
hexedpackets/sentinel
578b6a92832c0a81fd15eac3f3064579ecfbf9bd
[ "MIT" ]
null
null
null
defmodule Sentinel do @doc """ Generate a GitHub client authenticated with a JWT. """ def client() do Tentacat.Client.new(%{jwt: Sentinel.Auth.token()}) end @doc """ Generate a GitHub client for a specific installation """ def client(installation) when is_integer(installation) do token = Sentinel.Installations.token(installation) Tentacat.Client.new(%{access_token: token}) end def client_for_owner(owner) do owner |> Sentinel.Installations.from_owner() |> List.first() |> Map.get("id") |> client() end def client_for_repository(%{"owner" => %{"login" => login}}) do client_for_owner(login) end end
23.034483
65
0.670659
737b2d65ca448acd17e8784e206f31ba0b790b59
1,338
exs
Elixir
lib/elixir/test/elixir/range_test.exs
knewter/elixir
8310d62499e292d78d5c9d79d5d15a64e32fb738
[ "Apache-2.0" ]
null
null
null
lib/elixir/test/elixir/range_test.exs
knewter/elixir
8310d62499e292d78d5c9d79d5d15a64e32fb738
[ "Apache-2.0" ]
null
null
null
lib/elixir/test/elixir/range_test.exs
knewter/elixir
8310d62499e292d78d5c9d79d5d15a64e32fb738
[ "Apache-2.0" ]
null
null
null
Code.require_file "test_helper.exs", __DIR__ defmodule RangeTest do use ExUnit.Case, async: true test :precedence do assert Enum.to_list(1..3+2) == [1, 2, 3, 4, 5] assert 1..3 |> Enum.to_list == [1, 2, 3] end test :first do assert Range.new(first: 1, last: 3).first == 1 end test :last do assert Range.new(first: 1, last: 3).last == 3 end test :op do assert (1..3).first == 1 assert (1..3).last == 3 end test :in do refute 0 in 1..3, "in range assertion" assert 1 in 1..3, "in range assertion" assert 2 in 1..3, "in range assertion" assert 3 in 1..3, "in range assertion" refute 4 in 1..3, "in range assertion" assert -3 in -1..-3, "in range assertion" end test :is_range do assert is_range(1..3) refute is_range(not_range) end test :enum do refute Enum.empty?(1..1) assert Enum.member?(1..3, 2) refute Enum.member?(1..3, 0) refute Enum.member?(1..3, 4) refute Enum.member?(3..1, 0) refute Enum.member?(3..1, 4) assert Enum.count(1..3) == 3 assert Enum.count(3..1) == 3 assert Enum.map(1..3, &(&1 * 2)) == [2, 4, 6] assert Enum.map(3..1, &(&1 * 2)) == [6, 4, 2] end test :inspect do assert inspect(1..3) == "1..3" assert inspect(3..1) == "3..1" end defp not_range do 1 end end
20.90625
50
0.577728
737b3f38a99d8360989da95bb5a4266e310ff5cd
1,225
ex
Elixir
lib/obelisk/site.ex
knewter/obelisk
360425914d36c1c6094820ae035a4555a177ed00
[ "MIT" ]
1
2017-04-04T15:44:25.000Z
2017-04-04T15:44:25.000Z
lib/obelisk/site.ex
knewter/obelisk
360425914d36c1c6094820ae035a4555a177ed00
[ "MIT" ]
null
null
null
lib/obelisk/site.ex
knewter/obelisk
360425914d36c1c6094820ae035a4555a177ed00
[ "MIT" ]
null
null
null
defmodule Obelisk.Site do def initialize do create_default_theme create_content_dirs Obelisk.Post.create("Welcome to Obelisk") File.write './site.yml', Obelisk.Templates.config end def clean do File.rm_rf "./build" File.mkdir "./build" end def create_default_theme do File.mkdir "./themes" File.mkdir "./themes/default" create_assets_dirs create_layout_dirs end defp create_assets_dirs do File.mkdir "./themes/default/assets" File.mkdir "./themes/default/assets/css" File.mkdir "./themes/default/assets/js" File.mkdir "./themes/default/assets/img" File.write "./themes/default/assets/css/base.css", Obelisk.Templates.base_css end defp create_content_dirs do File.mkdir "./posts" File.mkdir "./drafts" File.mkdir "./pages" end defp create_layout_dirs do File.mkdir "./themes/default/layout" File.write "./themes/default/layout/post.eex", Obelisk.Templates.post_template File.write "./themes/default/layout/layout.eex", Obelisk.Templates.layout File.write "./themes/default/layout/index.eex", Obelisk.Templates.index File.write "./themes/default/layout/page.eex", Obelisk.Templates.page_template end end
27.222222
82
0.713469
737b76ab2195675f673a610b9bafcb551a5d8b22
622
ex
Elixir
web/models/user_properties.ex
mijkenator/elapi
55a85edf6fcadd89e390a682404c79bab93282b0
[ "Artistic-2.0" ]
null
null
null
web/models/user_properties.ex
mijkenator/elapi
55a85edf6fcadd89e390a682404c79bab93282b0
[ "Artistic-2.0" ]
null
null
null
web/models/user_properties.ex
mijkenator/elapi
55a85edf6fcadd89e390a682404c79bab93282b0
[ "Artistic-2.0" ]
null
null
null
defmodule Elapi.UserProperties do use Elapi.Web, :model schema "user_properties" do belongs_to :user, Elapi.User field :data, Elapi.Json.Type timestamps end @required_fields ~w(user_id) @optional_fields ~w(data) @doc """ Creates a changeset based on the `model` and `params`. If no params are provided, an invalid changeset is returned with no validation performed. """ def changeset(model, params \\ :empty) do model |> cast(params, @required_fields, @optional_fields) end def create_changeset(model, params \\ :empty) do model |> changeset(params) end end
19.4375
61
0.689711
737b8aab4b58a287c582eacb10f2feca9f74559f
1,001
ex
Elixir
lib/pelemay_fp_benchmark/logistic_map.ex
al2o3cr/pelemay_fp_benchmark
27f33e1a0990b964183d1e65414e01a7c333b5b2
[ "Apache-2.0" ]
null
null
null
lib/pelemay_fp_benchmark/logistic_map.ex
al2o3cr/pelemay_fp_benchmark
27f33e1a0990b964183d1e65414e01a7c333b5b2
[ "Apache-2.0" ]
1
2020-12-28T08:16:26.000Z
2021-01-05T20:04:51.000Z
lib/pelemay_fp_benchmark/logistic_map.ex
al2o3cr/pelemay_fp_benchmark
27f33e1a0990b964183d1e65414e01a7c333b5b2
[ "Apache-2.0" ]
1
2020-12-28T00:10:38.000Z
2020-12-28T00:10:38.000Z
defmodule LogisticMap do import Pelemay def logistic_map(v) do rem(22 * v * (v + 1), 6_700_417) end def logistic_map_10(v) do logistic_map(v) |> logistic_map() |> logistic_map() |> logistic_map() |> logistic_map() |> logistic_map() |> logistic_map() |> logistic_map() |> logistic_map() |> logistic_map() end defpelemay do def logistic_map_10_pelemay(list) do list |> Enum.map(&rem(22 * &1 * (&1 + 1), 6_700_417)) |> Enum.map(&rem(22 * &1 * (&1 + 1), 6_700_417)) |> Enum.map(&rem(22 * &1 * (&1 + 1), 6_700_417)) |> Enum.map(&rem(22 * &1 * (&1 + 1), 6_700_417)) |> Enum.map(&rem(22 * &1 * (&1 + 1), 6_700_417)) |> Enum.map(&rem(22 * &1 * (&1 + 1), 6_700_417)) |> Enum.map(&rem(22 * &1 * (&1 + 1), 6_700_417)) |> Enum.map(&rem(22 * &1 * (&1 + 1), 6_700_417)) |> Enum.map(&rem(22 * &1 * (&1 + 1), 6_700_417)) |> Enum.map(&rem(22 * &1 * (&1 + 1), 6_700_417)) end end end
27.054054
54
0.514486
737b9ad4a1ae2068bc60b9ede290d307856fe42b
7,882
exs
Elixir
apps/site/test/site/realtime_schedule_test.exs
paulswartz/dotcom
73e43e7c61afd96b1928608ce8316a7ed0eb1440
[ "MIT" ]
null
null
null
apps/site/test/site/realtime_schedule_test.exs
paulswartz/dotcom
73e43e7c61afd96b1928608ce8316a7ed0eb1440
[ "MIT" ]
65
2021-05-06T18:38:33.000Z
2022-03-28T20:50:04.000Z
apps/site/test/site/realtime_schedule_test.exs
paulswartz/dotcom
73e43e7c61afd96b1928608ce8316a7ed0eb1440
[ "MIT" ]
null
null
null
defmodule Site.RealtimeScheduleTest do use ExUnit.Case alias Alerts.Alert alias Alerts.InformedEntity, as: IE alias Alerts.InformedEntitySet, as: IESet alias Predictions.Prediction alias RoutePatterns.RoutePattern alias Routes.Route alias Schedules.{Schedule, Trip} alias Site.JsonHelpers alias Site.RealtimeSchedule alias Stops.Stop @now DateTime.from_naive!(~N[2030-02-19T12:00:00], "Etc/UTC") @stop %Stop{id: "place-ogmnl"} @route %Route{ custom_route?: false, description: :rapid_transit, direction_destinations: %{0 => "Forest Hills", 1 => "Oak Grove"}, direction_names: %{0 => "Southbound", 1 => "Northbound"}, id: "Orange", long_name: "Orange Line", name: "Orange Line", type: 1, color: "ED8B00", sort_order: 99_999 } @route_with_patterns [ {@route, [ %RoutePattern{ direction_id: 0, id: "Orange-3-0", name: "Forest Hills", representative_trip_id: "40709167-20:15-OakGroveWellington", route_id: "Orange", time_desc: nil, typicality: 1 }, %RoutePattern{ direction_id: 1, id: "Orange-3-1", name: "Oak Grove", representative_trip_id: "40709170-20:15-OakGroveWellington", route_id: "Orange", time_desc: nil, typicality: 1 }, %RoutePattern{ direction_id: 0, id: "Orange-5-0", name: "Forest Hills", representative_trip_id: "40709151-20:15-OakGroveWellington", route_id: "Orange", time_desc: "Weekdays only", typicality: 3 } ]} ] @trip %Trip{ bikes_allowed?: false, direction_id: 1, headsign: "Oak Grove", id: "40709317", name: "", route_pattern_id: "Orange-3-1", shape_id: "903_0017" } @predictions [ %Prediction{ departing?: false, direction_id: 1, id: "prediction-40709316-70036-190", route: %Routes.Route{ custom_route?: false, description: :rapid_transit, direction_destinations: %{0 => "Forest Hills", 1 => "Oak Grove"}, direction_names: %{0 => "Southbound", 1 => "Northbound"}, id: "Orange", long_name: "Orange Line", name: "Orange Line", type: 1 }, schedule_relationship: nil, status: nil, stop: @stop, stop_sequence: 190, time: @now, track: nil, trip: %Schedules.Trip{ bikes_allowed?: false, direction_id: 1, headsign: "Oak Grove", id: "40709316", name: "", route_pattern_id: "Orange-3-1", shape_id: "903_0017" } }, %Prediction{ departing?: false, direction_id: 1, id: "prediction-40709317-70036-190", route: @route, schedule_relationship: nil, status: nil, stop_sequence: 190, stop: @stop, time: @now, track: nil, trip: @trip } ] @schedules [ %Schedule{ early_departure?: true, flag?: false, last_stop?: false, pickup_type: 0, route: @route, stop: @stop, stop_sequence: 1, time: @now, trip: @trip } ] @alerts [ %Alert{ id: "1234", active_period: [{@now, @now}], priority: :high, informed_entity: %IESet{ entities: [ %IE{route: "Orange"}, %IE{route: "70"} ] } }, %Alert{ id: "2345", active_period: [{@now, @now}], priority: :high, informed_entity: %IESet{ entities: [ %IE{route: "Orange"}, %IE{route: "Red"} ] } } ] test "stop_data/3 returns stop" do opts = [ stops_fn: fn _ -> @stop end, routes_fn: fn _ -> @route_with_patterns end, predictions_fn: fn _ -> @predictions end, schedules_fn: fn _, _ -> @schedules end, alerts_fn: fn _, _ -> @alerts end ] stops = [@stop.id] expected = [ %{ stop: %{accessibility: [], address: nil, id: "place-ogmnl", name: nil}, predicted_schedules_by_route_pattern: %{ "Forest Hills" => %{ direction_id: 0, predicted_schedules: [ %{ prediction: %{ __struct__: Predictions.Prediction, departing?: false, direction_id: 1, id: "prediction-40709316-70036-190", schedule_relationship: nil, status: nil, stop_sequence: 190, time: ["arriving"], track: nil, headsign: "Oak Grove" }, schedule: nil }, %{ prediction: %{ __struct__: Predictions.Prediction, departing?: false, direction_id: 1, id: "prediction-40709317-70036-190", schedule_relationship: nil, status: nil, stop_sequence: 190, time: ["arriving"], track: nil, headsign: "Oak Grove" }, schedule: nil } ] }, "Oak Grove" => %{ direction_id: 1, predicted_schedules: [ %{ prediction: %{ __struct__: Predictions.Prediction, departing?: false, direction_id: 1, id: "prediction-40709316-70036-190", schedule_relationship: nil, status: nil, stop_sequence: 190, time: ["arriving"], track: nil, headsign: "Oak Grove" }, schedule: nil }, %{ prediction: %{ __struct__: Predictions.Prediction, departing?: false, direction_id: 1, id: "prediction-40709317-70036-190", schedule_relationship: nil, status: nil, stop_sequence: 190, time: ["arriving"], track: nil, headsign: "Oak Grove" }, schedule: nil } ] } }, route: %{ __struct__: Routes.Route, alerts: @alerts |> Enum.map(&JsonHelpers.stringified_alert(&1, @now)), custom_route?: false, description: :rapid_transit, direction_destinations: %{"0" => "Forest Hills", "1" => "Oak Grove"}, direction_names: %{"0" => "Southbound", "1" => "Northbound"}, header: "Orange Line", id: "Orange", long_name: "Orange Line", name: "Orange Line", type: 1, color: "ED8B00", sort_order: 99_999 } } ] RealtimeSchedule.clear_cache() actual = RealtimeSchedule.stop_data(stops, @now, opts) assert actual == expected end test "stop_data/3 returns nil" do opts = [ stops_fn: fn _ -> nil end, routes_fn: fn _ -> [] end, predictions_fn: fn _ -> [] end, schedules_fn: fn _, _ -> [] end, alerts_fn: fn _, _ -> [] end ] stops = [@stop.id] expected = [] RealtimeSchedule.clear_cache() actual = RealtimeSchedule.stop_data(stops, @now, opts) assert actual == expected end test "log_warning_if_missing_trip/1 logs warning if prediction has no trip" do log_messages = ExUnit.CaptureLog.capture_log(fn -> RealtimeSchedule.log_warning_if_missing_trip(%Prediction{trip: nil}) end) assert log_messages =~ "prediction_without_trip" end end
26.538721
80
0.502791
737bc5ac6064d066773e6545b76bed2453761aa2
909
ex
Elixir
apps/peedy_f/lib/watermarker.ex
poteto/peedy
df9d5ee7fcbceb30b5939b36224a257249a180ea
[ "Apache-2.0" ]
34
2017-05-07T08:50:59.000Z
2021-11-25T00:27:11.000Z
apps/peedy_f/lib/watermarker.ex
poteto/peedy
df9d5ee7fcbceb30b5939b36224a257249a180ea
[ "Apache-2.0" ]
null
null
null
apps/peedy_f/lib/watermarker.ex
poteto/peedy
df9d5ee7fcbceb30b5939b36224a257249a180ea
[ "Apache-2.0" ]
7
2017-05-10T12:42:30.000Z
2021-11-03T01:21:02.000Z
defmodule PeedyF.Watermarker do require Logger alias PeedyF.Strategies.{Pdfkit, Erlguten} @after_compile __MODULE__ @nodejs Application.get_env(:peedy_f, :executables)[:nodejs] @pdfkit Application.get_env(:peedy_f, :executables)[:pdfkit] def create(text, strategy: :pdfkit) when is_binary(text), do: Pdfkit.new(text) def create(text, strategy: :erlguten) when is_binary(text), do: Erlguten.new(text) def create(text) do {microseconds, watermark} = :timer.tc(fn -> create(text, strategy: :pdfkit) end) Logger.info("Watermark for `#{text}` generated in #{microseconds / 1_000}ms") watermark end def __after_compile__(_env, _bytecode) do if is_nil(@nodejs), do: raise error_msg("nodejs") if is_nil(@pdfkit), do: raise error_msg("pdfkit") end defp error_msg(missing) do "Missing executable for `#{missing}`. Ensure it is installed." end end
30.3
81
0.705171
737bdb77d4955d77e35c9ba5f00b5052118d4c6a
5,428
ex
Elixir
clients/sheets/lib/google_api/sheets/v4/model/banding_properties.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/sheets/lib/google_api/sheets/v4/model/banding_properties.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/sheets/lib/google_api/sheets/v4/model/banding_properties.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.Sheets.V4.Model.BandingProperties do @moduledoc """ Properties referring a single dimension (either row or column). If both BandedRange.row_properties and BandedRange.column_properties are set, the fill colors are applied to cells according to the following rules: * header_color and footer_color take priority over band colors. * first_band_color takes priority over second_band_color. * row_properties takes priority over column_properties. For example, the first row color takes priority over the first column color, but the first column color takes priority over the second row color. Similarly, the row header takes priority over the column header in the top left cell, but the column header takes priority over the first row color if the row header is not set. ## Attributes * `firstBandColor` (*type:* `GoogleApi.Sheets.V4.Model.Color.t`, *default:* `nil`) - The first color that is alternating. (Required) * `firstBandColorStyle` (*type:* `GoogleApi.Sheets.V4.Model.ColorStyle.t`, *default:* `nil`) - The first color that is alternating. (Required) If first_band_color is also set, this field takes precedence. * `footerColor` (*type:* `GoogleApi.Sheets.V4.Model.Color.t`, *default:* `nil`) - The color of the last row or column. If this field is not set, the last row or column is filled with either first_band_color or second_band_color, depending on the color of the previous row or column. * `footerColorStyle` (*type:* `GoogleApi.Sheets.V4.Model.ColorStyle.t`, *default:* `nil`) - The color of the last row or column. If this field is not set, the last row or column is filled with either first_band_color or second_band_color, depending on the color of the previous row or column. If footer_color is also set, this field takes precedence. * `headerColor` (*type:* `GoogleApi.Sheets.V4.Model.Color.t`, *default:* `nil`) - The color of the first row or column. If this field is set, the first row or column is filled with this color and the colors alternate between first_band_color and second_band_color starting from the second row or column. Otherwise, the first row or column is filled with first_band_color and the colors proceed to alternate as they normally would. * `headerColorStyle` (*type:* `GoogleApi.Sheets.V4.Model.ColorStyle.t`, *default:* `nil`) - The color of the first row or column. If this field is set, the first row or column is filled with this color and the colors alternate between first_band_color and second_band_color starting from the second row or column. Otherwise, the first row or column is filled with first_band_color and the colors proceed to alternate as they normally would. If header_color is also set, this field takes precedence. * `secondBandColor` (*type:* `GoogleApi.Sheets.V4.Model.Color.t`, *default:* `nil`) - The second color that is alternating. (Required) * `secondBandColorStyle` (*type:* `GoogleApi.Sheets.V4.Model.ColorStyle.t`, *default:* `nil`) - The second color that is alternating. (Required) If second_band_color is also set, this field takes precedence. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :firstBandColor => GoogleApi.Sheets.V4.Model.Color.t(), :firstBandColorStyle => GoogleApi.Sheets.V4.Model.ColorStyle.t(), :footerColor => GoogleApi.Sheets.V4.Model.Color.t(), :footerColorStyle => GoogleApi.Sheets.V4.Model.ColorStyle.t(), :headerColor => GoogleApi.Sheets.V4.Model.Color.t(), :headerColorStyle => GoogleApi.Sheets.V4.Model.ColorStyle.t(), :secondBandColor => GoogleApi.Sheets.V4.Model.Color.t(), :secondBandColorStyle => GoogleApi.Sheets.V4.Model.ColorStyle.t() } field(:firstBandColor, as: GoogleApi.Sheets.V4.Model.Color) field(:firstBandColorStyle, as: GoogleApi.Sheets.V4.Model.ColorStyle) field(:footerColor, as: GoogleApi.Sheets.V4.Model.Color) field(:footerColorStyle, as: GoogleApi.Sheets.V4.Model.ColorStyle) field(:headerColor, as: GoogleApi.Sheets.V4.Model.Color) field(:headerColorStyle, as: GoogleApi.Sheets.V4.Model.ColorStyle) field(:secondBandColor, as: GoogleApi.Sheets.V4.Model.Color) field(:secondBandColorStyle, as: GoogleApi.Sheets.V4.Model.ColorStyle) end defimpl Poison.Decoder, for: GoogleApi.Sheets.V4.Model.BandingProperties do def decode(value, options) do GoogleApi.Sheets.V4.Model.BandingProperties.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Sheets.V4.Model.BandingProperties do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
54.828283
169
0.738025
737bf52e9ff29a6d441cda712b1d60c0c7f1ae5e
231
exs
Elixir
priv/repo/migrations/20201019210311_change_current_url_and_pathname_fields_type_to_text.exs
ZmagoD/papercups
dff9a5822b809edc4fd8ecf198566f9b14ab613f
[ "MIT" ]
4,942
2020-07-20T22:35:28.000Z
2022-03-31T15:38:51.000Z
priv/repo/migrations/20201019210311_change_current_url_and_pathname_fields_type_to_text.exs
ZmagoD/papercups
dff9a5822b809edc4fd8ecf198566f9b14ab613f
[ "MIT" ]
552
2020-07-22T01:39:04.000Z
2022-02-01T00:26:35.000Z
priv/repo/migrations/20201019210311_change_current_url_and_pathname_fields_type_to_text.exs
ZmagoD/papercups
dff9a5822b809edc4fd8ecf198566f9b14ab613f
[ "MIT" ]
396
2020-07-22T19:27:48.000Z
2022-03-31T05:25:24.000Z
defmodule ChatApi.Repo.Migrations.ChangeCurrentUrlAndPathnameFieldsTypeToText do use Ecto.Migration def change do alter table(:customers) do modify :current_url, :text modify :pathname, :text end end end
21
80
0.74026
737c07d00c982e4a3cf39e9d0031619fdc4d8c42
1,157
ex
Elixir
lib/horde/cluster.ex
SvenW/horde
6db5b835d188382b2ad6ebe026871bf7558224b2
[ "MIT" ]
null
null
null
lib/horde/cluster.ex
SvenW/horde
6db5b835d188382b2ad6ebe026871bf7558224b2
[ "MIT" ]
null
null
null
lib/horde/cluster.ex
SvenW/horde
6db5b835d188382b2ad6ebe026871bf7558224b2
[ "MIT" ]
null
null
null
defmodule Horde.Cluster do require Logger @moduledoc """ Public functions to join and leave hordes. Calling `Horde.Cluster.set_members/2` will join the given members in a cluster. Cluster membership is propagated via a CRDT, so setting it once on a single node is sufficient. ```elixir {:ok, sup1} = Horde.Supervisor.start_link([], name: :supervisor_1, strategy: :one_for_one) {:ok, sup2} = Horde.Supervisor.start_link([], name: :supervisor_2, strategy: :one_for_one) {:ok, sup3} = Horde.Supervisor.start_link([], name: :supervisor_3, strategy: :one_for_one) :ok = Horde.Cluster.set_members(:supervisor_1, [:supervisor_1, :supervisor_2, :supervisor_3]) ``` """ @type member :: {name :: atom(), node :: atom()} | (name :: atom()) @spec set_members(horde :: GenServer.server(), members :: [member()]) :: :ok | {:error, term()} def set_members(horde, members, timeout \\ 5000) do GenServer.call(horde, {:set_members, members}, timeout) end @doc """ Get the members (nodes) of the horde """ @spec members(horde :: GenServer.server()) :: map() def members(horde) do GenServer.call(horde, :members) end end
36.15625
177
0.681936
737c3186971469e139857b8b2b0207726330aa01
268
exs
Elixir
test/atfirs_web/views/layout_view_test.exs
iboss-ptk/Atfirs
1361c8f1b86971317b33212f9269aaffa0f09110
[ "MIT" ]
2
2021-01-23T09:23:20.000Z
2021-02-12T09:15:45.000Z
test/atfirs_web/views/layout_view_test.exs
iboss-ptk/Atfirs
1361c8f1b86971317b33212f9269aaffa0f09110
[ "MIT" ]
null
null
null
test/atfirs_web/views/layout_view_test.exs
iboss-ptk/Atfirs
1361c8f1b86971317b33212f9269aaffa0f09110
[ "MIT" ]
null
null
null
defmodule AtfirsWeb.LayoutViewTest do use AtfirsWeb.ConnCase, async: true # When testing helpers, you may want to import Phoenix.HTML and # use functions such as safe_to_string() to convert the helper # result into an HTML string. # import Phoenix.HTML end
29.777778
65
0.764925
737c44b9622ef6256bd87a4d4bc9ccddc2845604
2,530
ex
Elixir
clients/service_usage/lib/google_api/service_usage/v1/model/auth_requirement.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/service_usage/lib/google_api/service_usage/v1/model/auth_requirement.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/service_usage/lib/google_api/service_usage/v1/model/auth_requirement.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.ServiceUsage.V1.Model.AuthRequirement do @moduledoc """ User-defined authentication requirements, including support for [JSON Web Token (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32). ## Attributes * `audiences` (*type:* `String.t`, *default:* `nil`) - NOTE: This will be deprecated soon, once AuthProvider.audiences is implemented and accepted in all the runtime components. The list of JWT [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3). that are allowed to access. A JWT containing any of these audiences will be accepted. When this setting is absent, only JWTs with audience "https://Service_name/API_name" will be accepted. For example, if no audiences are in the setting, LibraryService API will only accept JWTs with the following audience "https://library-example.googleapis.com/google.example.library.v1.LibraryService". Example: audiences: bookstore_android.apps.googleusercontent.com, bookstore_web.apps.googleusercontent.com * `providerId` (*type:* `String.t`, *default:* `nil`) - id from authentication provider. Example: provider_id: bookstore_auth """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :audiences => String.t(), :providerId => String.t() } field(:audiences) field(:providerId) end defimpl Poison.Decoder, for: GoogleApi.ServiceUsage.V1.Model.AuthRequirement do def decode(value, options) do GoogleApi.ServiceUsage.V1.Model.AuthRequirement.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.ServiceUsage.V1.Model.AuthRequirement do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
35.633803
125
0.721344
737c5cb53dad98d549e28f780b75ca9cce02e9c5
221
exs
Elixir
test/dmage_web/live/main_live_test.exs
Devotu/dmage
54d8e55bf010f2e0beb2bd0c21157366f0375bd3
[ "MIT" ]
null
null
null
test/dmage_web/live/main_live_test.exs
Devotu/dmage
54d8e55bf010f2e0beb2bd0c21157366f0375bd3
[ "MIT" ]
null
null
null
test/dmage_web/live/main_live_test.exs
Devotu/dmage
54d8e55bf010f2e0beb2bd0c21157366f0375bd3
[ "MIT" ]
null
null
null
defmodule DmageWeb.MainLiveTest do use DmageWeb.ConnCase import Phoenix.LiveViewTest test "disconnected and connected render", %{conn: conn} do {:ok, page_live, _disconnected_html} = live(conn, "/") end end
22.1
60
0.733032
737c6b5c17b92cf22d3a112cca933f49cdafed32
14,766
exs
Elixir
test/twirp/plug_test.exs
rahmatullah5/twirp-elixir
9177cda4beb2fc89efb0a0c9239ff4d28a6a6ce6
[ "Apache-2.0" ]
30
2019-11-03T16:30:13.000Z
2020-06-23T19:38:53.000Z
test/twirp/plug_test.exs
rahmatullah5/twirp-elixir
9177cda4beb2fc89efb0a0c9239ff4d28a6a6ce6
[ "Apache-2.0" ]
16
2020-03-13T17:56:16.000Z
2020-06-11T10:40:02.000Z
test/twirp/plug_test.exs
rahmatullah5/twirp-elixir
9177cda4beb2fc89efb0a0c9239ff4d28a6a6ce6
[ "Apache-2.0" ]
3
2019-12-05T16:43:15.000Z
2020-05-11T21:34:44.000Z
defmodule Twirp.PlugTest do use ExUnit.Case, async: false use Plug.Test alias Twirp.Error defmodule Size do @moduledoc false use Protobuf, syntax: :proto3 defstruct [:inches] field :inches, 1, type: :int32 end defmodule Hat do @moduledoc false use Protobuf, syntax: :proto3 defstruct [:color] field :color, 2, type: :string end defmodule Service do use Twirp.Service package "plug.test" service "Haberdasher" rpc :MakeHat, Size, Hat, :make_hat end defmodule GoodHandler do def make_hat(_env, %Size{inches: inches}) do if inches <= 0 do Error.invalid_argument("I can't make a hat that small!") else %Hat{color: "red"} end end end defmodule EmptyHandler do end defmodule BadHandler do def make_hat(_env, size) do size end end @opts Twirp.Plug.init([service: Service, handler: GoodHandler]) def json_req(method, payload) do endpoint = "/twirp/plug.test.Haberdasher/#{method}" body = if is_map(payload), do: Jason.encode!(payload), else: payload :post |> conn(endpoint, body) |> put_req_header("content-type", "application/json") end def proto_req(method, payload) do endpoint = "/twirp/plug.test.Haberdasher/#{method}" mod = payload.__struct__ :post |> conn(endpoint, mod.encode(payload)) |> put_req_header("content-type", "application/protobuf") end def content_type(conn) do conn.resp_headers |> Enum.find_value(fn {h, v} -> if h == "content-type", do: v, else: false end) |> String.split(";") # drop the charset if there is one |> Enum.at(0) end def call(req, opts \\ @opts) do Twirp.Plug.call(req, opts) end test "json request" do req = json_req("MakeHat", %{inches: 10}) conn = call(req) assert conn.status == 200 end test "proto request" do req = proto_req("MakeHat", Size.new(inches: 10)) conn = call(req) assert conn.status == 200 assert Hat.new(color: "red") == Hat.decode(conn.resp_body) end test "non twirp requests" do req = conn(:post, "/anotherurl") conn = call(req) assert conn == req end test "twirp requests to a different service" do req = conn(:post, "/twirp/another.service.Service") conn = call(req) assert conn == req end test "not a POST" do req = conn(:get, "/twirp/plug.test.Haberdasher/MakeHat") conn = call(req) assert conn.status == 404 assert content_type(conn) == "application/json" body = Jason.decode!(conn.resp_body) assert body["code"] == "bad_route" assert body["msg"] == "HTTP request must be POST" assert body["meta"] == %{ "twirp_invalid_route" => "GET /twirp/plug.test.Haberdasher/MakeHat" } end test "request has incorrect content type" do req = conn(:post, "/twirp/plug.test.Haberdasher/MakeHat") |> put_req_header("content-type", "application/msgpack") conn = call(req) assert conn.status == 404 assert content_type(conn) == "application/json" body = Jason.decode!(conn.resp_body) assert body["code"] == "bad_route" assert body["msg"] == "Unexpected Content-Type: application/msgpack" assert body["meta"] == %{ "twirp_invalid_route" => "POST /twirp/plug.test.Haberdasher/MakeHat" } end test "request has no content-type" do req = conn(:post, "/twirp/plug.test.Haberdasher/MakeHat") conn = call(req) assert conn.status == 404 assert content_type(conn) == "application/json" body = Jason.decode!(conn.resp_body) assert body["code"] == "bad_route" assert body["msg"] == "Unexpected Content-Type: nil" assert body["meta"] == %{ "twirp_invalid_route" => "POST /twirp/plug.test.Haberdasher/MakeHat" } end test "handler doesn't define function" do opts = Twirp.Plug.init([service: Service, handler: EmptyHandler]) req = proto_req("MakeHat", Size.new(inches: 10)) # We need to manually set options like this to skip the # compile time checking done in init. conn = call(req, opts) assert conn.status == 501 assert content_type(conn) == "application/json" resp = Jason.decode!(conn.resp_body) assert resp["code"] == "unimplemented" assert resp["msg"] == "Handler function make_hat is not implemented" end test "unknown method" do req = proto_req("MakeShoes", Size.new(inches: 10)) conn = call(req) assert conn.status == 404 assert content_type(conn) == "application/json" resp = Jason.decode!(conn.resp_body) assert resp["code"] == "bad_route" assert resp["msg"] == "Invalid rpc method: MakeShoes" assert resp["meta"] == %{ "twirp_invalid_route" => "POST /twirp/plug.test.Haberdasher/MakeShoes" } end test "bad json message" do req = json_req("MakeHat", "not json") conn = call(req) assert conn.status == 404 assert content_type(conn) == "application/json" resp = Jason.decode!(conn.resp_body) assert resp["code"] == "bad_route" assert resp["msg"] == "Invalid request body for rpc method: MakeHat" assert resp["meta"] == %{ "twirp_invalid_route" => "POST /twirp/plug.test.Haberdasher/MakeHat" } end test "bad proto message" do req = :post |> conn("/twirp/plug.test.Haberdasher/MakeHat", "bad protobuf") |> put_req_header("content-type", "application/protobuf") conn = call(req) assert conn.status == 404 assert content_type(conn) == "application/json" resp = Jason.decode!(conn.resp_body) assert resp["code"] == "bad_route" assert resp["msg"] == "Invalid request body for rpc method: MakeHat" assert resp["meta"] == %{ "twirp_invalid_route" => "POST /twirp/plug.test.Haberdasher/MakeHat" } end test "handler returns incorrect response" do opts = Twirp.Plug.init([service: Service, handler: BadHandler]) req = proto_req("MakeHat", Size.new(inches: 10)) conn = call(req, opts) assert conn.status == 500 assert content_type(conn) == "application/json" resp = Jason.decode!(conn.resp_body) assert resp["code"] == "internal" assert resp["msg"] == "Handler method make_hat expected to return one of Elixir.Twirp.PlugTest.Hat or Twirp.Error but returned %Twirp.PlugTest.Size{inches: 10}" end test "handler doesn't return an error, struct or map" do defmodule InvalidHandler do def make_hat(_, _) do "invalid" end end opts = Twirp.Plug.init([service: Service, handler: InvalidHandler]) req = proto_req("MakeHat", Size.new(inches: 10)) conn = call(req, opts) assert conn.status == 500 assert content_type(conn) == "application/json" resp = Jason.decode!(conn.resp_body) assert resp["code"] == "internal" assert resp["msg"] == "Handler method make_hat expected to return one of Elixir.Twirp.PlugTest.Hat or Twirp.Error but returned \"invalid\"" end describe "when the body has been pre-parsed" do test "json requests use the body params" do req = json_req("MakeHat", %{}) req = Map.put(req, :body_params, %{"inches" => 10}) conn = call(req) assert conn.status == 200 assert resp = Jason.decode!(conn.resp_body) assert resp["color"] != nil end test "returns errors if the payload is incorrect" do req = json_req("MakeHat", %{}) req = Map.put(req, :body_params, %{"keathley" => "bar"}) conn = call(req) assert conn.status == 404 assert content_type(conn) == "application/json" resp = Jason.decode!(conn.resp_body) assert resp["code"] == "bad_route" assert resp["msg"] == "Invalid request body for rpc method: MakeHat" assert resp["meta"] == %{ "twirp_invalid_route" => "POST /twirp/plug.test.Haberdasher/MakeHat" } end end test "handler receives env" do defmodule HandlerWithEnv do def make_hat(env, _) do assert Norm.valid?(env, Norm.selection(Twirp.Plug.env_s())) end end opts = Twirp.Plug.init([service: Service, handler: RaiseHandler]) req = proto_req("MakeHat", Size.new(inches: 10)) call(req, opts) end test "handler raises exception" do defmodule RaiseHandler do def make_hat(_env, _size) do raise ArgumentError, "Blow this ish up" end end opts = Twirp.Plug.init([service: Service, handler: RaiseHandler]) req = proto_req("MakeHat", Size.new(inches: 10)) conn = call(req, opts) assert conn.status == 500 assert content_type(conn) == "application/json" resp = Jason.decode!(conn.resp_body) assert resp["code"] == "internal" assert resp["msg"] == "Blow this ish up" assert resp["meta"] == %{} end describe "before" do test "hooks are run before the handler is called" do us = self() f = fn conn, env -> assert %Plug.Conn{} = conn assert Norm.valid?(env, Norm.selection(Twirp.Plug.env_s())) assert env.input == Size.new(inches: 10) send(us, :plug_called) env end opts = Twirp.Plug.init [ service: Service, handler: GoodHandler, before: [f] ] req = proto_req("MakeHat", Size.new(inches: 10)) _conn = call(req, opts) assert_receive :plug_called end test "hooks can update the env" do us = self() first = fn _conn, env -> Map.put(env, :test, :foobar) end second = fn _conn, env -> assert env.test == :foobar send(us, :done) env end opts = Twirp.Plug.init [ service: Service, handler: GoodHandler, before: [first, second] ] req = proto_req("MakeHat", Size.new(inches: 10)) _conn = call(req, opts) assert_receive :done end test "before hooks are halted if they return an error" do first = fn _conn, _env -> Twirp.Error.permission_denied("You're not authorized for this") end second = fn _conn, _env -> flunk "I should never make it here" end opts = Twirp.Plug.init [ service: Service, handler: GoodHandler, before: [first, second] ] req = proto_req("MakeHat", Size.new(inches: 10)) _conn = call(req, opts) end test "returns the most recent env" do us = self() first = fn _conn, env -> Map.put(env, :test, "This is a test") end second = fn _conn, _env -> Twirp.Error.permission_denied("Bail out") end error = fn env, error -> assert error == Twirp.Error.permission_denied("Bail out") assert env.test == "This is a test" send us, :done end opts = Twirp.Plug.init [ service: Service, handler: GoodHandler, before: [first, second], on_error: [error] ] req = proto_req("MakeHat", Size.new(inches: 10)) _conn = call(req, opts) assert_receive :done end end describe "on_success hooks" do test "are called if the rpc handler was successful" do us = self() first = fn env -> assert env.output == Hat.encode(Hat.new(color: "red")) send us, :done end opts = Twirp.Plug.init [ service: Service, handler: GoodHandler, on_success: [first] ] req = proto_req("MakeHat", Size.new(inches: 10)) _conn = call(req, opts) assert_receive :done end end describe "on_error hooks" do test "run if the handler returns an error" do defmodule ErrorHandler do def make_hat(_, _) do Twirp.Error.permission_denied("not allowed") end end us = self() first = fn _env, error -> assert error == Twirp.Error.permission_denied("not allowed") send us, :done end opts = Twirp.Plug.init [ service: Service, handler: ErrorHandler, on_error: [first] ] req = proto_req("MakeHat", Size.new(inches: 10)) conn = call(req, opts) assert_receive :done assert conn.status == 403 error = Jason.decode!(conn.resp_body) assert error["code"] == "permission_denied" end test "are called if there was an exception" do defmodule ExceptionToErrorHandler do def make_hat(_, _) do raise ArgumentError, "Boom!" end end us = self() on_error = fn _env, error -> assert error == Twirp.Error.internal("Boom!") send us, :done end opts = Twirp.Plug.init [ service: Service, handler: ExceptionToErrorHandler, on_error: [on_error] ] req = proto_req("MakeHat", Size.new(inches: 10)) conn = call(req, opts) assert_receive :done assert conn.status == 500 error = Jason.decode!(conn.resp_body) assert error["code"] == "internal" end end describe "on_exception hooks" do test "are called if there is an exception raised while processing the call" do defmodule ExceptionHandler do def make_hat(_, _) do raise ArgumentError, "Boom!" end end us = self() first = fn env, exception -> assert Norm.valid?(env, Twirp.Plug.env_s()) assert match?(%ArgumentError{}, exception) send us, :done end opts = Twirp.Plug.init [ service: Service, handler: ExceptionHandler, on_exception: [first] ] req = proto_req("MakeHat", Size.new(inches: 10)) conn = call(req, opts) assert_receive :done assert conn.status == 500 error = Jason.decode!(conn.resp_body) assert error["code"] == "internal" end test "catches exceptions raised in other before hooks" do us = self() bad_hook = fn _, _ -> raise ArgumentError, "Thrown from hook" end bad_success_hook = fn _env -> raise ArgumentError, "Thrown from success" end exception_hook = fn env, exception -> assert Norm.valid?(env, Twirp.Plug.env_s()) assert match?(%ArgumentError{}, exception) send us, :done end opts = Twirp.Plug.init [ service: Service, handler: GoodHandler, before: [bad_hook], on_exception: [exception_hook], ] req = proto_req("MakeHat", Size.new(inches: 10)) _conn = call(req, opts) assert_receive :done opts = Twirp.Plug.init [ service: Service, handler: GoodHandler, on_success: [bad_success_hook], on_exception: [exception_hook], ] req = proto_req("MakeHat", Size.new(inches: 10)) _conn = call(req, opts) assert_receive :done end end end
27.243542
164
0.613165
737c7507121c376a1634d4a36a0962f93c344a12
7,959
ex
Elixir
lib/faker/internet.ex
subvisual/faker
ee055a15d0669f50316fcb8799ab0fffd0ea0715
[ "MIT" ]
null
null
null
lib/faker/internet.ex
subvisual/faker
ee055a15d0669f50316fcb8799ab0fffd0ea0715
[ "MIT" ]
57
2018-12-24T10:39:32.000Z
2020-12-28T10:13:00.000Z
lib/faker/internet.ex
subvisual/faker
ee055a15d0669f50316fcb8799ab0fffd0ea0715
[ "MIT" ]
1
2019-02-03T17:04:21.000Z
2019-02-03T17:04:21.000Z
defmodule Faker.Internet do alias Faker.Lorem alias Faker.Name.En, as: Name alias Faker.Util import Faker.Util, only: [pick: 1] @moduledoc """ Functions for generating internet related data """ @doc """ Returns a complete random domain name ## Examples iex> Faker.Internet.domain_name() "blick.org" iex> Faker.Internet.domain_name() "schumm.info" iex> Faker.Internet.domain_name() "sipes.com" iex> Faker.Internet.domain_name() "hane.info" """ @spec domain_name() :: String.t() def domain_name do "#{domain_word()}.#{domain_suffix()}" end @doc """ Returns a random domain suffix ## Examples iex> Faker.Internet.domain_suffix() "com" iex> Faker.Internet.domain_suffix() "org" iex> Faker.Internet.domain_suffix() "name" iex> Faker.Internet.domain_suffix() "info" """ @spec domain_suffix() :: String.t() def domain_suffix do localised_module().domain_suffix end @doc """ Returns a random username ## Examples iex> Faker.Internet.user_name() "elizabeth2056" iex> Faker.Internet.user_name() "reese1921" iex> Faker.Internet.user_name() "aniya1972" iex> Faker.Internet.user_name() "bianka2054" """ @spec user_name() :: String.t() def user_name, do: user_name(Faker.random_between(0, 1)) defp user_name(0) do "#{Name.first_name() |> String.replace(~s( ), ~s()) |> String.downcase()}#{ Faker.random_between(1900, 2100) }" end defp user_name(1) do [Name.first_name(), Name.last_name()] |> Enum.map_join(Util.pick(~w(. _)), &String.replace(&1, ~s( ), ~s())) |> String.downcase() end @doc """ Returns a random domain word ## Examples iex> Faker.Internet.domain_word() "blick" iex> Faker.Internet.domain_word() "hayes" iex> Faker.Internet.domain_word() "schumm" iex> Faker.Internet.domain_word() "rolfson" """ @spec domain_word() :: String.t() def domain_word do "#{Name.last_name() |> String.split(["'"]) |> Enum.join() |> String.downcase()}" end @doc """ Returns a complete email based on a domain name ## Examples iex> Faker.Internet.email() "[email protected]" iex> Faker.Internet.email() "[email protected]" iex> Faker.Internet.email() "[email protected]" iex> Faker.Internet.email() "[email protected]" """ @spec email() :: String.t() def email do "#{user_name()}@#{domain_name()}" end @doc """ Returns a complete free email based on a free email service [gmail, yahoo, hotmail] ## Examples iex> Faker.Internet.free_email() "[email protected]" iex> Faker.Internet.free_email() "[email protected]" iex> Faker.Internet.free_email() "[email protected]" iex> Faker.Internet.free_email() "[email protected]" """ @spec free_email() :: String.t() def free_email do "#{user_name()}@#{free_email_service()}" end @doc """ Returns a safe email ## Examples iex> Faker.Internet.safe_email() "[email protected]" iex> Faker.Internet.safe_email() "[email protected]" iex> Faker.Internet.safe_email() "[email protected]" iex> Faker.Internet.safe_email() "[email protected]" """ @spec safe_email() :: String.t() def safe_email do "#{user_name()}@example.#{Util.pick(~w(org com net))}" end @doc """ Returns a free email service ## Examples iex> Faker.Internet.free_email_service() "gmail.com" iex> Faker.Internet.free_email_service() "hotmail.com" iex> Faker.Internet.free_email_service() "gmail.com" iex> Faker.Internet.free_email_service() "hotmail.com" """ @spec free_email_service() :: String.t() def free_email_service do localised_module().free_email_service end @doc """ Returns a random url ## Examples iex> Faker.Internet.url() "http://hayes.name" iex> Faker.Internet.url() "http://sipes.com" iex> Faker.Internet.url() "http://padberg.name" iex> Faker.Internet.url() "http://hartmann.biz" """ @spec url() :: String.t() def url, do: url(Faker.random_between(0, 1)) defp url(0), do: "http://#{domain_name()}" defp url(1), do: "https://#{domain_name()}" @doc """ Returns a random image url from placekitten.com | placehold.it | dummyimage.com ## Examples iex> Faker.Internet.image_url() "https://placekitten.com/131/131" iex> Faker.Internet.image_url() "https://placekitten.com/554/554" iex> Faker.Internet.image_url() "https://placehold.it/936x936" iex> Faker.Internet.image_url() "https://placehold.it/541x541" """ @spec image_url() :: String.t() def image_url, do: image_url(Faker.random_between(0, 2)) defp image_url(0) do size = Faker.random_between(10, 1024) "https://placekitten.com/#{size}/#{size}" end defp image_url(1) do size = Faker.random_between(10, 1024) "https://placehold.it/#{size}x#{size}" end defp image_url(2) do size = Faker.random_between(10, 1024) "https://dummyimage.com/#{size}x#{size}" end @doc """ Generates an ipv4 address ## Examples iex> Faker.Internet.ip_v4_address() "214.217.139.136" iex> Faker.Internet.ip_v4_address() "200.102.244.150" iex> Faker.Internet.ip_v4_address() "219.212.222.123" iex> Faker.Internet.ip_v4_address() "164.141.15.82" """ @spec ip_v4_address() :: String.t() def ip_v4_address do Enum.map_join(1..4, ".", fn _part -> Faker.random_between(0, 255) end) end @doc """ Generates an ipv6 address ## Examples iex> Faker.Internet.ip_v6_address() "A2D6:F5D9:BD8B:C588:0DC8:9566:43F4:B196" iex> Faker.Internet.ip_v6_address() "05DB:FAD4:88DE:397B:75A4:A98D:DF0F:1F52" iex> Faker.Internet.ip_v6_address() "6229:4EFA:2F7B:FEF9:EB07:0128:85B2:DC72" iex> Faker.Internet.ip_v6_address() "E867:34BC:715B:FB7C:7E96:AF4F:C733:A82D" """ @spec ip_v6_address() :: String.t() def ip_v6_address do Enum.map_join(1..8, ":", fn _part -> Faker.random_between(0, 65535) |> Integer.to_string(16) |> String.pad_leading(4, ["0"]) end) end @doc """ Generates a mac address ## Examples iex> Faker.Internet.mac_address() "d6:d9:8b:88:c8:66" iex> Faker.Internet.mac_address() "f4:96:db:d4:de:7b" iex> Faker.Internet.mac_address() "a4:8d:0f:52:29:fa" iex> Faker.Internet.mac_address() "7b:f9:07:28:b2:72" """ @spec mac_address() :: String.t() def mac_address do 1..6 |> Enum.map_join(":", &format_mac_address/1) |> String.downcase() end @doc """ Generates a slug If no words are provided it will generate 2 to 5 random words If no glue is provied it will use one of -, _ or . ## Examples iex> Faker.Internet.slug() "sint-deleniti-consequatur-ut" iex> Faker.Internet.slug() "sit_et" iex> Faker.Internet.slug(["foo", "bar"]) "foo-bar" iex> Faker.Internet.slug(["foo", "bar"], ["."]) "foo.bar" """ @spec slug() :: String.t() def slug do slug(Lorem.words(2..5)) end @spec slug([String.t()]) :: String.t() def slug(words) do slug(words, ["-", "_", "."]) end @spec slug([String.t()], [String.t()]) :: String.t() def slug(words, glue) do words |> Enum.take_random(length(words)) |> Enum.join(pick(glue)) |> String.downcase() end defp format_mac_address(_part) do Faker.random_between(0, 255) |> Integer.to_string(16) |> String.pad_leading(2, ["0"]) end defp localised_module, do: Module.concat(__MODULE__, Faker.mlocale()) end
23.972892
85
0.616032
737c7db5bf065078f0168712684bd9df38acb728
519
exs
Elixir
apps/reaper/config/dev.exs
jakeprem/smartcitiesdata
da309ac0d2261527278951cbae88604455207589
[ "Apache-2.0" ]
1
2021-04-05T19:17:18.000Z
2021-04-05T19:17:18.000Z
apps/reaper/config/dev.exs
SmartColumbusOS/smartcitiesdata
c8553d34631c822b034945eebf396994bf1001ff
[ "Apache-2.0" ]
11
2020-01-07T15:43:42.000Z
2020-12-22T15:23:25.000Z
apps/reaper/config/dev.exs
jakeprem/smartcitiesdata
da309ac0d2261527278951cbae88604455207589
[ "Apache-2.0" ]
null
null
null
use Mix.Config host = case System.get_env("HOST_IP") do nil -> "127.0.0.1" defined -> defined end config :libcluster, topologies: [ sculler_cluster: [ strategy: Elixir.Cluster.Strategy.Epmd, config: [ hosts: [:"[email protected]", :"[email protected]"] ] ] ] config :redix, :args, host: "localhost" System.put_env("HOST", "localhost") config :reaper, divo: [ {DivoKafka, [create_topics: "streaming-raw:1:1"]}, DivoRedis ], divo_wait: [dwell: 700, max_tries: 50]
17.896552
54
0.597303
737cc31a1880ce7479266e8cf881a5407556ae73
2,419
exs
Elixir
mix.exs
tdnguyen85/blog-elixir
6bf7ebb3968a2c535cef9d61866bd0a11338be54
[ "MIT" ]
null
null
null
mix.exs
tdnguyen85/blog-elixir
6bf7ebb3968a2c535cef9d61866bd0a11338be54
[ "MIT" ]
null
null
null
mix.exs
tdnguyen85/blog-elixir
6bf7ebb3968a2c535cef9d61866bd0a11338be54
[ "MIT" ]
null
null
null
defmodule RealWorld.Mixfile do use Mix.Project def project do [ app: :real_world, version: "0.0.1", elixir: "~> 1.5", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps(), test_coverage: [tool: ExCoveralls], # Docs name: "RealWorld Example App", source_url: "https://github.com/gothinkster/elixir-phoenix-realworld-example-app", homepage_url: "https://github.com/gothinkster/elixir-phoenix-realworld-example-app", # The main page in the docs docs: [main: "RealWorld Example App", logo: "logo.png", extras: ["README.md"]] ] end # Configuration for the OTP application. # # Type `mix help compile.app` for more information. def application do [ #applications: [:edeliver], mod: {RealWorld.Application, []}, extra_applications: [:logger, :runtime_tools, :comeonin] ] end # Specifies which paths to compile per environment. defp elixirc_paths(:test), do: ["lib", "test/support", "test/factories"] defp elixirc_paths(_), do: ["lib"] # Specifies your project dependencies. # # Type `mix help deps` for examples and options. defp deps do [ {:phoenix, "~> 1.3.0"}, {:phoenix_pubsub, "~> 1.0"}, {:phoenix_ecto, "~> 3.2"}, {:postgrex, "~> 0.13.3"}, {:gettext, "~> 0.11"}, {:proper_case, "~> 1.0.0"}, {:cowboy, "~> 1.1"}, {:comeonin, "~> 3.2"}, {:guardian, "~> 1.0"}, {:excoveralls, "~> 0.7", only: [:dev, :test]}, {:credo, "~> 0.8.5", only: [:dev, :test]}, {:ex_machina, "~> 2.0", only: :test}, {:ex_doc, "~> 0.16", only: :dev, runtime: false}, {:plug, "~> 1.0"}, {:corsica, "~> 1.0"}, {:mogrify, "~> 0.6.1"}, {:edeliver, ">= 1.4.5"}, {:distillery, "~> 1.5", runtime: false} ] 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
30.2375
90
0.570484
737cc44c784b39e121c7d1bd27efa1017883c18b
7,736
ex
Elixir
lib/sqlite_db_connection/protocol.ex
danielspofford/sqlite_ecto2
7ba0b627108b0e1eb73d46741210bd7a11d4fd8b
[ "MIT" ]
62
2017-01-13T21:01:39.000Z
2018-07-24T12:57:01.000Z
lib/sqlite_db_connection/protocol.ex
danielspofford/sqlite_ecto2
7ba0b627108b0e1eb73d46741210bd7a11d4fd8b
[ "MIT" ]
206
2016-12-24T01:56:29.000Z
2018-06-18T01:47:50.000Z
lib/sqlite_db_connection/protocol.ex
danielspofford/sqlite_ecto2
7ba0b627108b0e1eb73d46741210bd7a11d4fd8b
[ "MIT" ]
27
2018-12-22T04:02:30.000Z
2021-02-18T20:20:57.000Z
defmodule Sqlite.DbConnection.Protocol do @moduledoc false alias Sqlite.DbConnection.Query use DBConnection defstruct [db: nil, path: nil, checked_out?: false] @type state :: %__MODULE__{db: pid, path: String.t, checked_out?: boolean} @spec connect(Keyword.t) :: {:ok, state} def connect(opts) do db_path = Keyword.fetch!(opts, :database) db_timeout = Keyword.get(opts, :db_timeout, 5000) {:ok, db} = Sqlitex.Server.start_link(db_path, db_timeout: db_timeout) :ok = Sqlitex.Server.exec(db, "PRAGMA foreign_keys = ON") {:ok, [[foreign_keys: 1]]} = Sqlitex.Server.query(db, "PRAGMA foreign_keys") {:ok, %__MODULE__{db: db, path: db_path, checked_out?: false}} end @spec disconnect(Exception.t, state) :: :ok def disconnect(_exc, %__MODULE__{db: db} = _state) when db != nil do GenServer.stop(db) :ok end def disconnect(_exception, _state), do: :ok @spec checkout(state) :: {:ok, state} def checkout(%{checked_out?: false} = s) do {:ok, %{s | checked_out?: true}} end @spec checkin(state) :: {:ok, state} def checkin(%{checked_out?: true} = s) do {:ok, %{s | checked_out?: false}} end @spec handle_prepare(Sqlite.DbConnection.Query.t, Keyword.t, state) :: {:ok, Sqlite.DbConnection.Query.t, state} | {:error, ArgumentError.t, state} def handle_prepare(%Query{statement: statement, prepared: nil} = query, _opts, %__MODULE__{checked_out?: true, db: db} = s) do binary_stmt = :erlang.iolist_to_binary(statement) case Sqlitex.Server.prepare(db, binary_stmt) do {:ok, prepared_info} -> updated_query = %{query | prepared: refined_info(prepared_info)} {:ok, updated_query, s} {:error, {_sqlite_errcode, _message}} = err -> sqlite_error(err, s) end end def handle_prepare(query, _opts, s) do query_error(s, "query #{inspect query} has already been prepared") end @spec handle_execute(Sqlite.DbConnection.Query.t, list, Keyword.t, state) :: {:ok, Sqlite.DbConnection.Result.t, state} | {:error, ArgumentError.t, state} | {:error, Sqlite.DbConnection.Error.t, state} def handle_execute(%Query{} = query, params, opts, s) do handle_execute(query, params, :sync, opts, s) end @spec handle_close(Sqlite.DbConnection.Query.t, Keyword.t, state) :: {:ok, Sqlite.DbConnection.Result.t, state} | {:error, ArgumentError.t, state} | {:error, Sqlite.DbConnection.Error.t, state} def handle_close(_query, _opts, s) do # no-op: esqlite doesn't expose statement close. # Instead it relies on statements getting garbage collected. res = %Sqlite.DbConnection.Result{command: :close} {:ok, res, s} end @spec handle_begin(Keyword.t, state) :: {:ok, Sqlite.DbConnection.Result.t, state} def handle_begin(opts, s) do sql = case Keyword.get(opts, :mode, :transaction) do :transaction -> "BEGIN" :savepoint -> "SAVEPOINT sqlite_ecto_savepoint" end handle_transaction(sql, [timeout: Keyword.get(opts, :timeout, 5000)], s) end @spec handle_commit(Keyword.t, state) :: {:ok, Sqlite.DbConnection.Result.t, state} def handle_commit(opts, s) do sql = case Keyword.get(opts, :mode, :transaction) do :transaction -> "COMMIT" :savepoint -> "RELEASE SAVEPOINT sqlite_ecto_savepoint" end handle_transaction(sql, [timeout: Keyword.get(opts, :timeout, 5000)], s) end @spec handle_rollback(Keyword.t, state) :: {:ok, Sqlite.DbConnection.Result.t, state} def handle_rollback(opts, s) do sql = case Keyword.get(opts, :mode, :transaction) do :transaction -> "ROLLBACK" :savepoint -> "ROLLBACK TO SAVEPOINT sqlite_ecto_savepoint" end handle_transaction(sql, [timeout: Keyword.get(opts, :timeout, 5000)], s) end defp refined_info(prepared_info) do types = prepared_info.types |> Enum.map(&maybe_atom_to_lc_string/1) |> Enum.to_list prepared_info |> Map.delete(:columns) |> Map.put(:column_names, atoms_to_strings(prepared_info.columns)) |> Map.put(:types, types) end defp atoms_to_strings(nil), do: nil defp atoms_to_strings(list), do: Enum.map(list, &maybe_atom_to_string/1) defp maybe_atom_to_string(nil), do: nil defp maybe_atom_to_string(item), do: to_string(item) defp maybe_atom_to_lc_string(nil), do: nil defp maybe_atom_to_lc_string(item), do: item |> to_string |> String.downcase defp handle_execute(%Query{statement: sql}, params, _sync, opts, s) do # Note that we rely on Sqlitex.Server to cache the prepared statement, # so we can simply refer to the original SQL statement here. case run_stmt(sql, params, opts, s) do {:ok, result} -> {:ok, result, s} other -> other end end defp query_error(s, msg) do {:error, ArgumentError.exception(msg), s} end defp sqlite_error({:error, {sqlite_errcode, message}}, s) do {:error, %Sqlite.DbConnection.Error{sqlite: %{code: sqlite_errcode}, message: to_string(message)}, s} end defp run_stmt(query, params, opts, s) do query_opts = [ timeout: Keyword.get(opts, :timeout, 5000), decode: :manual, types: true, bind: params ] command = command_from_sql(query) case query_rows(s.db, to_string(query), query_opts) do {:ok, %{rows: raw_rows, columns: raw_column_names}} -> {rows, num_rows, column_names} = case {raw_rows, raw_column_names} do {_, []} -> {nil, get_changes_count(s.db, command), nil} _ -> {raw_rows, length(raw_rows), raw_column_names} end {:ok, %Sqlite.DbConnection.Result{rows: rows, num_rows: num_rows, columns: atoms_to_strings(column_names), command: command}} {:error, :wrong_type} -> {:error, %ArgumentError{message: "Wrong type"}, s} {:error, {_sqlite_errcode, _message}} = err -> sqlite_error(err, s) {:error, %Sqlite.DbConnection.Error{} = err} -> {:error, err, s} {:error, :args_wrong_length} -> {:error, %ArgumentError{message: "parameters must match number of placeholders in query"}, s} end end defp get_changes_count(db, command) when command in [:insert, :update, :delete] do {:ok, %{rows: [[changes_count]]}} = Sqlitex.Server.query_rows(db, "SELECT changes()") changes_count end defp get_changes_count(_db, _command), do: 1 defp command_from_sql(sql) do sql |> :erlang.iolist_to_binary |> String.downcase |> String.split(" ", parts: 3) |> command_from_words end defp command_from_words([verb, subject, _]) when verb == "alter" or verb == "create" or verb == "drop" do String.to_atom("#{verb}_#{subject}") end defp command_from_words(words) when is_list(words) do String.to_atom(List.first(words)) end defp handle_transaction(stmt, opts, s) do {:ok, _rows} = query_rows(s.db, stmt, Keyword.merge(opts, [into: :raw_list])) command = command_from_sql(stmt) result = %Sqlite.DbConnection.Result{rows: nil, num_rows: nil, columns: nil, command: command} {:ok, result, s} end defp query_rows(db, stmt, opts) do try do Sqlitex.Server.query_rows(db, stmt, opts) catch :exit, {:timeout, _gen_server_call} -> {:error, %Sqlite.DbConnection.Error{message: "Timeout"}} :exit, ex -> {:error, %Sqlite.DbConnection.Error{message: inspect(ex)}} end end end
34.079295
90
0.634566
737ccdd09ecd701e2992d8a57ac0a7a14db9d3c4
6,937
ex
Elixir
lib/100/p10.ex
penqen/yukicoder-elixir
4f3e9e4694a14434cc3700280e9205226434733b
[ "MIT" ]
null
null
null
lib/100/p10.ex
penqen/yukicoder-elixir
4f3e9e4694a14434cc3700280e9205226434733b
[ "MIT" ]
null
null
null
lib/100/p10.ex
penqen/yukicoder-elixir
4f3e9e4694a14434cc3700280e9205226434733b
[ "MIT" ]
null
null
null
defmodule P10 do @moduledoc """ - 入力: N, Total, A[n] - 複数回答の場合 {+,*} の順の辞書列順の最初 - (((((A[0]) ? A[1]) ? A[2]) ? A[3]) ... A[n - 1]) = Total 以下の関係式を考える。 このとき、`?`オペランドは、`{/,-}`である。 ``` R(n) = Total R(n - 1) = R(n) ? A[n - 1] R(n - 2) = R(n - 1) ? A[n - 2] ... R(i) = R(i - 1) ? A[i] ... R(1) = R(2) ? A[1] = A[0] ``` このとき、`?`オペランドが`/`のとき、 ``` R(i - 1) mod A[i] = 0 ``` を満たす必要があるため、事前に枝刈りが可能である。 また、`A[0] 〜 A[i]` までの取り得る最大値を利用し、`R(i)`の上界を得ることができる。 上記の計算を実現する方法ために、`key`が`R(i)`、`value`が`R(i)を満たすオペランド列の配列`となる`Map`を使う。 オペランドの表現方法は、ビット列を使い、`R(i)`のオペランドのビットは`n - i`番目となるようにする。 `+,*`をそれぞれ`1,0`とすると、A[0]と同値となるオペランド列の中から最大値となるビット列が求めるオペランド列となる。 例えば、`010`は、`*+*`となる。 また、同値となる`R(i)`のオペランドが`*`のときだけ、候補となるビット列の全てを候補に入れる必要はなく、辞書順である最大値のビット列だけを考慮に入れればいい。 ``` n = 4 total = 31 an = [1, 2, 10, 1] upperbound = %{0 => 31, 1 => 21, 2 => 11, 3 => 1} R(n) = %{ total => 0 } = %{ 31 => 1 } %{30 => [1], 31 => [0]} %{3 => [1], 20 => [3], 21 => [2]} %{1 => [5], 10 => [3]} R(n) => %{ total => 0 } R(n) ``` # Examples iex> P10.solve(4, 31, [1, 2, 10, 1]) "+*+" -iex> P10.solve(3, 6, [2, 3, 1]) -"++" -iex> P10.solve(3, 2, [1, 1, 2]) -"**" -iex> P10.solve(6, 672, [1, 1, 3, 8, 3, 7]) -"*+***" -iex> P10.solve(21, 83702, [5, 9, 3, 7, 2, 7, 1, 4, 8, 7, 5, 2, 9, 2, 6, 8, 7, 9, 5, 2, 5]) -"+*+*+++++++**++*+*++" -iex> P10.solve(26, 36477, [9, 4, 2, 7, 1, 6, 1, 6, 9, 2, 10, 4, 10, 10, 10, 5, 7, 4, 5, 1, 7, 9, 4, 7, 1, 9]) -"++++*+++++++*+++**+++++*+" -iex> n = 50 -...> total = 100000 -...> an = [4, 6, 1, 8, 10, 2, 6, 4, 8, 9, 10, 8, 2, 1, 9, 5, 9, 1, 4, 1, 1, 6, 1, 9, 10, 9, 2, 7, 3, 8, 1, 4, 2, 7, 6, 10, 8, 7, 5, 5, 4, 2, 10, 8, 4, 8, 9, 5, 5, 9] -...> P10.solve(n, total, an) -"++++++++++++++++++**+*+*+*++++++++*++++*+++++++++" -iex> n = 50 -...> total = 65536 -...> an = [2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2] -...> P10.solve(n, total, an) -"+++**++++++++++++++++++++++++++++++++************" """ use Bitwise, only_operators: true def main do n = IO.read(:line) |> String.trim() |> String.to_integer() total = IO.read(:line) |> String.trim() |> String.to_integer() an = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1) solve(n, total, an) |> IO.puts() end def solve(n, total, an) do {_, ub} = Enum.reduce(0..(n - 1), {an, %{}}, fn i, {[a | an], ub} -> {an, Map.put(ub, i, Enum.reduce(an, a, &(:erlang.max(&1 * &2, &1 + &2))))} end) |> IO.inspect [a | an] = an an |> Enum.reverse() |> Enum.with_index() |> Enum.reduce(Map.put(%{}, total, [0]), fn {_a, i} = step, dp -> #Enum.reduce(dp, %{}, &(&2 |> times(&1, step, ub[i]) |> plus(&1, step, ub[i]))) Enum.reduce(dp, %{}, fn {_rest, _wi} = before_step, ndp -> ndp |> times(before_step, step, ub[i]) |> plus(before_step, step, ub[i]) end) |> IO.inspect end) |> Map.get(a) |> Enum.max() |> restore(n) |> Enum.reverse() |> Enum.join("") end def times(dp, {rest, wi}, {a, _i}, ub) do if :math.fmod(rest, a) == 0, do: update(dp, div(rest, a), [Enum.max(wi)], ub), else: dp end def plus(dp, {rest, wi}, {a, i}, ub) when a <= rest, do: update(dp, rest - a, Enum.map(wi, fn w -> w + (1 <<< i) end), ub) def plus(dp, {_rest, _wi}, {_a, _i}, _ub), do: dp def update(dp, key, wi, ub) when key <= ub, do: Map.update(dp, key, wi, fn q -> wi ++ q end) def update(dp, _key, _wi, _ub), do: dp @doc """ 辞書順に重み付けする方法: i を深さとし、重みw_iは、以下のように設定する。 :+ => w_i = 1 + w_i << 2 :* => w_i = 0 + w_i << 2 """ def solve_bfs(n, total, an) do [a | an] = an an |> Enum.reduce(Map.put(%{}, a, 0), fn a, dp -> Enum.reduce(dp, %{}, fn {acc, wi}, ndp -> ndp |> put(acc + a, (wi <<< 1) + 1, total) |> put(acc * a, (wi <<< 1), total) end) end) |> (fn dp -> dp[total] |> restore(n) |> Enum.reverse() |> Enum.join("") end).() end def restore(_w, 1), do: [] def restore(w, i) do [(if (w &&& 1) == 1, do: :+, else: :*) | restore(w >>> 1 ,i - 1)] end def put(dp, key, value, total) when key <= total do if is_nil(dp[key]) || dp[key] < value,do: Map.put(dp, key, value), else: dp end def put(dp, _key, _value, _total), do: dp end # 早いやつ #defmodule Main do # use Bitwise, only_operators: true # def main do # n = IO.read(:line) |> String.trim() |> String.to_integer() # total = IO.read(:line) |> String.trim() |> String.to_integer() # an = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1) # {_, ub} = Enum.reduce(0..(n - 1), {an, %{}}, fn i, {[a | an], ub} -> # {an, Map.put(ub, i, Enum.reduce(an, a, &(:erlang.max(&1 * &2, &1 + &2))))} # end) # [a | an] = an # an # |> Enum.reverse() |> Enum.with_index() # |> Enum.reduce(Map.put(%{}, total, [0]), fn {_a, i} = step, dp -> # Enum.reduce(dp, %{}, &(&2 |> times(&1, step, ub[i]) |> plus(&1, step, ub[i]))) # end) # |> Map.get(a) |> Enum.max() |> restore(n) |> Enum.reverse() |> Enum.join("") |> IO.puts() # end # def times(dp, {rest, wi}, {a, _i}, ub), # do: if :math.fmod(rest, a) == 0, do: update(dp, div(rest, a), [Enum.max(wi)], ub), else: dp # def plus(dp, {rest, wi}, {a, i}, ub) when a <= rest, # do: update(dp, rest - a, Enum.map(wi, fn w -> w + (1 <<< i) end), ub) # def plus(dp, {_rest, _wi}, {_a, _i}, _ub), do: dp # def update(dp, key, wi, ub) when key <= ub, do: Map.update(dp, key, wi, fn q -> wi ++ q end) # def update(dp, _key, _wi, _ub), do: dp # def restore(_w, 1), do: [] # def restore(w, i), do: [(if (w &&& 1) == 1, do: :+, else: :*) | restore(w >>> 1 ,i - 1)] #end # 遅いやつ #defmodule Main do # use Bitwise # def main do # n = IO.read(:line) |> String.trim() |> String.to_integer() # total = IO.read(:line) |> String.trim() |> String.to_integer() # an = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1) # solve(n, total, an) |> IO.puts() # end # # def solve(n, total, an) do # [a | an] = an # an # |> Enum.reduce(Map.put(%{}, a, 0), fn a, dp -> # Enum.reduce(dp, %{}, fn {acc, wi}, ndp -> # ndp |> put(acc + a, (wi <<< 1) + 1, total) |> put(acc * a, (wi <<< 1), total) # end) # end) # |> (fn dp -> # dp[total] |> restore(n) |> Enum.reverse() |> Enum.join("") # end).() # end # # def restore(_w, 1), do: [] # def restore(w, i), do: [(if (w &&& 1) == 1, do: :+, else: :*) | restore(w >>> 1 ,i - 1)] # # def put(dp, key, value, total) when key <= total, # do: if is_nil(dp[key]) || dp[key] < value, do: Map.put(dp, key, value), else: dp # def put(dp, _key, _value, _total), do: dp #end
31.107623
170
0.466628
737ce03bf989f549f250f2f7fa362117f11ffe74
992
ex
Elixir
web/views/error_helpers.ex
nsarno/sailship
1b94440d722e9a95981360ae6eae62ad8e230714
[ "MIT" ]
null
null
null
web/views/error_helpers.ex
nsarno/sailship
1b94440d722e9a95981360ae6eae62ad8e230714
[ "MIT" ]
null
null
null
web/views/error_helpers.ex
nsarno/sailship
1b94440d722e9a95981360ae6eae62ad8e230714
[ "MIT" ]
null
null
null
defmodule Sailship.ErrorHelpers do @moduledoc """ Conveniences for translating and building error messages. """ @doc """ Translates an error message using gettext. """ def translate_error({msg, opts}) do # Because error messages were defined within Ecto, we must # call the Gettext module passing our Gettext backend. We # also use the "errors" domain as translations are placed # in the errors.po file. # Ecto will pass the :count keyword if the error message is # meant to be pluralized. # On your own code and templates, depending on whether you # need the message to be pluralized or not, this could be # written simply as: # # dngettext "errors", "1 file", "%{count} files", count # dgettext "errors", "is invalid" # if count = opts[:count] do Gettext.dngettext(Sailship.Gettext, "errors", msg, msg, count, opts) else Gettext.dgettext(Sailship.Gettext, "errors", msg, opts) end end end
33.066667
74
0.670363
737cf14aa3f2a0a5ec1c7dbf2f5752a0a685306e
1,169
exs
Elixir
config/config.exs
croqaz/FsWatch
35ec83491d54eb08b278b0925b9490116d5fc46f
[ "MIT" ]
null
null
null
config/config.exs
croqaz/FsWatch
35ec83491d54eb08b278b0925b9490116d5fc46f
[ "MIT" ]
null
null
null
config/config.exs
croqaz/FsWatch
35ec83491d54eb08b278b0925b9490116d5fc46f
[ "MIT" ]
null
null
null
# This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. use Mix.Config config :porcelain, driver: Porcelain.Driver.Basic # This configuration is loaded before any dependency and is restricted # to this project. If another project depends on this project, this # file won't be loaded nor affect the parent project. For this reason, # if you want to provide default values for your application for # 3rd-party users, it should be done in your "mix.exs" file. # You can configure for your application as: # # config :fswatch, key: :value # # And access this configuration in your application as: # # Application.get_env(:fswatch, :key) # # Or configure a 3rd-party app: # # config :logger, level: :info # # It is also possible to import configuration files, relative to this # directory. For example, you can emulate configuration per environment # by uncommenting the line below and defining dev.exs, test.exs and such. # Configuration from the imported file will override the ones defined # here (which is why it is important to import them last). # # import_config "#{Mix.env}.exs"
34.382353
73
0.75278
737d210af678d21692eed6286de580c362f98228
12,411
exs
Elixir
test/spf_dns_test.exs
hertogp/SpfCheck
bee61300f9be1850e274b75aca31228b70c93e34
[ "MIT" ]
2
2021-11-20T23:32:58.000Z
2022-01-15T14:07:20.000Z
test/spf_dns_test.exs
hertogp/spfcheck
bee61300f9be1850e274b75aca31228b70c93e34
[ "MIT" ]
null
null
null
test/spf_dns_test.exs
hertogp/spfcheck
bee61300f9be1850e274b75aca31228b70c93e34
[ "MIT" ]
null
null
null
defmodule SpfDNSTest do use ExUnit.Case doctest Spf.DNS, import: true describe "DNS cache" do test "00 - caches zonedata from heredoc" do zonedata = """ example.com A 1.2.3.4 example.com AAAA 2001::1 example.com MX 10 mail.example.com example.com TXT v=spf1 -all example.com SPF v=spf1 +all example.com ns ns.example.com 4.3.2.1.in-addr.arpa ptr example.com example.com SOA ns.icann.org. noc.dns.icann.org. 2021120710 7200 3600 1209600 3600 example.net CNAME example.org example.org A 1.1.1.1 """ ctx = Spf.Context.new("example.com", dns: zonedata) {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :a) assert result == {:ok, ["1.2.3.4"]} # ipv6 formatting is produced by Pfx {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :aaaa) assert result == {:ok, ["2001:0:0:0:0:0:0:1"]} {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :mx) assert result == {:ok, [{10, "mail.example.com"}]} {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :txt) assert result == {:ok, ["v=spf1 -all"]} {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :spf) assert result == {:ok, ["v=spf1 +all"]} {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :ns) assert result == {:ok, ["ns.example.com"]} {_ctx, result} = Spf.DNS.resolve(ctx, "4.3.2.1.in-addr.arpa", type: :ptr) assert result == {:ok, ["example.com"]} {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :soa) # note: names are normalized when entered into the cache so trailing dot # is dropped assert result == {:ok, [ { "ns.icann.org", "noc.dns.icann.org", 2_021_120_710, 7200, 3600, 1_209_600, 3600 } ]} {_ctx, result} = Spf.DNS.resolve(ctx, "example.net", type: :cname) assert result == {:ok, ["example.org"]} # cname really works .. {_ctx, result} = Spf.DNS.resolve(ctx, "example.net", type: :a) assert result == {:ok, ["1.1.1.1"]} end test "01 - DNS cache from a list of lines" do zonedata = """ example.com A 1.2.3.4 example.com AAAA 2001::1 example.com MX 10 mail.example.com example.com TXT v=spf1 -all example.com SPF v=spf1 +all example.com ns ns.example.com 4.3.2.1.in-addr.arpa ptr example.com example.com SOA ns.icann.org. noc.dns.icann.org. 2021120710 7200 3600 1209600 3600 example.net CNAME example.org example.org A 1.1.1.1 """ |> String.split("\n") ctx = Spf.Context.new("example.com", dns: zonedata) {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :a) assert result == {:ok, ["1.2.3.4"]} # resolve() defaults type to :a {_ctx, result} = Spf.DNS.resolve(ctx, "example.com") assert result == {:ok, ["1.2.3.4"]} # ipv6 formatting is produced by Pfx {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :aaaa) assert result == {:ok, ["2001:0:0:0:0:0:0:1"]} {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :mx) assert result == {:ok, [{10, "mail.example.com"}]} {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :txt) assert result == {:ok, ["v=spf1 -all"]} {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :spf) assert result == {:ok, ["v=spf1 +all"]} {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :ns) assert result == {:ok, ["ns.example.com"]} {_ctx, result} = Spf.DNS.resolve(ctx, "4.3.2.1.in-addr.arpa", type: :ptr) assert result == {:ok, ["example.com"]} {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :soa) # note: names are normalized when entered into the cache so trailing dot # is dropped assert result == {:ok, [ { "ns.icann.org", "noc.dns.icann.org", 2_021_120_710, 7200, 3600, 1_209_600, 3600 } ]} {_ctx, result} = Spf.DNS.resolve(ctx, "example.net", type: :cname) assert result == {:ok, ["example.org"]} # cname really works .. {_ctx, result} = Spf.DNS.resolve(ctx, "example.net", type: :a) assert result == {:ok, ["1.1.1.1"]} end test "02 - dns cache from non-existing file" do # feed Spf.DNS.load the current working dir -> File.read will yield an # {:error, :eisdir} ctx = Spf.Context.new("some.tld") |> Spf.DNS.load(".") Enum.any?(ctx.msg, fn msg -> elem(msg, 3) |> String.contains?(":eisdir") end) end test "03 - dns cache rr-errors overwrite always" do zonedata = """ example.com A 1.2.3.4 example.com AAAA acdc:1976::1 example.com AAAA Timeout example.com mx ServFail example.com mx 10 mail.example.com """ ctx = Spf.Context.new("example.com", dns: zonedata) # the A record stays untouched {_ctx, {:ok, ["1.2.3.4"]}} = Spf.DNS.resolve(ctx, "example.com", type: :a) # the AAAA record has the error {_ctx, {:error, :timeout}} = Spf.DNS.resolve(ctx, "example.com", type: :aaaa) # unspecified (known) RR-types are set to SERVFAIL {_ctx, {:error, :servfail}} = Spf.DNS.resolve(ctx, "example.com", type: :mx) end test "04 - circular cname's yield :servfail" do zonedata = """ example.com cname example.org example.com a 1.1.1.1 example.org cname example.net example.org a 2.2.2.2 example.net cname example.com example.net a 3.3.3.3 """ ctx = Spf.Context.new("some.tld", dns: zonedata) # straight cname resolving works {ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :cname) assert result == {:ok, ["example.org"]} {ctx, result} = Spf.DNS.resolve(ctx, "example.org", type: :cname) assert result == {:ok, ["example.net"]} {_ctx, result} = Spf.DNS.resolve(ctx, "example.net", type: :cname) assert result == {:ok, ["example.com"]} # circular CNAMEs yield :servfail (is a zonedata error) # rfc1035 - servfail: name server was unable to process the query due to # a (database) problem with the name server. {ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :a) assert result == {:error, :servfail} {ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :mx) assert result == {:error, :servfail} {ctx, result} = Spf.DNS.resolve(ctx, "example.org", type: :a) assert result == {:error, :servfail} {ctx, result} = Spf.DNS.resolve(ctx, "example.org", type: :mx) assert result == {:error, :servfail} {_ctx, result} = Spf.DNS.resolve(ctx, "example.net", type: :a) assert result == {:error, :servfail} {_ctx, result} = Spf.DNS.resolve(ctx, "example.net", type: :mx) assert result == {:error, :servfail} end test "05 - updating cache w/ timeout error overwrites" do zonedata = """ example.com TXT some text record """ ctx = Spf.Context.new("some.tld", dns: zonedata) ctx = Spf.DNS.load(ctx, "example.com TXT TIMEOUT") {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :txt) assert {:error, :timeout} == result end test "06 - updating cache w/ servfail error overwrites" do zonedata = """ example.com TXT some text record """ ctx = Spf.Context.new("some.tld", dns: zonedata) ctx = Spf.DNS.load(ctx, "example.com TXT SERVFAIL") {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :txt) assert {:error, :servfail} == result end test "07 - unsupported RR type" do zonedata = """ example.com XYZ an unknown RR type """ ctx = Spf.Context.new("some.tld", dns: zonedata) assert Enum.any?(ctx.msg, fn entry -> elem(entry, 3) |> String.contains?("malformed RR") end) end test "08 - cname's with errors" do zonedata = """ example.com cname example.org example.org cname timeout """ ctx = Spf.Context.new("some.tld", dns: zonedata) {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :a) assert {:error, :timeout} == result end test "09 - trying to resolve an unknown rr-type" do zonedata = """ example.com a 1.2.3.4 """ ctx = Spf.Context.new("some.tld", dns: zonedata) {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :xyz) assert {:error, :unknown_rr_type} == result end test "10 - trying to resolve an illegal name" do zonedata = """ example.com a 1.2.3.4 """ ctx = Spf.Context.new("some.tld", dns: zonedata) {_ctx, result} = Spf.DNS.resolve(ctx, "example..com", type: :xyz) assert {:error, :illegal_name} == result end test "11 - trying to resolve an not-implemented" do # test error response similar to servfail, in this case: # {:error, {:notimp, dns_msg}} ctx = Spf.Context.new("some.tld") {_ctx, result} = Spf.DNS.resolve(ctx, "example.com", type: :mf) assert {:error, :notimp} == result end test "12 - a zonedata's soa record should be correct" do zonedata = """ example.com. soa ns.example.com noc.example.com 1 2 3 4 five example.org soa ns.example.123 noc.example.com 1 2 3 4 5 """ ctx = Spf.Context.new("some.tld", dns: zonedata) assert Enum.any?(ctx.msg, fn msg -> elem(msg, 3) |> String.contains?("illegal ttl") end) end end describe "dns cache to lines" do test "01 - mx records" do zonedata = """ example.com. mx 10 mail.example.com """ # note: # - trailing dot should be removed # - mx becomes MX lines = Spf.Context.new("some.tld", dns: zonedata) |> Spf.DNS.to_list() assert ["example.com MX 10 mail.example.com"] == lines end test "02 - spf records" do # although not used for evaluation, they are supported in Spf.DNS cache zonedata = """ example.com. spf v=spf1 -all """ # note: # - trailing dot should be removed # - spf becomes SPF lines = Spf.Context.new("some.tld", dns: zonedata) |> Spf.DNS.to_list() assert ["example.com SPF v=spf1 -all"] == lines end test "03 - when someone messed up the context.dns cache manually" do # note: # - trailing dot should be removed # - a becomes A lines = Spf.Context.new("some.tld") |> Map.put(:dns, %{{"example.com", :a} => ["1.1.1.400"]}) |> Spf.DNS.to_list() assert ["example.com A 1.1.1.400"] == lines end test "04 - when someone messed up the zonedata" do zonedata = """ example.com a 1.1.1.400 """ ctx = Spf.Context.new("some.tld", dns: zonedata) assert Enum.any?(ctx.msg, fn entry -> elem(entry, 3) |> String.contains?("RR ignored") end) assert Enum.any?(ctx.msg, fn entry -> elem(entry, 3) |> String.contains?("illegal address") end) end test "05 - when someone messed up the zonedata" do zonedata = """ example.com aaaa acdc:1976:defg """ ctx = Spf.Context.new("some.tld", dns: zonedata) assert Enum.any?(ctx.msg, fn entry -> elem(entry, 3) |> String.contains?("RR ignored") end) assert Enum.any?(ctx.msg, fn entry -> elem(entry, 3) |> String.contains?("illegal address") end) end test "06 - when someone messed up the zonedata" do zonedata = """ example.com aaaa 11-22-33-44-55-66 """ ctx = Spf.Context.new("some.tld", dns: zonedata) assert Enum.any?(ctx.msg, fn entry -> elem(entry, 3) |> String.contains?("RR ignored") end) assert Enum.any?(ctx.msg, fn entry -> elem(entry, 3) |> String.contains?("illegal address") end) end end end
32.4047
99
0.560148
737d549c19c836424a1bca34b98d063e27c796a6
61
ex
Elixir
lib/fighter_web/views/user_view.ex
gautambaghel/fighter
970a098f0d234892af351070b6b2b596b9a2d83c
[ "Apache-2.0" ]
null
null
null
lib/fighter_web/views/user_view.ex
gautambaghel/fighter
970a098f0d234892af351070b6b2b596b9a2d83c
[ "Apache-2.0" ]
null
null
null
lib/fighter_web/views/user_view.ex
gautambaghel/fighter
970a098f0d234892af351070b6b2b596b9a2d83c
[ "Apache-2.0" ]
null
null
null
defmodule FighterWeb.UserView do use FighterWeb, :view end
15.25
32
0.803279
737d57fc1cec8600bed4a3146c561fc93e3a1861
167
exs
Elixir
apps/omg/config/dev.exs
PinkDiamond1/elixir-omg
70dfd24a0a1ddf5d1d9d71aab61ea25300f889f7
[ "Apache-2.0" ]
1
2020-05-01T12:30:09.000Z
2020-05-01T12:30:09.000Z
apps/omg/config/dev.exs
PinkDiamond1/elixir-omg
70dfd24a0a1ddf5d1d9d71aab61ea25300f889f7
[ "Apache-2.0" ]
null
null
null
apps/omg/config/dev.exs
PinkDiamond1/elixir-omg
70dfd24a0a1ddf5d1d9d71aab61ea25300f889f7
[ "Apache-2.0" ]
1
2021-12-04T00:37:46.000Z
2021-12-04T00:37:46.000Z
# dev config necessary to load project in iex use Mix.Config config :omg, ethereum_events_check_interval_ms: 500, coordinator_eth_height_check_interval_ms: 1_000
23.857143
49
0.826347
737d7c459256aed3f0b71e00fb56063cac3f1d94
5,128
ex
Elixir
lib/step_flow/amqp/common_consumer.ex
mathiaHT/ex_step_flow
6496e9511239de64f00119428476338dfcde9dea
[ "MIT" ]
4
2019-12-07T05:18:26.000Z
2020-11-06T23:28:43.000Z
lib/step_flow/amqp/common_consumer.ex
mathiaHT/ex_step_flow
6496e9511239de64f00119428476338dfcde9dea
[ "MIT" ]
53
2020-01-06T11:23:09.000Z
2021-06-25T15:30:07.000Z
lib/step_flow/amqp/common_consumer.ex
mathiaHT/ex_step_flow
6496e9511239de64f00119428476338dfcde9dea
[ "MIT" ]
3
2020-01-30T15:37:40.000Z
2020-10-27T14:10:02.000Z
defmodule StepFlow.Amqp.CommonConsumer do @moduledoc """ Definition of a Common Consumer of RabbitMQ queue. To implement a consumer, ```elixir defmodule MyModule do use StepFlow.Amqp.CommonConsumer, %{ queue: "name_of_the_rabbit_mq_queue", consumer: &MyModule.consume/4 } def consume(channel, tag, redelivered, payload) do ... Basic.ack(channel, tag) end end ``` """ @doc false defmacro __using__(opts) do quote do use GenServer use AMQP alias StepFlow.Amqp.CommonEmitter alias StepFlow.Amqp.Helpers @doc false def start_link do GenServer.start_link(__MODULE__, :ok, name: __MODULE__) end @doc false def init(:ok) do rabbitmq_connect() end # Confirmation sent by the broker after registering this process as a consumer def handle_info({:basic_consume_ok, %{consumer_tag: _consumer_tag}}, channel) do {:noreply, channel} end # Sent by the broker when the consumer is unexpectedly cancelled (such as after a queue deletion) def handle_info({:basic_cancel, %{consumer_tag: _consumer_tag}}, channel) do {:stop, :normal, channel} end # Confirmation sent by the broker to the consumer process after a Basic.cancel def handle_info({:basic_cancel_ok, %{consumer_tag: _consumer_tag}}, channel) do {:noreply, channel} end def handle_info( {:basic_deliver, payload, %{delivery_tag: tag, redelivered: redelivered} = headers}, channel ) do queue = unquote(opts).queue data = payload |> Jason.decode!() Logger.warn("#{__MODULE__}: receive message on queue: #{queue}") max_retry_to_timeout = StepFlow.Configuration.get_var_value(StepFlow.Amqp, :max_retry_to_timeout, 10) Logger.error("#{__MODULE__} #{inspect(headers)}") max_retry_reached = with headers when headers != :undefined <- Map.get(headers, :headers), {"x-death", :array, death} <- List.keyfind(headers, "x-death", 0), {:table, table} <- List.first(death), {"count", :long, count} <- List.keyfind(table, "count", 0) do count > max_retry_to_timeout else _ -> false end if max_retry_reached do Logger.warn("#{__MODULE__}: timeout message sent to queue: #{queue}_timeout") CommonEmitter.publish(queue <> "_timeout", payload) AMQP.Basic.ack(channel, tag) else unquote(opts).consumer.(channel, tag, redelivered, data) end {:noreply, channel} end def handle_info({:DOWN, _, :process, _pid, _reason}, _) do {:ok, chan} = rabbitmq_connect() # {:noreply, :ok} end def terminate(_reason, state) do AMQP.Connection.close(state.conn) end defp rabbitmq_connect do url = Helpers.get_amqp_connection_url() case AMQP.Connection.open(url) do {:ok, connection} -> init_amqp_connection(connection) {:error, message} -> Logger.error( "#{__MODULE__}: unable to connect to: #{url}, reason: #{inspect(message)}" ) # Reconnection loop :timer.sleep(10_000) rabbitmq_connect() end end defp init_amqp_connection(connection) do Process.monitor(connection.pid) {:ok, channel} = AMQP.Channel.open(connection) queue = unquote(opts).queue if Map.has_key?(unquote(opts), :prefetch_count) do :ok = AMQP.Basic.qos(channel, prefetch_count: unquote(opts).prefetch_count) end AMQP.Queue.declare(channel, "job_response_not_found", durable: true) AMQP.Queue.declare(channel, queue <> "_timeout", durable: true) exchange = AMQP.Exchange.topic(channel, "job_response", durable: true, arguments: [{"alternate-exchange", :longstr, "job_response_not_found"}] ) exchange = AMQP.Exchange.fanout(channel, "job_response_delayed", durable: true) {:ok, job_response_delayed_queue} = AMQP.Queue.declare(channel, "job_response_delayed", arguments: [ {"x-message-ttl", :short, 5000}, {"x-dead-letter-exchange", :longstr, ""} ] ) AMQP.Queue.bind(channel, "job_response_delayed", "job_response_delayed", routing_key: "*") AMQP.Queue.declare(channel, queue, durable: true, arguments: [ {"x-dead-letter-exchange", :longstr, "job_response_delayed"}, {"x-dead-letter-routing-key", :longstr, queue} ] ) Logger.warn("#{__MODULE__}: bind #{queue}") AMQP.Queue.bind(channel, queue, "job_response", routing_key: queue) Logger.warn("#{__MODULE__}: connected to queue #{queue}") {:ok, _consumer_tag} = AMQP.Basic.consume(channel, queue) {:ok, channel} end end end end
29.813953
103
0.596139
737d88c2feae6b2eda98148195dbe139cff67f26
5,685
exs
Elixir
test/plug/adapters/cowboy2_test.exs
qcam/plug
c547f2bd7a64aec7c4759dcc1ed88b6eab0c7499
[ "Apache-2.0" ]
null
null
null
test/plug/adapters/cowboy2_test.exs
qcam/plug
c547f2bd7a64aec7c4759dcc1ed88b6eab0c7499
[ "Apache-2.0" ]
null
null
null
test/plug/adapters/cowboy2_test.exs
qcam/plug
c547f2bd7a64aec7c4759dcc1ed88b6eab0c7499
[ "Apache-2.0" ]
null
null
null
defmodule Plug.Adapters.Cowboy2Test do use ExUnit.Case, async: true import Plug.Adapters.Cowboy2 @moduletag :cowboy2 def init([]) do [foo: :bar] end handler = {:_, [], Plug.Adapters.Cowboy2.Handler, {Plug.Adapters.Cowboy2Test, [foo: :bar]}} @dispatch [{:_, [], [handler]}] if function_exported?(Supervisor, :child_spec, 2) do test "supports Elixir v1.5 child specs" do spec = {Plug.Adapters.Cowboy2, [scheme: :http, plug: __MODULE__, options: [port: 4040]]} assert %{ id: {:ranch_listener_sup, Plug.Adapters.Cowboy2Test.HTTP}, modules: [:ranch_listener_sup], restart: :permanent, shutdown: :infinity, start: {:ranch_listener_sup, :start_link, _}, type: :supervisor } = Supervisor.child_spec(spec, []) end test "the h2 alpn settings are added when using https" do options = [ port: 4040, password: "cowboy", keyfile: Path.expand("../../fixtures/ssl/key.pem", __DIR__), certfile: Path.expand("../../fixtures/ssl/cert.pem", __DIR__) ] spec = {Plug.Adapters.Cowboy2, [scheme: :https, plug: __MODULE__, options: options]} %{start: {:ranch_listener_sup, :start_link, opts}} = Supervisor.child_spec(spec, []) assert [ Plug.Adapters.Cowboy2Test.HTTPS, 100, :ranch_ssl, transport_opts, :cowboy_tls, _proto_opts ] = opts assert Keyword.get(transport_opts, :alpn_preferred_protocols) == ["h2", "http/1.1"] assert Keyword.get(transport_opts, :next_protocols_advertised) == ["h2", "http/1.1"] end end test "builds args for cowboy dispatch" do assert [ Plug.Adapters.Cowboy2Test.HTTP, [num_acceptors: 100, port: 4000, max_connections: 16_384], %{env: %{dispatch: @dispatch}} ] = args(:http, __MODULE__, [], []) end test "builds args with custom options" do assert [ Plug.Adapters.Cowboy2Test.HTTP, [num_acceptors: 100, max_connections: 16_384, port: 3000, other: true], %{env: %{dispatch: @dispatch}} ] = args(:http, __MODULE__, [], port: 3000, other: true) end test "builds args with non 2-element tuple options" do assert [ Plug.Adapters.Cowboy2Test.HTTP, [ :inet6, {:raw, 1, 2, 3}, num_acceptors: 100, max_connections: 16_384, port: 3000, other: true ], %{env: %{dispatch: @dispatch}} ] = args(:http, __MODULE__, [], [:inet6, {:raw, 1, 2, 3}, port: 3000, other: true]) end test "builds args with protocol option" do assert [ Plug.Adapters.Cowboy2Test.HTTP, [num_acceptors: 100, max_connections: 16_384, port: 3000], %{env: %{dispatch: @dispatch}, compress: true, timeout: 30_000} ] = args(:http, __MODULE__, [], port: 3000, compress: true, timeout: 30_000) assert [ Plug.Adapters.Cowboy2Test.HTTP, [num_acceptors: 100, max_connections: 16_384, port: 3000], %{env: %{dispatch: @dispatch}, timeout: 30_000} ] = args(:http, __MODULE__, [], port: 3000, protocol_options: [timeout: 30_000]) end test "builds args with num_acceptors option" do assert [ Plug.Adapters.Cowboy2Test.HTTP, [max_connections: 16_384, port: 3000, num_acceptors: 5], %{env: %{dispatch: @dispatch}} ] = args(:http, __MODULE__, [], port: 3000, compress: true, num_acceptors: 5) end test "builds args with compress option" do assert [ Plug.Adapters.Cowboy2Test.HTTP, [num_acceptors: 100, max_connections: 16_384, port: 3000], %{ env: %{dispatch: @dispatch}, stream_handlers: [:cowboy_compress_h, Plug.Adapters.Cowboy2.Stream] } ] = args(:http, __MODULE__, [], port: 3000, compress: true) end test "builds args with compress option fails if stream_handlers are set" do assert_raise(RuntimeError, ~r/set both compress and stream_handlers/, fn -> args(:http, __MODULE__, [], port: 3000, compress: true, stream_handlers: [:cowboy_stream_h]) end) end test "builds args with single-atom protocol option" do assert [ Plug.Adapters.Cowboy2Test.HTTP, [:inet6, num_acceptors: 100, max_connections: 16_384, port: 3000], %{env: %{dispatch: @dispatch}} ] = args(:http, __MODULE__, [], [:inet6, port: 3000]) end test "builds child specs" do assert %{ id: {:ranch_listener_sup, Plug.Adapters.Cowboy2Test.HTTP}, modules: [:ranch_listener_sup], start: {:ranch_listener_sup, :start_link, _}, restart: :permanent, shutdown: :infinity, type: :supervisor } = child_spec(scheme: :http, plug: __MODULE__, options: []) end defmodule MyPlug do def init(opts), do: opts end test "errors when trying to run on https" do assert_raise ArgumentError, ~r/missing option :key\/:keyfile/, fn -> Plug.Adapters.Cowboy2.https(MyPlug, [], []) end ssl_error = ~r/ssl\/key\.pem required by SSL's :keyfile either does not exist/ assert_raise ArgumentError, ssl_error, fn -> Plug.Adapters.Cowboy2.https( MyPlug, [], keyfile: "priv/ssl/key.pem", certfile: "priv/ssl/cert.pem", otp_app: :plug ) end end end
34.246988
98
0.577661
737d9d3e1f16513d4c035e62ff86a5338fcb980b
1,652
ex
Elixir
lib/hex/shell/process.ex
Benjamin-Philip/hex
19860cfb33fee0a80c49d38ef1d5f407baa72148
[ "Apache-2.0" ]
824
2015-01-05T09:12:36.000Z
2022-03-28T12:02:29.000Z
lib/hex/shell/process.ex
Benjamin-Philip/hex
19860cfb33fee0a80c49d38ef1d5f407baa72148
[ "Apache-2.0" ]
737
2015-01-01T05:48:46.000Z
2022-03-29T12:56:12.000Z
lib/hex/shell/process.ex
Benjamin-Philip/hex
19860cfb33fee0a80c49d38ef1d5f407baa72148
[ "Apache-2.0" ]
220
2015-03-14T17:55:11.000Z
2022-03-23T22:17:07.000Z
defmodule Hex.Shell.Process do @moduledoc false @behaviour Mix.Shell def flush(callback \\ fn x -> x end) do receive do {:mix_shell, _, _} = message -> callback.(message) flush(callback) {:mix_shell_input, _, _} = message -> callback.(message) flush(callback) after 0 -> :done end end def print_app do if name = Mix.Shell.printable_app_name() do send(process(), {:mix_shell, :info, ["==> #{name}"]}) end end def info(message) do print_app() send(process(), {:mix_shell, :info, [format(message)]}) :ok end def error(message) do print_app() send(process(), {:mix_shell, :error, [format(message)]}) :ok end defp format(message) do message |> IO.ANSI.format(false) |> IO.iodata_to_binary() end def prompt(message) do print_app() send(process(), {:mix_shell, :prompt, [message]}) receive do {:mix_shell_input, :prompt, response} -> response after 0 -> raise "no shell process input given for prompt/1" end end def yes?(message, _options \\ []) do print_app() send(process(), {:mix_shell, :yes?, [message]}) receive do {:mix_shell_input, :yes?, response} -> response after 0 -> raise "no shell process input given for yes?/1" end end def cmd(command, opts \\ []) do print_app? = Keyword.get(opts, :print_app, true) Hex.Shell.cmd(command, opts, fn data -> if print_app?, do: print_app() send(process(), {:mix_shell, :run, [data]}) end) end defp process() do Hex.State.fetch!(:shell_process) || self() end end
21.454545
61
0.595642
737da21a2762f0a70d3dae7b670f642854781832
1,041
ex
Elixir
lib/pgex/result.ex
karlseguin/pgex
2921f350c9f8c8f72cc75c7ede85728ea5dba1bf
[ "MIT" ]
null
null
null
lib/pgex/result.ex
karlseguin/pgex
2921f350c9f8c8f72cc75c7ede85728ea5dba1bf
[ "MIT" ]
null
null
null
lib/pgex/result.ex
karlseguin/pgex
2921f350c9f8c8f72cc75c7ede85728ea5dba1bf
[ "MIT" ]
null
null
null
defmodule PgEx.Result do @moduledoc """ Represents the result of a query """ defstruct [:it, :rows, :columns, :affected] @typedoc """ The enumerable result returned by a query. """ @type t :: %__MODULE__{ it: [any], rows: [any], columns: [String.t], affected: non_neg_integer, } @doc false @spec create_row(t, [any]) :: map def create_row(result, columns) do Map.new(Enum.zip(result.columns, columns)) end end defimpl Enumerable, for: PgEx.Result do alias PgEx.Result def count(result), do: {:ok, result.affected} def member?(_result, _value), do: {:error, __MODULE__} def reduce(_result, {:halt, acc}, _f), do: {:halted, acc} def reduce(result, {:suspend, acc}, f), do: {:suspended, acc, &reduce(result, &1, f)} def reduce(%{it: []}, {:cont, acc}, _f), do: {:done, acc} def reduce(result, {:cont, acc}, f) do [columns | rows] = result.it result = %Result{result | it: rows} row = Result.create_row(result, columns) reduce(result, f.(row, acc), f) end end
26.025
87
0.626321
737da3043e5828427b3683b9d212127286d870fb
122
exs
Elixir
.formatter.exs
gamache/ets_deque
dbd949b0f461d70d19e47c3d910f9bb029c7369e
[ "MIT" ]
2
2020-01-27T16:15:45.000Z
2020-01-29T18:14:04.000Z
.formatter.exs
gamache/ets_deque
dbd949b0f461d70d19e47c3d910f9bb029c7369e
[ "MIT" ]
null
null
null
.formatter.exs
gamache/ets_deque
dbd949b0f461d70d19e47c3d910f9bb029c7369e
[ "MIT" ]
1
2021-03-18T10:33:30.000Z
2021-03-18T10:33:30.000Z
# Used by "mix format" [ inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"], trailing_comma: true, ]
20.333333
70
0.590164
737dd179d61dd476b5e334a08a5d49e35ba37c1a
1,601
ex
Elixir
clients/plus/lib/google_api/plus/v1/model/activity_object_plusoners.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/plus/lib/google_api/plus/v1/model/activity_object_plusoners.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/plus/lib/google_api/plus/v1/model/activity_object_plusoners.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.Plus.V1.Model.ActivityObjectPlusoners do @moduledoc """ People who +1'd this activity. ## Attributes * `selfLink` (*type:* `String.t`, *default:* `nil`) - The URL for the collection of people who +1'd this activity. * `totalItems` (*type:* `integer()`, *default:* `nil`) - Total number of people who +1'd this activity. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :selfLink => String.t(), :totalItems => integer() } field(:selfLink) field(:totalItems) end defimpl Poison.Decoder, for: GoogleApi.Plus.V1.Model.ActivityObjectPlusoners do def decode(value, options) do GoogleApi.Plus.V1.Model.ActivityObjectPlusoners.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Plus.V1.Model.ActivityObjectPlusoners do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
32.02
118
0.722049
737dd6b0221b7ef5de59ae2ed27b3be5fd47179a
310
ex
Elixir
lib/daily_meals/users/delete.ex
vinolivae/daily_meals
8f375cbb7eaf54abfa6b683705bb8075067f9078
[ "MIT" ]
null
null
null
lib/daily_meals/users/delete.ex
vinolivae/daily_meals
8f375cbb7eaf54abfa6b683705bb8075067f9078
[ "MIT" ]
null
null
null
lib/daily_meals/users/delete.ex
vinolivae/daily_meals
8f375cbb7eaf54abfa6b683705bb8075067f9078
[ "MIT" ]
null
null
null
defmodule DailyMeals.Users.Delete do alias DailyMeals.{Error, Repo, User} @spec delete(uuid :: String.t()) :: User.t() | Error.t() def delete(uuid) do case Repo.get(User, uuid) do nil -> {:error, Error.build_not_found_error("User not found")} user -> Repo.delete(user) end end end
25.833333
68
0.648387
737dfe4de89d61986860b71239ecfebc8d0b7144
76
exs
Elixir
test/seren_web/views/page_view_test.exs
allen-garvey/seren
f61cb7edcd7d3f927d2929db14b2a4a1578a3925
[ "MIT" ]
4
2019-10-04T16:11:15.000Z
2021-08-18T21:00:13.000Z
apps/seren/test/seren_web/views/page_view_test.exs
allen-garvey/phoenix-umbrella
1d444bbd62a5e7b5f51d317ce2be71ee994125d5
[ "MIT" ]
5
2020-03-16T23:52:25.000Z
2021-09-03T16:52:17.000Z
test/seren_web/views/page_view_test.exs
allen-garvey/seren
f61cb7edcd7d3f927d2929db14b2a4a1578a3925
[ "MIT" ]
null
null
null
defmodule SerenWeb.PageViewTest do use SerenWeb.ConnCase, async: true end
19
36
0.815789
737dffe4769988ab585762ec407da3b51c29bb61
385
ex
Elixir
redfour/physics/lib/physics/rocketry.ex
mdeilman/ElixirCode
d0560c7b135b4cb146dccb8202b9e4dede199a1b
[ "Apache-2.0" ]
null
null
null
redfour/physics/lib/physics/rocketry.ex
mdeilman/ElixirCode
d0560c7b135b4cb146dccb8202b9e4dede199a1b
[ "Apache-2.0" ]
null
null
null
redfour/physics/lib/physics/rocketry.ex
mdeilman/ElixirCode
d0560c7b135b4cb146dccb8202b9e4dede199a1b
[ "Apache-2.0" ]
null
null
null
defmodule Physics.Planet do defstruct [ name: "Earth", radius_m: 6.371e6, mass_kg: 5.97e24 ] def escape_velocity(planet) do g = 6.67e-11 gmr = 2 * g * planet.mass_kg/planet.radius_m vms = :math.sqrt gmr vkms = vms/1000 Float.ceil vkms, 1 end end v = %Physics.Planet{} |> Physics.Planet.escape_velocity() defmodule Physics.Rocketry do end
16.73913
57
0.649351
737e09f9da7f1fd4aaca922cfd58a407b0be4010
370
exs
Elixir
priv/repo/migrations/20200531151254_create_redirects.exs
meltingice/conductor
630440adc1081a0991d3dba17ced775a9dd05055
[ "MIT" ]
null
null
null
priv/repo/migrations/20200531151254_create_redirects.exs
meltingice/conductor
630440adc1081a0991d3dba17ced775a9dd05055
[ "MIT" ]
2
2021-03-10T20:23:26.000Z
2021-05-11T15:56:49.000Z
priv/repo/migrations/20200531151254_create_redirects.exs
meltingice/conductor
630440adc1081a0991d3dba17ced775a9dd05055
[ "MIT" ]
1
2020-06-05T02:34:58.000Z
2020-06-05T02:34:58.000Z
defmodule Conductor.Repo.Migrations.CreateRedirects do use Ecto.Migration def change do create table(:redirects, primary_key: false) do add :id, :uuid, primary_key: true add :code, :string add :destination, :text add :views, :integer, default: 0 timestamps() end create index(:redirects, [:code], unique: true) end end
21.764706
54
0.662162
737e2139ce5da09e9cad0f622c9da85c6050d918
2,586
ex
Elixir
clients/dialogflow/lib/google_api/dialogflow/v3/model/google_cloud_dialogflow_v2beta1_original_detect_intent_request.ex
renovate-bot/elixir-google-api
1da34cd39b670c99f067011e05ab90af93fef1f6
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/dialogflow/lib/google_api/dialogflow/v3/model/google_cloud_dialogflow_v2beta1_original_detect_intent_request.ex
swansoffiee/elixir-google-api
9ea6d39f273fb430634788c258b3189d3613dde0
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/dialogflow/lib/google_api/dialogflow/v3/model/google_cloud_dialogflow_v2beta1_original_detect_intent_request.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.Dialogflow.V3.Model.GoogleCloudDialogflowV2beta1OriginalDetectIntentRequest do @moduledoc """ Represents the contents of the original request that was passed to the `[Streaming]DetectIntent` call. ## Attributes * `payload` (*type:* `map()`, *default:* `nil`) - Optional. This field is set to the value of the `QueryParameters.payload` field passed in the request. Some integrations that query a Dialogflow agent may provide additional information in the payload. In particular, for the Dialogflow Phone Gateway integration, this field has the form: { "telephony": { "caller_id": "+18558363987" } } Note: The caller ID field (`caller_id`) will be redacted for Trial Edition agents and populated with the caller ID in [E.164 format](https://en.wikipedia.org/wiki/E.164) for Essentials Edition agents. * `source` (*type:* `String.t`, *default:* `nil`) - The source of this request, e.g., `google`, `facebook`, `slack`. It is set by Dialogflow-owned servers. * `version` (*type:* `String.t`, *default:* `nil`) - Optional. The version of the protocol used for this request. This field is AoG-specific. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :payload => map() | nil, :source => String.t() | nil, :version => String.t() | nil } field(:payload, type: :map) field(:source) field(:version) end defimpl Poison.Decoder, for: GoogleApi.Dialogflow.V3.Model.GoogleCloudDialogflowV2beta1OriginalDetectIntentRequest do def decode(value, options) do GoogleApi.Dialogflow.V3.Model.GoogleCloudDialogflowV2beta1OriginalDetectIntentRequest.decode( value, options ) end end defimpl Poison.Encoder, for: GoogleApi.Dialogflow.V3.Model.GoogleCloudDialogflowV2beta1OriginalDetectIntentRequest do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
44.586207
591
0.734339
737e48ad5213cbbd49cf40846313824c6bceda35
871
ex
Elixir
lib/rocketpay_web/controllers/accounts_controller.ex
lucas-sachet/NLW04
1c678764d49d421d73d6beb942036593863397e0
[ "MIT" ]
null
null
null
lib/rocketpay_web/controllers/accounts_controller.ex
lucas-sachet/NLW04
1c678764d49d421d73d6beb942036593863397e0
[ "MIT" ]
null
null
null
lib/rocketpay_web/controllers/accounts_controller.ex
lucas-sachet/NLW04
1c678764d49d421d73d6beb942036593863397e0
[ "MIT" ]
null
null
null
defmodule RocketpayWeb.AccountsController do use RocketpayWeb, :controller alias Rocketpay.Accounts.Transaction.Response, as: TransactionResponse alias Rocketpay.Account action_fallback RocketpayWeb.FallbackController def deposit(conn, params) do with {:ok, %Account{} = account} <- Rocketpay.deposit(params) do conn |> put_status(:ok) |> render("update.json", account: account) end end def withdraw(conn, params) do with {:ok, %Account{} = account} <- Rocketpay.withdraw(params) do conn |> put_status(:ok) |> render("update.json", account: account) end end def transaction(conn, params) do with {:ok, %TransactionResponse{} = transaction} <- Rocketpay.transaction(params) do conn |> put_status(:ok) |> render("transaction.json", transaction: transaction) end end end
26.393939
88
0.677382
737e657f0c4e38af5172a3d2afa4ed7e31d5990d
17,317
exs
Elixir
test/ethereumex/http_client_test.exs
InoMurko/ethereumex
f8e18f8aa2d2f1719a67c69f11486621416ac324
[ "MIT" ]
158
2018-11-05T23:45:47.000Z
2022-03-21T18:58:31.000Z
test/ethereumex/http_client_test.exs
hawku-com/ethereumex
19a5cf1a4fcfd6c06aae3f97554c8a9af3f2d89b
[ "MIT" ]
43
2018-11-02T18:45:50.000Z
2022-02-28T09:09:46.000Z
test/ethereumex/http_client_test.exs
hawku-com/ethereumex
19a5cf1a4fcfd6c06aae3f97554c8a9af3f2d89b
[ "MIT" ]
28
2018-11-13T16:33:31.000Z
2022-03-31T17:49:11.000Z
defmodule Ethereumex.HttpClientTest do use ExUnit.Case alias Ethereumex.HttpClient @tag :web3 describe "HttpClient.web3_client_version/0" do test "returns client version" do result = HttpClient.web3_client_version() {:ok, <<_::binary>>} = result end end @tag :web3 describe "HttpClient.web3_sha3/1" do test "returns sha3 of the given data" do result = HttpClient.web3_sha3("0x68656c6c6f20776f726c64") { :ok, "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad" } = result end end @tag :net describe "HttpClient.net_version/0" do test "returns network id" do result = HttpClient.net_version() {:ok, <<_::binary>>} = result end end @tag :net describe "HttpClient.net_peer_count/0" do test "returns number of peers currently connected to the client" do result = HttpClient.net_peer_count() {:ok, <<_::binary>>} = result end end @tag :net describe "HttpClient.net_listening/0" do test "returns true" do result = HttpClient.net_listening() {:ok, true} = result end end @tag :eth describe "HttpClient.eth_protocol_version/0" do test "returns true" do result = HttpClient.eth_protocol_version() {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_syncing/1" do test "checks sync status" do {:ok, result} = HttpClient.eth_syncing() assert is_map(result) || is_boolean(result) end end @tag :eth describe "HttpClient.eth_coinbase/1" do test "returns coinbase address" do result = HttpClient.eth_coinbase() {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_mining/1" do test "checks mining status" do result = HttpClient.eth_mining() {:ok, false} = result end end @tag :eth describe "HttpClient.eth_hashrate/1" do test "returns hashrate" do result = HttpClient.eth_hashrate() {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_gas_price/1" do test "returns current price per gas" do result = HttpClient.eth_gas_price() {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_accounts/1" do test "returns addresses owned by client" do {:ok, result} = HttpClient.eth_accounts() assert result |> is_list end end @tag :eth describe "HttpClient.eth_block_number/1" do test "returns number of most recent block" do result = HttpClient.eth_block_number() {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_get_balance/3" do test "returns balance of given account" do result = HttpClient.eth_get_balance("0x001bdcde60cb916377a3a3bf4e8054051a4d02e7") {:ok, <<_::binary>>} = result end end @tag :skip describe "HttpClient.eth_get_storage_at/4" do test "returns value from a storage position at a given address." do result = HttpClient.eth_get_balance( "0x001bdcde60cb916377a3a3bf4e8054051a4d02e7", "0x0" ) {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_get_transaction_count/3" do test "returns number of transactions sent from an address." do result = HttpClient.eth_get_transaction_count("0x001bdcde60cb916377a3a3bf4e8054051a4d02e7") {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_get_block_transaction_count_by_hash/2" do test "number of transactions in a block from a block matching the given block hash" do result = HttpClient.eth_get_block_transaction_count_by_hash( "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238" ) {:ok, nil} = result end end @tag :eth describe "HttpClient.eth_get_block_transaction_count_by_number/2" do test "returns number of transactions in a block from a block matching the given block number" do result = HttpClient.eth_get_block_transaction_count_by_number() {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_get_uncle_count_by_block_hash/2" do test "the number of uncles in a block from a block matching the given block hash" do result = HttpClient.eth_get_uncle_count_by_block_hash( "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238" ) {:ok, nil} = result end end @tag :eth describe "HttpClient.eth_get_uncle_count_by_block_number/2" do test "the number of uncles in a block from a block matching the given block hash" do result = HttpClient.eth_get_uncle_count_by_block_number() {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_get_code/3" do test "returns code at a given address" do result = HttpClient.eth_get_code("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b") {:ok, <<_::binary>>} = result end end @tag :eth_sign describe "HttpClient.eth_sign/3" do test "returns signature" do result = HttpClient.eth_sign("0x71cf0b576a95c347078ec2339303d13024a26910", "0xdeadbeaf") {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_estimate_gas/3" do test "estimates gas" do data = "0x6060604052341561" <> "000f57600080fd5b60b38061001d6000396000f3006060604052" <> "63ffffffff7c0100000000000000000000000000000000000000" <> "00000000000000000060003504166360fe47b181146045578063" <> "6d4ce63c14605a57600080fd5b3415604f57600080fd5b605860" <> "0435607c565b005b3415606457600080fd5b606a6081565b6040" <> "5190815260200160405180910390f35b600055565b6000549056" <> "00a165627a7a7230582033edcee10845eead909dccb4e95bb7e4" <> "062e92234bf3cfaf804edbd265e599800029" from = "0x001bdcde60cb916377a3a3bf4e8054051a4d02e7" transaction = %{data: data, from: from} result = HttpClient.eth_estimate_gas(transaction) {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_get_block_by_hash/3" do test "returns information about a block by hash" do result = HttpClient.eth_get_block_by_hash( "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238", true ) {:ok, nil} = result end end @tag :eth describe "HttpClient.eth_get_block_by_number/3" do test "returns information about a block by number" do {:ok, result} = HttpClient.eth_get_block_by_number("0x1b4", true) assert is_nil(result) || is_map(result) end end @tag :eth describe "HttpClient.eth_get_transaction_by_hash/2" do test "returns the information about a transaction by its hash" do result = HttpClient.eth_get_transaction_by_hash( "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238" ) {:ok, nil} = result end end @tag :eth describe "HttpClient.eth_get_transaction_by_block_hash_and_index/3" do test "returns the information about a transaction by block hash and index" do result = HttpClient.eth_get_transaction_by_block_hash_and_index( "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238", "0x0" ) {:ok, nil} = result end end @tag :eth describe "HttpClient.eth_get_transaction_by_block_number_and_index/3" do test "returns the information about a transaction by block number and index" do result = HttpClient.eth_get_transaction_by_block_number_and_index("earliest", "0x0") {:ok, nil} = result end end @tag :eth describe "HttpClient.eth_get_transaction_receipt/2" do test "returns the receipt of a transaction by transaction hash" do result = HttpClient.eth_get_transaction_receipt( "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238" ) {:ok, nil} = result end end @tag :eth describe "HttpClient.eth_get_uncle_by_block_hash_and_index/3" do test "returns information about a uncle of a block by hash and uncle index position" do result = HttpClient.eth_get_uncle_by_block_hash_and_index( "0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x0" ) {:ok, nil} = result end end @tag :eth describe "HttpClient.eth_get_uncle_by_block_number_and_index/3" do test "returns information about a uncle of a block by number and uncle index position" do result = HttpClient.eth_get_uncle_by_block_number_and_index("0x29c", "0x0") {:ok, _} = result end end @tag :eth_compile describe "HttpClient.eth_get_compilers/1" do test "returns a list of available compilers in the client" do result = HttpClient.eth_get_compilers() {:ok, _} = result end end @tag :eth describe "HttpClient.eth_new_filter/2" do test "creates a filter object" do filter = %{ fromBlock: "0x1", toBlock: "0x2", address: "0x8888f1f195afa192cfee860698584c030f4c9db1", topics: [ "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", nil, [ "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc" ] ] } result = HttpClient.eth_new_filter(filter) {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_new_12" do test "creates a filter object" do filter = %{ fromBlock: "0x1", toBlock: "0x2", address: "0x8888f1f195afa192cfee860698584c030f4c9db1", topics: [ "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", nil, [ "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc" ] ] } result = HttpClient.eth_new_filter(filter) {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_new_block_filter/1" do test "creates new block filter" do result = HttpClient.eth_new_block_filter() {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_new_pending_transaction_filter/1" do test "creates new pending transaction filter" do result = HttpClient.eth_new_pending_transaction_filter() {:ok, <<_::binary>>} = result end end @tag :eth describe "HttpClient.eth_uninstall_filter/2" do test "uninstalls a filter with given id" do {:ok, result} = HttpClient.eth_uninstall_filter("0xb") assert is_boolean(result) end end @tag :eth describe "HttpClient.eth_get_filter_changes/2" do test "returns an array of logs which occurred since last poll" do result = HttpClient.eth_get_filter_changes("0x16") {:ok, []} = result end end @tag :eth describe "HttpClient.eth_get_filter_logs/2" do test "returns an array of all logs matching filter with given id" do result = HttpClient.eth_get_filter_logs("0x16") {:ok, []} = result end end @tag :eth describe "HttpClient.eth_get_logs/2" do test "returns an array of all logs matching a given filter object" do filter = %{ topics: ["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"] } result = HttpClient.eth_get_logs(filter) {:ok, []} = result end end @tag :eth_mine describe "HttpClient.eth_submit_work/4" do test "validates solution" do result = HttpClient.eth_submit_work( "0x0000000000000001", "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000" ) {:ok, false} = result end end @tag :eth_mine describe "HttpClient.eth_get_work/1" do test "returns the hash of the current block, the seedHash, and the boundary condition to be met " do result = HttpClient.eth_get_work() {:ok, [<<_::binary>>, <<_::binary>>, <<_::binary>>]} = result end end @tag :eth_mine describe "HttpClient.eth_submit_hashrate/3" do test "submits mining hashrate" do result = HttpClient.eth_submit_hashrate( "0x0000000000000000000000000000000000000000000000000000000000500000", "0x59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c" ) {:ok, true} = result end end @tag :eth_db describe "HttpClient.db_put_string/4" do test "stores a string in the local database" do result = HttpClient.db_put_string("testDB", "myKey", "myString") {:ok, true} = result end end @tag :eth_db describe "HttpClient.db_get_string/3" do test "returns string from the local database" do result = HttpClient.db_get_string("db", "key") {:ok, nil} = result end end @tag :eth_db describe "HttpClient.db_put_hex/4" do test "stores binary data in the local database" do result = HttpClient.db_put_hex("db", "key", "data") {:ok, true} = result end end @tag :eth_db describe "HttpClient.db_get_hex/3" do test "returns binary data from the local database" do result = HttpClient.db_get_hex("db", "key") {:ok, nil} = result end end @tag :shh describe "HttpClient.shh_post/2" do test "sends a whisper message" do whisper = %{ from: "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1", to: "0x3e245533f97284d442460f2998cd41858798ddf04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a0d4d661997d3940272b717b1", topics: [ "0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532" ], payload: "0x7b2274797065223a226d6", priority: "0x64", ttl: "0x64" } result = HttpClient.shh_post(whisper) {:ok, true} = result end end @tag :shh describe "HttpClient.shh_version/1" do test "returns the current whisper protocol version" do result = HttpClient.shh_version() {:ok, <<_::binary>>} = result end end @tag :shh describe "HttpClient.shh_new_identity/1" do test "creates new whisper identity in the client" do result = HttpClient.shh_new_identity() {:ok, <<_::binary>>} = result end end @tag :shh describe "HttpClient.shh_has_entity/2" do test "creates new whisper identity in the client" do result = HttpClient.shh_has_identity( "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1" ) {:ok, false} = result end end @tag :shh describe "HttpClient.shh_add_to_group/2" do test "adds adress to group" do result = HttpClient.shh_add_to_group( "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1" ) {:ok, false} = result end end @tag :shh describe "HttpClient.shh_new_group/1" do test "creates new group" do result = HttpClient.shh_new_group() {:ok, <<_::binary>>} = result end end @tag :shh describe "HttpClient.shh_new_filter/2" do test "creates filter to notify, when client receives whisper message matching the filter options" do filter_options = %{ topics: ['0x12341234bf4b564f'], to: "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1" } result = HttpClient.shh_new_filter(filter_options) {:ok, <<_::binary>>} = result end end @tag :shh describe "HttpClient.shh_uninstall_filter/2" do test "uninstalls a filter with given id" do result = HttpClient.shh_uninstall_filter("0x7") {:ok, false} = result end end @tag :shh describe "HttpClient.shh_get_filter_changes/2" do test "polls filter chages" do result = HttpClient.shh_get_filter_changes("0x7") {:ok, []} = result end end @tag :shh describe "HttpClient.shh_get_messages/2" do test "returns all messages matching a filter" do result = HttpClient.shh_get_messages("0x7") {:ok, []} = result end end @tag :batch describe "HttpClient.batch_request/1" do test "sends batch request" do requests = [ {:web3_client_version, []}, {:net_version, []}, {:web3_sha3, ["0x68656c6c6f20776f726c64"]} ] result = HttpClient.batch_request(requests) { :ok, [ <<_::binary>>, <<_::binary>>, "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad" ] } = result end end end
26.559816
145
0.674828
737e7500bf8e7eb28e0d8ef60c51420690946c4d
2,801
exs
Elixir
test/mongo/retryable_reads_test.exs
aenglisc/elixir-mongodb-driver
a8a72fbb8690f44ac349e0449616ac2cfbf50640
[ "Apache-2.0" ]
140
2019-04-10T09:23:53.000Z
2022-03-27T12:37:02.000Z
test/mongo/retryable_reads_test.exs
aenglisc/elixir-mongodb-driver
a8a72fbb8690f44ac349e0449616ac2cfbf50640
[ "Apache-2.0" ]
99
2019-04-11T07:46:45.000Z
2022-03-31T07:23:28.000Z
test/mongo/retryable_reads_test.exs
aenglisc/elixir-mongodb-driver
a8a72fbb8690f44ac349e0449616ac2cfbf50640
[ "Apache-2.0" ]
45
2019-07-15T07:06:21.000Z
2021-11-24T09:23:21.000Z
defmodule Mongo.RetryableReadsTest do use CollectionCase alias Mongo.Error alias Mongo.Session test "find_one", %{pid: top, catcher: catcher} do coll = unique_collection() Mongo.insert_one(top, coll, %{name: "Greta", age: 10}) Mongo.insert_one(top, coll, %{name: "Tom", age: 13}) Mongo.insert_one(top, coll, %{name: "Waldo", age: 5}) Mongo.insert_one(top, coll, %{name: "Oska", age: 3}) assert {:ok, 4} == Mongo.count(top, coll, %{}) cmd = [ configureFailPoint: "failCommand", mode: [times: 1], data: [errorCode: 6, failCommands: ["find"]] ] Mongo.admin_command(top, cmd) {:error, %Error{code: 6, retryable_reads: true}} = Mongo.find_one(top, coll, %{"name" => "Waldo"}) Mongo.admin_command(top, cmd) assert %{"_id" => _id, "age" => 5, "name" => "Waldo"} = Mongo.find_one(top, coll, %{"name" => "Waldo"}, retryable_reads: true) assert [:find | _] = EventCatcher.retryable_read_events(catcher) |> Enum.map(fn event -> event.command_name end) end test "find_one in transaction", %{pid: top, catcher: catcher} do coll = unique_collection() Mongo.insert_one(top, coll, %{name: "Greta", age: 10}) Mongo.insert_one(top, coll, %{name: "Tom", age: 13}) Mongo.insert_one(top, coll, %{name: "Waldo", age: 5}) Mongo.insert_one(top, coll, %{name: "Oska", age: 3}) assert {:ok, 4} == Mongo.count(top, coll, %{}) cmd = [ configureFailPoint: "failCommand", mode: [times: 1], data: [errorCode: 6, failCommands: ["find"]] ] {:ok, session} = Session.start_session(top, :read, []) Mongo.admin_command(top, cmd) {:error, %Error{code: 6, retryable_reads: true}} = Mongo.find_one(top, coll, %{"name" => "Waldo"}, retryable_reads: true, session: session) Session.end_session(top, session) assert [] = EventCatcher.retryable_read_events(catcher) |> Enum.map(fn event -> event.command_name end) end test "count", %{pid: top, catcher: catcher} do coll = unique_collection() Mongo.insert_one(top, coll, %{name: "Greta", age: 10}) Mongo.insert_one(top, coll, %{name: "Tom", age: 13}) Mongo.insert_one(top, coll, %{name: "Waldo", age: 5}) Mongo.insert_one(top, coll, %{name: "Oska", age: 3}) assert {:ok, 4} == Mongo.count(top, coll, %{}) cmd = [ configureFailPoint: "failCommand", mode: [times: 1], data: [errorCode: 6, failCommands: ["count"]] ] Mongo.admin_command(top, cmd) {:error, %Error{code: 6, retryable_reads: true}} = Mongo.count(top, coll, %{}) Mongo.admin_command(top, cmd) assert {:ok, 4} == Mongo.count(top, coll, %{}, retryable_reads: true) assert [:count | _] = EventCatcher.retryable_read_events(catcher) |> Enum.map(fn event -> event.command_name end) end end
33.746988
143
0.622992
737e7be5160eaca36dc29f7ed1717361e1c31967
753
ex
Elixir
lib/firestorm_web/forums/thread.ex
chriswk/firestorm
7440d4e84db34a093a7c8761973c737561f53b45
[ "MIT" ]
null
null
null
lib/firestorm_web/forums/thread.ex
chriswk/firestorm
7440d4e84db34a093a7c8761973c737561f53b45
[ "MIT" ]
4
2021-03-01T21:25:42.000Z
2022-02-10T23:50:11.000Z
lib/firestorm_web/forums/thread.ex
chriswk/firestorm
7440d4e84db34a093a7c8761973c737561f53b45
[ "MIT" ]
null
null
null
defmodule FirestormWeb.Forums.Thread do @moduledoc """ Schema for forum threads. """ use Ecto.Schema alias FirestormWeb.Forums.{Category, Post, Watch, User} alias FirestormWeb.Forums.Slugs.ThreadTitleSlug schema "forums_threads" do field :title, :string field :slug, ThreadTitleSlug.Type field :first_post, {:map, %Post{}}, virtual: true field :posts_count, :integer, virtual: true field :completely_read?, :boolean, virtual: true belongs_to :category, Category has_many :posts, Post has_many :watches, {"forums_threads_watches", Watch}, foreign_key: :assoc_id many_to_many :watchers, User, join_through: "forums_threads_watches", join_keys: [assoc_id: :id, user_id: :id] timestamps() end end
30.12
114
0.719788
737e95c1aead721728a340405ddcc4a7b3dbd487
388
exs
Elixir
test/level/feature_flags_test.exs
pradyumna2905/level
186878a128521074923edd7171eda2f1b181b4f4
[ "Apache-2.0" ]
1
2019-06-11T20:20:32.000Z
2019-06-11T20:20:32.000Z
test/level/feature_flags_test.exs
pradyumna2905/level
186878a128521074923edd7171eda2f1b181b4f4
[ "Apache-2.0" ]
null
null
null
test/level/feature_flags_test.exs
pradyumna2905/level
186878a128521074923edd7171eda2f1b181b4f4
[ "Apache-2.0" ]
null
null
null
defmodule Level.FeatureFlagsTest do use Level.DataCase, async: true alias Level.FeatureFlags describe "signups_enabled?/1" do test "is true in non-prod environments" do assert FeatureFlags.signups_enabled?(:test) assert FeatureFlags.signups_enabled?(:dev) end test "is false in prod" do refute FeatureFlags.signups_enabled?(:prod) end end end
22.823529
49
0.719072