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 list | 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 list | 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 list | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ff20d571d29b01306ba9c04c6fe716062491316a | 71 | ex | Elixir | lib/user_service_web/views/layout_view.ex | sb8244/pow_starter_pack | 82e16c3e4139ecc85295078b54024f58f95ab794 | [
"MIT"
] | 13 | 2020-03-31T21:45:40.000Z | 2021-02-13T12:17:22.000Z | lib/user_service_web/views/layout_view.ex | sb8244/pow_starter_pack | 82e16c3e4139ecc85295078b54024f58f95ab794 | [
"MIT"
] | 1 | 2021-03-10T12:57:21.000Z | 2021-03-10T12:57:21.000Z | lib/user_service_web/views/layout_view.ex | sb8244/pow_starter_pack | 82e16c3e4139ecc85295078b54024f58f95ab794 | [
"MIT"
] | 1 | 2020-04-28T15:41:56.000Z | 2020-04-28T15:41:56.000Z | defmodule UserServiceWeb.LayoutView do
use UserServiceWeb, :view
end
| 17.75 | 38 | 0.830986 |
ff212e10d77df453783c959824d37349b1ec7062 | 994 | ex | Elixir | lib/bd_pro.ex | bus-detective/pro | d313f4facdb4c9229bd7a022eeabb85170000e18 | [
"MIT"
] | null | null | null | lib/bd_pro.ex | bus-detective/pro | d313f4facdb4c9229bd7a022eeabb85170000e18 | [
"MIT"
] | null | null | null | lib/bd_pro.ex | bus-detective/pro | d313f4facdb4c9229bd7a022eeabb85170000e18 | [
"MIT"
] | null | null | null | defmodule BdPro do
use Application
# See http://elixir-lang.org/docs/stable/elixir/Application.html
# for more information on OTP Applications
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
# Start the endpoint when the application starts
supervisor(BdPro.Endpoint, []),
# Start the Ecto repository
worker(BdPro.Repo, []),
# Here you could define other workers and supervisors as children
# worker(BdPro.Worker, [arg1, arg2, arg3]),
worker(BdPro.Collector, [])
]
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: BdPro.Supervisor]
Supervisor.start_link(children, opts)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
def config_change(changed, _new, removed) do
BdPro.Endpoint.config_change(changed, removed)
:ok
end
end
| 31.0625 | 71 | 0.702213 |
ff2148fb19ea5c854fd9413f312c690699bb3188 | 402 | ex | Elixir | lib/ex_pool/manager/info.ex | jcabotc/ex_pool | ec5acab0e16aa7b7d5c58abba8aa1ebcf8c5c6e4 | [
"Apache-2.0"
] | 6 | 2015-11-29T10:43:02.000Z | 2016-04-07T17:32:17.000Z | lib/ex_pool/manager/info.ex | jcabotc/ex_pool | ec5acab0e16aa7b7d5c58abba8aa1ebcf8c5c6e4 | [
"Apache-2.0"
] | null | null | null | lib/ex_pool/manager/info.ex | jcabotc/ex_pool | ec5acab0e16aa7b7d5c58abba8aa1ebcf8c5c6e4 | [
"Apache-2.0"
] | null | null | null | defmodule ExPool.Manager.Info do
alias ExPool.State
def get(state) do
%{
workers: workers(state),
waiting: waiting(state)
}
end
defp workers(state) do
total = State.total_workers(state)
free = State.available_workers(state)
in_use = total - free
%{total: total, free: free, in_use: in_use}
end
defp waiting(state), do: State.queue_size(state)
end
| 19.142857 | 50 | 0.656716 |
ff214f03e3378578413fe87c38df8e182bfce8a1 | 202 | exs | Elixir | priv/repo/migrations/20140115124723_create_rooms.exs | debonair/mogo-chat | 108c611177363a04d278221aabc03dcd2b66597c | [
"MIT"
] | 210 | 2015-01-01T04:17:56.000Z | 2022-02-26T23:54:56.000Z | priv/repo/migrations/20140115124723_create_rooms.exs | debonair/mogo-chat | 108c611177363a04d278221aabc03dcd2b66597c | [
"MIT"
] | 1 | 2015-05-08T21:44:36.000Z | 2015-05-08T21:44:36.000Z | priv/repo/migrations/20140115124723_create_rooms.exs | debonair/mogo-chat | 108c611177363a04d278221aabc03dcd2b66597c | [
"MIT"
] | 40 | 2015-01-06T08:48:40.000Z | 2020-05-26T18:03:07.000Z | defmodule Repo.Migrations.CreateRooms do
use Ecto.Migration
def up do
"CREATE TABLE IF NOT EXISTS rooms(id serial primary key, name text)"
end
def down do
"DROP TABLE rooms"
end
end
| 16.833333 | 72 | 0.712871 |
ff2160cee6df974580d37d7e98b26348b2f60bf4 | 3,188 | ex | Elixir | clients/dataflow/lib/google_api/dataflow/v1b3/model/execution_stage_summary.ex | MasashiYokota/elixir-google-api | 975dccbff395c16afcb62e7a8e411fbb58e9ab01 | [
"Apache-2.0"
] | null | null | null | clients/dataflow/lib/google_api/dataflow/v1b3/model/execution_stage_summary.ex | MasashiYokota/elixir-google-api | 975dccbff395c16afcb62e7a8e411fbb58e9ab01 | [
"Apache-2.0"
] | null | null | null | clients/dataflow/lib/google_api/dataflow/v1b3/model/execution_stage_summary.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.Dataflow.V1b3.Model.ExecutionStageSummary do
@moduledoc """
Description of the composing transforms, names/ids, and input/outputs of a stage of execution. Some composing transforms and sources may have been generated by the Dataflow service during execution planning.
## Attributes
* `componentSource` (*type:* `list(GoogleApi.Dataflow.V1b3.Model.ComponentSource.t)`, *default:* `nil`) - Collections produced and consumed by component transforms of this stage.
* `componentTransform` (*type:* `list(GoogleApi.Dataflow.V1b3.Model.ComponentTransform.t)`, *default:* `nil`) - Transforms that comprise this execution stage.
* `id` (*type:* `String.t`, *default:* `nil`) - Dataflow service generated id for this stage.
* `inputSource` (*type:* `list(GoogleApi.Dataflow.V1b3.Model.StageSource.t)`, *default:* `nil`) - Input sources for this stage.
* `kind` (*type:* `String.t`, *default:* `nil`) - Type of tranform this stage is executing.
* `name` (*type:* `String.t`, *default:* `nil`) - Dataflow service generated name for this stage.
* `outputSource` (*type:* `list(GoogleApi.Dataflow.V1b3.Model.StageSource.t)`, *default:* `nil`) - Output sources for this stage.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:componentSource => list(GoogleApi.Dataflow.V1b3.Model.ComponentSource.t()),
:componentTransform => list(GoogleApi.Dataflow.V1b3.Model.ComponentTransform.t()),
:id => String.t(),
:inputSource => list(GoogleApi.Dataflow.V1b3.Model.StageSource.t()),
:kind => String.t(),
:name => String.t(),
:outputSource => list(GoogleApi.Dataflow.V1b3.Model.StageSource.t())
}
field(:componentSource, as: GoogleApi.Dataflow.V1b3.Model.ComponentSource, type: :list)
field(:componentTransform, as: GoogleApi.Dataflow.V1b3.Model.ComponentTransform, type: :list)
field(:id)
field(:inputSource, as: GoogleApi.Dataflow.V1b3.Model.StageSource, type: :list)
field(:kind)
field(:name)
field(:outputSource, as: GoogleApi.Dataflow.V1b3.Model.StageSource, type: :list)
end
defimpl Poison.Decoder, for: GoogleApi.Dataflow.V1b3.Model.ExecutionStageSummary do
def decode(value, options) do
GoogleApi.Dataflow.V1b3.Model.ExecutionStageSummary.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.Dataflow.V1b3.Model.ExecutionStageSummary do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 49.046154 | 209 | 0.72522 |
ff2176274ea7e1af77f8ffe7f5e55c5595b4c05f | 3,331 | ex | Elixir | lib/bpxe/engine/parallel_gateway.ex | cjsuite/bpxe | 4b4759b7e2e8ced9f6f76ab55e5da26eb319a7c9 | [
"Apache-2.0"
] | null | null | null | lib/bpxe/engine/parallel_gateway.ex | cjsuite/bpxe | 4b4759b7e2e8ced9f6f76ab55e5da26eb319a7c9 | [
"Apache-2.0"
] | null | null | null | lib/bpxe/engine/parallel_gateway.ex | cjsuite/bpxe | 4b4759b7e2e8ced9f6f76ab55e5da26eb319a7c9 | [
"Apache-2.0"
] | null | null | null | defmodule BPXE.Engine.ParallelGateway do
use GenServer
use BPXE.Engine.FlowNode
alias BPXE.Engine.Process
alias BPXE.Engine.Process.Log
defstate token_ids: %{}, drop_tokens: %{}
@persist_state :token_ids
@persist_state :drop_tokens
def start_link(element, attrs, model, process) do
GenServer.start_link(__MODULE__, {element, attrs, model, process})
end
def init({_element, attrs, model, process}) do
state =
%__MODULE__{}
|> put_state(Base, %{attrs: attrs, model: model, process: process})
state = initialize(state)
{:ok, state}
end
def handle_token({%BPXE.Token{} = token, id}, state) do
base_state = get_state(state, BPXE.Engine.Base)
Process.log(base_state.process, %Log.ParallelGatewayReceived{
pid: self(),
id: base_state.attrs["id"],
token_id: token.token_id,
from: id
})
flow_node_state = get_state(state, BPXE.Engine.FlowNode)
case flow_node_state.incoming do
[_] ->
# only one incoming, we're done
Process.log(base_state.process, %Log.ParallelGatewayCompleted{
pid: self(),
id: base_state.attrs["id"],
token_id: token.token_id,
to: flow_node_state.outgoing
})
{:send, token, state}
[] ->
# there's a token but it couldn't come from anywhere. What gives?
Process.log(base_state.process, %Log.ParallelGatewayCompleted{
pid: self(),
id: base_state.attrs["id"],
token_id: token.token_id,
to: []
})
{:dontsend, state}
_ ->
# Join
# If join threshold was already reached, drop a token
drop_token = state.drop_tokens[token.token_id]
if !!drop_token do
drop_token = drop_token - 1
drop_tokens =
if drop_token == 0 do
Map.delete(state.drop_tokens, token.token_id)
else
Map.put(state.drop_tokens, token.token_id, drop_token)
end
{:dontsend, %{state | drop_tokens: drop_tokens}}
else
token_ids =
Map.update(state.token_ids, token.token_id, [token], fn x -> [token | x] end)
tokens = token_ids[token.token_id]
join_threshold =
(base_state.attrs[{BPXE.BPMN.ext_spec(), "joinThreshold"}] ||
"#{length(flow_node_state.incoming)}")
|> String.to_integer()
if length(tokens) == join_threshold do
token_ids = Map.delete(token_ids, token.token_id)
token = Enum.reduce(tl(tokens), token, &BPXE.Token.merge/2)
Process.log(base_state.process, %Log.ParallelGatewayCompleted{
pid: self(),
id: base_state.attrs["id"],
token_id: token.token_id,
to: flow_node_state.outgoing
})
{:send, token,
%{
state
| token_ids: token_ids,
drop_tokens:
Map.put(
state.drop_tokens,
token.token_id,
length(flow_node_state.incoming) - join_threshold
)
}}
else
{:dontsend, %{state | token_ids: token_ids}}
end
end
end
end
end
| 28.228814 | 89 | 0.563494 |
ff21948287057b4f4da74e0852c3f89027fa989a | 5,986 | exs | Elixir | priv/repo/seeds.exs | smpallen99/ucx_chat | 0dd98d0eb5e0537521844520ea2ba63a08fd3f19 | [
"MIT"
] | 60 | 2017-05-09T19:08:26.000Z | 2021-01-20T11:09:42.000Z | priv/repo/seeds.exs | smpallen99/ucx_chat | 0dd98d0eb5e0537521844520ea2ba63a08fd3f19 | [
"MIT"
] | 6 | 2017-05-10T15:43:16.000Z | 2020-07-15T07:14:41.000Z | priv/repo/seeds.exs | smpallen99/ucx_chat | 0dd98d0eb5e0537521844520ea2ba63a08fd3f19 | [
"MIT"
] | 10 | 2017-05-10T04:13:54.000Z | 2020-12-28T10:30:27.000Z | # Script for populating the database. You can run it as:
#
# mix run priv/repo/seeds.exs
#
# Inside the script, you can read and write to any of your
# repositories directly:
#
# UcxChat.Repo.insert!(%UcxChat.SomeModel{})
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.
alias UcxChat.{
Repo, User, Channel, Subscription, Message, Account, Mention,
Direct, PinnedMessage, StaredMessage, Config, Role, UserRole,
ChannelService, Attachment, Reaction
}
Repo.delete_all UserRole
Repo.delete_all User
Repo.delete_all Reaction
Repo.delete_all Attachment
Repo.delete_all Account
Repo.delete_all Channel
Repo.delete_all Subscription
Repo.delete_all Mention
Repo.delete_all Direct
Repo.delete_all Message
Repo.delete_all PinnedMessage
Repo.delete_all StaredMessage
Repo.delete_all Config
Repo.delete_all Role
Repo.insert! Config.new_changeset
roles =
[admin: :global, moderator: :rooms, owner: :rooms, user: :global, bot: :global, guest: :global]
|> Enum.map(fn {role, scope} ->
%Role{}
|> Role.changeset(%{name: to_string(role), scope: to_string(scope)})
|> Repo.insert!
end)
create_username = fn name ->
name
|> String.downcase
|> String.split(" ", trim: true)
|> Enum.join(".")
end
create_user = fn name, email, password, admin ->
username = create_username.(name)
account = %Account{} |> Account.changeset(%{}) |> Repo.insert!
params = %{
username: username, account_id: account.id, name: name, email: email,
password: password, password_confirmation: password
}
params = if admin == :bot, do: Map.put(params, :avatar_url, "/images/hubot.png"), else: params
user =
%User{}
|> User.changeset(params)
|> Repo.insert!
role_name = case admin do
true -> "admin"
false -> "user"
:bot -> "bot"
end
%UserRole{}
|> UserRole.changeset(%{user_id: user.id, role: role_name})
|> Repo.insert!
user
end
# c1 = User.changeset(%User{}, %{nickname: "Admin"}) |> UcxChat.Repo.insert!
# c2 = User.changeset(%User{}, %{nickname: "Steve"}) |> UcxChat.Repo.insert!
# c3 = User.changeset(%User{}, %{nickname: "Merilee"}) |> UcxChat.Repo.insert!
# u0 = User.changeset(%User{}, %{name: "UCxBot", username: "UCxBot", type: "b"}) |> UcxChat.Repo.insert!
u0 = create_user.("Bot", "bot@example.com", "test", :bot)
u1 = create_user.("Admin", "admin@spallen.com", "test", true)
u2 = create_user.("Steve Pallen", "steve.pallen@spallen.com", "test", true)
u3 = create_user.("Merilee Lackey", "merilee.lackey@spallen.com", "test", false)
users =
[
"Jamie Pallen", "Jason Pallen", "Simon", "Eric", "Lina", "Denine", "Vince", "Richard", "Sharron",
"Ardavan", "Joseph", "Chris", "Osmond", "Patrick", "Tom", "Jeff"
]
|> Enum.map(fn name ->
lname = create_username.(name)
create_user.(name, "#{lname}@example.com", "test", false)
end)
ch1 = ChannelService.insert_channel!(%{name: "general", user_id: u0.id})
ch2 = ChannelService.insert_channel!(%{name: "support", user_id: u1.id})
channels =
~w(Research Marketing HR Accounting Shipping Sales) ++ ["UCxWebUser", "UCxChat"]
|> Enum.map(fn name ->
ChannelService.insert_channel!(%{name: name, user_id: u1.id})
end)
[ch1, ch2] ++ Enum.take(channels, 3)
|> Enum.each(fn ch ->
%Subscription{}
|> Subscription.changeset(%{channel_id: ch.id, user_id: u1.id})
|> Repo.insert!
%Subscription{}
|> Subscription.changeset(%{channel_id: ch.id, user_id: u2.id})
|> Repo.insert!
%Subscription{}
|> Subscription.changeset(%{channel_id: ch.id, user_id: u3.id})
|> Repo.insert!
end)
users
|> Enum.each(fn c ->
%Subscription{}
|> Subscription.changeset(%{channel_id: ch1.id, user_id: c.id})
|> Repo.insert!
end)
chan_parts = ~w(biz sales tech foo home work product pbx phone iphone galaxy android slim user small big sand storm snow rain tv shows earth hail)
for i <- 1..50 do
name = Enum.random(chan_parts) <> to_string(i) <> Enum.random(chan_parts)
user = Enum.random(users)
ChannelService.insert_channel!(%{name: name, user_id: user.id})
end
add_messages = true
if add_messages do
messages = [
"hello there",
"what's up doc",
"are you there?",
"Did you get the join?",
"When will you be home?",
"Be right there!",
"Can't wait to see you!",
"What did you watch last night?",
"Is your homework done yet?",
"what time is it?",
"whats for dinner?",
"are you sleeping?",
"how did you sleep last night?",
"did you have a good trip?",
"Tell me about your day",
"be home by 5 please",
"wake me up a 9 please",
"ttyl",
"cul8r",
"hope it works",
"Let me tell you a story about a man named Jed",
]
user_ids = [u1.id, u2.id, u3.id]
other_ch_ids = Enum.take(channels, 3) |> Enum.map(&(&1.id))
for _ <- 0..500 do
for ch_id <- [ch1.id, ch2.id] ++ other_ch_ids do
id = Enum.random user_ids
%Message{}
|> Message.changeset(%{channel_id: ch_id, user_id: id, body: Enum.random(messages)})
|> Repo.insert!
end
end
for _ <- 0..500 do
id = Enum.random user_ids
%Message{}
|> Message.changeset(%{channel_id: ch1.id, user_id: id, body: Enum.random(messages)})
|> Repo.insert!
end
new_channel_users = [
{Enum.random(users), Enum.random(channels)},
{Enum.random(users), Enum.random(channels)},
{Enum.random(users), Enum.random(channels)},
{Enum.random(users), Enum.random(channels)},
{Enum.random(users), Enum.random(channels)},
{Enum.random(users), Enum.random(channels)},
{Enum.random(users), Enum.random(channels)},
]
new_channel_users
|> Enum.each(fn {c, ch} ->
%Subscription{}
|> Subscription.changeset(%{channel_id: ch.id, user_id: c.id})
|> Repo.insert!
end)
for _ <- 1..200 do
{c, ch} = Enum.random new_channel_users
%Message{}
|> Message.changeset(%{channel_id: ch.id, user_id: c.id, body: Enum.random(messages)})
|> Repo.insert!
end
end
| 29.2 | 146 | 0.655864 |
ff21c6a9598cd27c2652f22afa3701e0d9cfff94 | 1,135 | exs | Elixir | printer-error/config/config.exs | crsanti/codewars-elixir | 7e7d9bceea5db8b965ecc1e17be52bc2aeafa4f0 | [
"MIT"
] | 2 | 2021-08-18T11:31:31.000Z | 2021-08-24T00:25:08.000Z | printer-error/config/config.exs | crsanti/codewars-elixir | 7e7d9bceea5db8b965ecc1e17be52bc2aeafa4f0 | [
"MIT"
] | null | null | null | printer-error/config/config.exs | crsanti/codewars-elixir | 7e7d9bceea5db8b965ecc1e17be52bc2aeafa4f0 | [
"MIT"
] | null | null | null | # This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
# file won't be loaded nor affect the parent project. For this reason,
# if you want to provide default values for your application for
# 3rd-party users, it should be done in your "mix.exs" file.
# You can configure your application as:
#
# config :printer_error, key: :value
#
# and access this configuration in your application as:
#
# Application.get_env(:printer_error, :key)
#
# You can also configure a 3rd-party app:
#
# config :logger, level: :info
#
# It is also possible to import configuration files, relative to this
# directory. For example, you can emulate configuration per environment
# by uncommenting the line below and defining dev.exs, test.exs and such.
# Configuration from the imported file will override the ones defined
# here (which is why it is important to import them last).
#
# import_config "#{Mix.env}.exs"
| 36.612903 | 73 | 0.754185 |
ff21d414f59c6f28c9683291e2174819408b3c45 | 1,157 | exs | Elixir | mix.exs | raymondboswel/bureaucrat | 4c0ef96cf2226552c457ed4d1a9afd53e197b145 | [
"Unlicense"
] | null | null | null | mix.exs | raymondboswel/bureaucrat | 4c0ef96cf2226552c457ed4d1a9afd53e197b145 | [
"Unlicense"
] | null | null | null | mix.exs | raymondboswel/bureaucrat | 4c0ef96cf2226552c457ed4d1a9afd53e197b145 | [
"Unlicense"
] | null | null | null | defmodule Bureaucrat.Mixfile do
use Mix.Project
def project do
[
app: :bureaucrat,
version: "0.2.7",
elixir: "~> 1.6 or ~> 1.7",
description: "Generate Phoenix API documentation from tests",
deps: deps(),
package: package()
]
end
# Configuration for the OTP application
#
# Type `mix help compile.app` for more information
def application do
[
registered: [Bureaucrat.Recorder],
mod: {Bureaucrat, []},
env: [
writer: Bureaucrat.MarkdownWriter,
default_path: "API.md",
paths: [],
titles: [],
env_var: "DOC"
]
]
end
defp deps do
[
{:plug, ">= 1.0.0"},
{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0 or ~> 4.0", optional: true},
{:phoenix, ">= 1.2.0", optional: true},
{:ex_doc, "~> 0.19", only: :dev},
{:inflex, ">= 1.10.0"}
]
end
defp package do
[
files: ~w(lib mix.exs README.md UNLICENSE),
maintainers: ["Roman Kuznietsov", "Opak Alex", "Arno Dirlam"],
licenses: ["Unlicense"],
links: %{"GitHub" => "https://github.com/api-hogs/bureaucrat"}
]
end
end
| 22.686275 | 72 | 0.536733 |
ff21f4ca22cc1c10a578c35b4a207251eb4062d1 | 271 | ex | Elixir | core/src/main/java/site/ycsb/data_gen/Graph_gen/Graph_gen/examples/localmotifcluster/Makefile.ex | qiuhere/Bench | 80f15facb81120b754547586cf3a7e5f46ca1551 | [
"Apache-2.0"
] | 1,805 | 2015-01-06T20:01:35.000Z | 2022-03-29T16:12:51.000Z | examples/localmotifcluster/Makefile.ex | lizhaoqing/snap | 907c34aac6bcddc7c2f8efb64be76e87dd7e4ea5 | [
"BSD-3-Clause"
] | 168 | 2015-01-07T22:57:29.000Z | 2022-03-15T01:20:24.000Z | examples/localmotifcluster/Makefile.ex | lizhaoqing/snap | 907c34aac6bcddc7c2f8efb64be76e87dd7e4ea5 | [
"BSD-3-Clause"
] | 768 | 2015-01-09T02:28:45.000Z | 2022-03-30T00:53:46.000Z | #
# configuration variables for the example
## Main application file
MAIN = localmotifclustermain
DEPH = $(EXSNAPADV)/localmotifcluster.h
DEPCPP = $(EXSNAPADV)/localmotifcluster.cpp
# Set the suffix _ if the fortran77 routines are named that way
CXXFLAGS += -DF77_POST
| 24.636364 | 63 | 0.782288 |
ff22049a7835195e4e8efa9ac429314c2b8c663e | 330 | exs | Elixir | test_projects/nif/bundlex.exs | vanillahsu/unifex | a501479b611a94c8a1477d969e170a7280673b7c | [
"Apache-2.0"
] | 42 | 2018-09-11T02:27:00.000Z | 2022-03-23T18:30:56.000Z | test_projects/nif/bundlex.exs | vanillahsu/unifex | a501479b611a94c8a1477d969e170a7280673b7c | [
"Apache-2.0"
] | 30 | 2018-10-18T10:56:22.000Z | 2022-03-09T13:04:51.000Z | test_projects/nif/bundlex.exs | vanillahsu/unifex | a501479b611a94c8a1477d969e170a7280673b7c | [
"Apache-2.0"
] | 7 | 2018-10-24T09:21:40.000Z | 2022-03-29T12:39:08.000Z | defmodule Example.BundlexProject do
use Bundlex.Project
def project() do
[
natives: natives(Bundlex.platform())
]
end
def natives(_platform) do
[
example: [
src_base: "example",
sources: ["example.c"],
preprocessor: Unifex,
interface: :nif
]
]
end
end
| 15.714286 | 42 | 0.566667 |
ff222b32cce01c71c68beba20dae650f91913a00 | 1,370 | ex | Elixir | lib/example/tasks/migrate.ex | sfairchild/distillery-aws-example | 156ce07eef6ae9f133daf328899e0cccc5f8edea | [
"Apache-2.0"
] | 46 | 2018-08-06T23:18:46.000Z | 2020-11-26T12:43:49.000Z | lib/example/tasks/migrate.ex | sfairchild/distillery-aws-example | 156ce07eef6ae9f133daf328899e0cccc5f8edea | [
"Apache-2.0"
] | 15 | 2018-08-23T08:29:48.000Z | 2020-05-18T14:05:38.000Z | lib/example/tasks/migrate.ex | sfairchild/distillery-aws-example | 156ce07eef6ae9f133daf328899e0cccc5f8edea | [
"Apache-2.0"
] | 84 | 2018-08-27T11:56:59.000Z | 2022-01-28T00:33:47.000Z | defmodule Example.Tasks.Migrate do
@moduledoc false
def migrate(_args) do
# Configure
Distillery.Releases.Config.Providers.Elixir.init(["${RELEASE_ROOT_DIR}/etc/config.exs"])
repo_config = Application.get_env(:distillery_example, Example.Repo)
repo_config = Keyword.put(repo_config, :adapter, Ecto.Adapters.Postgres)
Application.put_env(:distillery_example, Example.Repo, repo_config)
# Start requisite apps
IO.puts("==> Starting applications..")
for app <- [:crypto, :ssl, :postgrex, :ecto, :ecto_sql] do
{:ok, res} = Application.ensure_all_started(app)
IO.puts("==> Started #{app}: #{inspect(res)}")
end
# Start the repo
IO.puts("==> Starting repo")
{:ok, _pid} = Example.Repo.start_link(pool_size: 10, log: :info, log_sql: true)
# Run the migrations for the repo
IO.puts("==> Running migrations")
priv_dir = Application.app_dir(:distillery_example, "priv")
migrations_dir = Path.join([priv_dir, "repo", "migrations"])
opts = [all: true]
pool = Example.Repo.config()[:pool]
if function_exported?(pool, :unboxed_run, 2) do
pool.unboxed_run(Example.Repo, fn ->
Ecto.Migrator.run(Example.Repo, migrations_dir, :up, opts)
end)
else
Ecto.Migrator.run(Example.Repo, migrations_dir, :up, opts)
end
# Shut down
:init.stop()
end
end
| 31.860465 | 92 | 0.667883 |
ff228213e6ca0b65f5d69c66747f2fd7cf5a4851 | 1,390 | ex | Elixir | clients/cloud_resource_manager/lib/google_api/cloud_resource_manager/v3/model/undelete_project_metadata.ex | renovate-bot/elixir-google-api | 1da34cd39b670c99f067011e05ab90af93fef1f6 | [
"Apache-2.0"
] | 1 | 2021-12-20T03:40:53.000Z | 2021-12-20T03:40:53.000Z | clients/cloud_resource_manager/lib/google_api/cloud_resource_manager/v3/model/undelete_project_metadata.ex | swansoffiee/elixir-google-api | 9ea6d39f273fb430634788c258b3189d3613dde0 | [
"Apache-2.0"
] | 1 | 2020-08-18T00:11:23.000Z | 2020-08-18T00:44:16.000Z | clients/cloud_resource_manager/lib/google_api/cloud_resource_manager/v3/model/undelete_project_metadata.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.CloudResourceManager.V3.Model.UndeleteProjectMetadata do
@moduledoc """
A status object which is used as the `metadata` field for the Operation returned by `UndeleteProject`.
## Attributes
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{}
end
defimpl Poison.Decoder, for: GoogleApi.CloudResourceManager.V3.Model.UndeleteProjectMetadata do
def decode(value, options) do
GoogleApi.CloudResourceManager.V3.Model.UndeleteProjectMetadata.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.CloudResourceManager.V3.Model.UndeleteProjectMetadata do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 33.095238 | 104 | 0.774101 |
ff22d85c1d6e4e4b1e74b698468a04c765444de2 | 1,881 | ex | Elixir | clients/document_ai/lib/google_api/document_ai/v1beta2/model/google_cloud_documentai_v1beta1_document_provenance_parent.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_provenance_parent.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_provenance_parent.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.GoogleCloudDocumentaiV1beta1DocumentProvenanceParent do
@moduledoc """
Structure for referencing parent provenances. When an element replaces one of more other elements parent references identify the elements that are replaced.
## Attributes
* `id` (*type:* `integer()`, *default:* `nil`) - The id of the parent provenance.
* `revision` (*type:* `integer()`, *default:* `nil`) - The index of the [Document.revisions] identifying the parent revision.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:id => integer(),
:revision => integer()
}
field(:id)
field(:revision)
end
defimpl Poison.Decoder,
for: GoogleApi.DocumentAI.V1beta2.Model.GoogleCloudDocumentaiV1beta1DocumentProvenanceParent do
def decode(value, options) do
GoogleApi.DocumentAI.V1beta2.Model.GoogleCloudDocumentaiV1beta1DocumentProvenanceParent.decode(
value,
options
)
end
end
defimpl Poison.Encoder,
for: GoogleApi.DocumentAI.V1beta2.Model.GoogleCloudDocumentaiV1beta1DocumentProvenanceParent do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 34.2 | 158 | 0.74588 |
ff231fb7a67942c0da16857eb292a7ce7d80ad3b | 1,538 | exs | Elixir | exercises/raindrops/raindrops_test.exs | jerith/elixir | 9a3f2a2fbee26a7b6a6b3ad74a9e6d1ff2495ed4 | [
"Apache-2.0"
] | null | null | null | exercises/raindrops/raindrops_test.exs | jerith/elixir | 9a3f2a2fbee26a7b6a6b3ad74a9e6d1ff2495ed4 | [
"Apache-2.0"
] | null | null | null | exercises/raindrops/raindrops_test.exs | jerith/elixir | 9a3f2a2fbee26a7b6a6b3ad74a9e6d1ff2495ed4 | [
"Apache-2.0"
] | 1 | 2018-07-19T23:43:56.000Z | 2018-07-19T23:43:56.000Z | if !System.get_env("EXERCISM_TEST_EXAMPLES") do
Code.load_file("raindrops.exs", __DIR__)
end
ExUnit.start()
ExUnit.configure(exclude: :pending, trace: true)
defmodule RaindropsTest do
use ExUnit.Case
# @tag :pending
test "1" do
assert Raindrops.convert(1) == "1"
end
@tag :pending
test "3" do
assert Raindrops.convert(3) == "Pling"
end
@tag :pending
test "5" do
assert Raindrops.convert(5) == "Plang"
end
@tag :pending
test "7" do
assert Raindrops.convert(7) == "Plong"
end
@tag :pending
test "6" do
assert Raindrops.convert(6) == "Pling"
end
@tag :pending
test "9" do
assert Raindrops.convert(9) == "Pling"
end
@tag :pending
test "10" do
assert Raindrops.convert(10) == "Plang"
end
@tag :pending
test "14" do
assert Raindrops.convert(14) == "Plong"
end
@tag :pending
test "15" do
assert Raindrops.convert(15) == "PlingPlang"
end
@tag :pending
test "21" do
assert Raindrops.convert(21) == "PlingPlong"
end
@tag :pending
test "25" do
assert Raindrops.convert(25) == "Plang"
end
@tag :pending
test "35" do
assert Raindrops.convert(35) == "PlangPlong"
end
@tag :pending
test "49" do
assert Raindrops.convert(49) == "Plong"
end
@tag :pending
test "52" do
assert Raindrops.convert(52) == "52"
end
@tag :pending
test "105" do
assert Raindrops.convert(105) == "PlingPlangPlong"
end
@tag :pending
test "12121" do
assert Raindrops.convert(12121) == "12121"
end
end
| 16.901099 | 54 | 0.635241 |
ff23471aa50f6880262294fac802c776db5b62d8 | 2,062 | exs | Elixir | config/prod.exs | elpassion/sprint-poker | 5c9b34bb264c7a30ff48f0aeac40821b67310ff8 | [
"MIT"
] | 199 | 2015-10-22T16:20:09.000Z | 2021-11-08T11:20:45.000Z | config/prod.exs | elpassion/sprint-poker | 5c9b34bb264c7a30ff48f0aeac40821b67310ff8 | [
"MIT"
] | 4 | 2015-10-24T20:43:29.000Z | 2016-03-03T21:09:06.000Z | config/prod.exs | elpassion/sprint-poker | 5c9b34bb264c7a30ff48f0aeac40821b67310ff8 | [
"MIT"
] | 34 | 2015-10-23T06:38:43.000Z | 2019-08-13T23:49:24.000Z | use Mix.Config
# For production, we configure the host to read the PORT
# from the system environment. Therefore, you will need
# to set PORT=80 before running your server.
#
# You should also configure the url host to something
# meaningful, we use this information when generating URLs.
#
# Finally, we also include the path to a manifest
# containing the digested version of static files. This
# manifest is generated by the mix phoenix.digest task
# which you typically run after static files are built.
config :sprint_poker, SprintPoker.Web.Endpoint,
http: [port: {:system, "PORT"}],
url: [host: System.get_env("HOST"), port: 80],
check_origin: [
"//api.sprintpoker.io",
"//sprintpoker.io",
"//sprintpoker.netlify.com"
]
config :sprint_poker, SprintPoker.Web.Endpoint,
secret_key_base: System.get_env("SECRET_KEY_BASE")
# Configure your database
config :sprint_poker, SprintPoker.Repo,
adapter: Ecto.Adapters.Postgres,
url: {:system, "DATABASE_URL"},
pool_size: 20 # The amount of database connections in the pool
# ## 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 :sprint_poker, SprintPoker.Web.Endpoint,
# ...
# url: [host: "example.com", port: 443],
# https: [port: 443,
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")]
#
# Where those two env variables point to a file on
# disk for the key and cert.
config :airbrakex,
project_key: System.get_env("AIRBRAKE_PROJECT_KEY"),
project_id: System.get_env("AIRBRAKE_PROJECT_ID"),
environment: Mix.env
config :logger,
backends: [Airbrakex.LoggerBackend]
# ## Using releases
#
# If you are doing OTP releases, you need to instruct Phoenix
# to start the server for all endpoints:
#
# config :phoenix, :serve_endpoints, true
#
# Alternatively, you can configure exactly which server to
# start per endpoint:
#
# config :sprint_poker, SprintPoker.Web.Endpoint, server: true
#
| 30.776119 | 66 | 0.723569 |
ff234751c52b68e4ed6157502b53f37102f813ac | 23,736 | ex | Elixir | lib/elixir/lib/map.ex | axelson/elixir | accadf541c2045844b0c399adae22476840b3602 | [
"Apache-2.0"
] | null | null | null | lib/elixir/lib/map.ex | axelson/elixir | accadf541c2045844b0c399adae22476840b3602 | [
"Apache-2.0"
] | 1 | 2019-04-25T12:52:49.000Z | 2019-04-25T13:27:31.000Z | lib/elixir/lib/map.ex | fertapric/elixir | 9df2216670493aa30f37681cc812f3192adfe55a | [
"Apache-2.0"
] | null | null | null | defmodule Map do
@moduledoc """
Maps are the "go to" key-value data structure in Elixir.
Maps can be created with the `%{}` syntax, and key-value pairs can be
expressed as `key => value`:
iex> %{}
%{}
iex> %{"one" => :two, 3 => "four"}
%{3 => "four", "one" => :two}
Key-value pairs in a map do not follow any order (that's why the printed map
in the example above has a different order than the map that was created).
Maps do not impose any restriction on the key type: anything can be a key in a
map. As a key-value structure, maps do not allow duplicated keys. Keys are
compared using the exact-equality operator (`===/2`). If colliding keys are defined
in a map literal, the last one prevails.
When the key in a key-value pair is an atom, the `key: value` shorthand syntax
can be used (as in many other special forms), provided key-value pairs are put at
the end:
iex> %{"hello" => "world", a: 1, b: 2}
%{:a => 1, :b => 2, "hello" => "world"}
Keys in maps can be accessed through some of the functions in this module
(such as `Map.get/3` or `Map.fetch/2`) or through the `map[]` syntax provided
by the `Access` module:
iex> map = %{a: 1, b: 2}
iex> Map.fetch(map, :a)
{:ok, 1}
iex> map[:b]
2
iex> map["non_existing_key"]
nil
For accessing atom keys, one may also `map.key`. Note that while `map[key]` will
return `nil` if `map` doesn't contain `key`, `map.key` will raise if `map` doesn't
contain the key `:key`.
iex> map = %{foo: "bar", baz: "bong"}
iex> map.foo
"bar"
iex> map.non_existing_key
** (KeyError) key :non_existing_key not found in: %{baz: "bong", foo: "bar"}
The two syntaxes for accessing keys reveal the dual nature of maps. The `map[key]`
syntax is used for dynamically created maps that may have any key, of any type.
`map.key` is used with maps that hold a predetermined set of atoms keys, which are
expected to always be present. Structs, defined via `defstruct/1`, are one example
of such "static maps", where the keys can also be checked during compile time.
Maps can be pattern matched on. When a map is on the left-hand side of a
pattern match, it will match if the map on the right-hand side contains the
keys on the left-hand side and their values match the ones on the left-hand
side. This means that an empty map matches every map.
iex> %{} = %{foo: "bar"}
%{foo: "bar"}
iex> %{a: a} = %{:a => 1, "b" => 2, [:c, :e, :e] => 3}
iex> a
1
iex> %{:c => 3} = %{:a => 1, 2 => :b}
** (MatchError) no match of right hand side value: %{2 => :b, :a => 1}
Variables can be used as map keys both when writing map literals as well as
when matching:
iex> n = 1
1
iex> %{n => :one}
%{1 => :one}
iex> %{^n => :one} = %{1 => :one, 2 => :two, 3 => :three}
%{1 => :one, 2 => :two, 3 => :three}
Maps also support a specific update syntax to update the value stored under
*existing* atom keys:
iex> map = %{one: 1, two: 2}
iex> %{map | one: "one"}
%{one: "one", two: 2}
iex> %{map | three: 3}
** (KeyError) key :three not found
The functions in this module that need to find a specific key work in logarithmic time.
This means that the time it takes to find keys grows as the map grows, but it's not
directly proportional to the map size. In comparison to finding an element in a list,
it performs better because lists have a linear time complexity. Some functions,
such as `keys/1` and `values/1`, run in linear time because they need to get to every
element in the map.
Maps also implement the `Enumerable` protocol, so many functions to work with maps
are found in the `Enum` module. Additionally, the following functions for maps are
found in `Kernel`:
* `map_size/1`
"""
@type key :: any
@type value :: any
@compile {:inline, fetch: 2, fetch!: 2, get: 2, put: 3, delete: 2, has_key?: 2, replace!: 3}
@doc """
Returns all keys from `map`.
Inlined by the compiler.
## Examples
iex> Map.keys(%{a: 1, b: 2})
[:a, :b]
"""
@spec keys(map) :: [key]
defdelegate keys(map), to: :maps
@doc """
Returns all values from `map`.
Inlined by the compiler.
## Examples
iex> Map.values(%{a: 1, b: 2})
[1, 2]
"""
@spec values(map) :: [value]
defdelegate values(map), to: :maps
@doc """
Converts `map` to a list.
Each key-value pair in the map is converted to a two-element tuple `{key,
value}` in the resulting list.
Inlined by the compiler.
## Examples
iex> Map.to_list(%{a: 1})
[a: 1]
iex> Map.to_list(%{1 => 2})
[{1, 2}]
"""
@spec to_list(map) :: [{term, term}]
defdelegate to_list(map), to: :maps
@doc """
Returns a new empty map.
## Examples
iex> Map.new()
%{}
"""
@spec new :: map
def new, do: %{}
@doc """
Creates a map from an `enumerable`.
Duplicated keys are removed; the latest one prevails.
## Examples
iex> Map.new([{:b, 1}, {:a, 2}])
%{a: 2, b: 1}
iex> Map.new(a: 1, a: 2, a: 3)
%{a: 3}
"""
@spec new(Enumerable.t()) :: map
def new(enumerable)
def new(list) when is_list(list), do: :maps.from_list(list)
def new(%_{} = struct), do: new_from_enum(struct)
def new(%{} = map), do: map
def new(enum), do: new_from_enum(enum)
defp new_from_enum(enumerable) do
enumerable
|> Enum.to_list()
|> :maps.from_list()
end
@doc """
Creates a map from an `enumerable` via the given transformation function.
Duplicated keys are removed; the latest one prevails.
## Examples
iex> Map.new([:a, :b], fn x -> {x, x} end)
%{a: :a, b: :b}
"""
@spec new(Enumerable.t(), (term -> {key, value})) :: map
def new(enumerable, transform) when is_function(transform, 1) do
enumerable
|> Enum.to_list()
|> new_transform(transform, [])
end
defp new_transform([], _fun, acc) do
acc
|> :lists.reverse()
|> :maps.from_list()
end
defp new_transform([element | rest], fun, acc) do
new_transform(rest, fun, [fun.(element) | acc])
end
@doc """
Returns whether the given `key` exists in the given `map`.
Inlined by the compiler.
## Examples
iex> Map.has_key?(%{a: 1}, :a)
true
iex> Map.has_key?(%{a: 1}, :b)
false
"""
@spec has_key?(map, key) :: boolean
def has_key?(map, key), do: :maps.is_key(key, map)
@doc """
Fetches the value for a specific `key` in the given `map`.
If `map` contains the given `key` with value `value`, then `{:ok, value}` is
returned. If `map` doesn't contain `key`, `:error` is returned.
Inlined by the compiler.
## Examples
iex> Map.fetch(%{a: 1}, :a)
{:ok, 1}
iex> Map.fetch(%{a: 1}, :b)
:error
"""
@spec fetch(map, key) :: {:ok, value} | :error
def fetch(map, key), do: :maps.find(key, map)
@doc """
Fetches the value for a specific `key` in the given `map`, erroring out if
`map` doesn't contain `key`.
If `map` contains the given `key`, the corresponding value is returned. If
`map` doesn't contain `key`, a `KeyError` exception is raised.
Inlined by the compiler.
## Examples
iex> Map.fetch!(%{a: 1}, :a)
1
iex> Map.fetch!(%{a: 1}, :b)
** (KeyError) key :b not found in: %{a: 1}
"""
@spec fetch!(map, key) :: value
def fetch!(map, key) do
:maps.get(key, map)
end
@doc """
Puts the given `value` under `key` unless the entry `key`
already exists in `map`.
## Examples
iex> Map.put_new(%{a: 1}, :b, 2)
%{a: 1, b: 2}
iex> Map.put_new(%{a: 1, b: 2}, :a, 3)
%{a: 1, b: 2}
"""
@spec put_new(map, key, value) :: map
def put_new(map, key, value) do
case map do
%{^key => _value} ->
map
%{} ->
put(map, key, value)
other ->
:erlang.error({:badmap, other})
end
end
@doc false
@deprecated "Use Map.fetch/2 + Map.put/3 instead"
def replace(map, key, value) do
case map do
%{^key => _value} ->
put(map, key, value)
%{} ->
map
other ->
:erlang.error({:badmap, other})
end
end
@doc """
Alters the value stored under `key` to `value`, but only
if the entry `key` already exists in `map`.
If `key` is not present in `map`, a `KeyError` exception is raised.
Inlined by the compiler.
## Examples
iex> Map.replace!(%{a: 1, b: 2}, :a, 3)
%{a: 3, b: 2}
iex> Map.replace!(%{a: 1}, :b, 2)
** (KeyError) key :b not found in: %{a: 1}
"""
@doc since: "1.5.0"
@spec replace!(map, key, value) :: map
def replace!(map, key, value) do
:maps.update(key, value, map)
end
@doc """
Evaluates `fun` and puts the result under `key`
in `map` unless `key` is already present.
This function is useful in case you want to compute the value to put under
`key` only if `key` is not already present (e.g., the value is expensive to
calculate or generally difficult to setup and teardown again).
## Examples
iex> map = %{a: 1}
iex> fun = fn ->
...> # some expensive operation here
...> 3
...> end
iex> Map.put_new_lazy(map, :a, fun)
%{a: 1}
iex> Map.put_new_lazy(map, :b, fun)
%{a: 1, b: 3}
"""
@spec put_new_lazy(map, key, (() -> value)) :: map
def put_new_lazy(map, key, fun) when is_function(fun, 0) do
case map do
%{^key => _value} ->
map
%{} ->
put(map, key, fun.())
other ->
:erlang.error({:badmap, other})
end
end
@doc """
Returns a new map with all the key-value pairs in `map` where the key
is in `keys`.
If `keys` contains keys that are not in `map`, they're simply ignored.
## Examples
iex> Map.take(%{a: 1, b: 2, c: 3}, [:a, :c, :e])
%{a: 1, c: 3}
"""
@spec take(map, [key]) :: map
def take(map, keys)
def take(map, keys) when is_map(map) and is_list(keys) do
take(keys, map, _acc = [])
end
def take(map, keys) when is_map(map) do
IO.warn(
"Map.take/2 with an Enumerable of keys that is not a list is deprecated. " <>
" Use a list of keys instead."
)
take(map, Enum.to_list(keys))
end
def take(non_map, _keys) do
:erlang.error({:badmap, non_map})
end
defp take([], _map, acc) do
:maps.from_list(acc)
end
defp take([key | rest], map, acc) do
acc =
case map do
%{^key => value} -> [{key, value} | acc]
%{} -> acc
end
take(rest, map, acc)
end
@doc """
Gets the value for a specific `key` in `map`.
If `key` is present in `map` with value `value`, then `value` is
returned. Otherwise, `default` is returned.
If `default` is not provided, `nil` is used.
## Examples
iex> Map.get(%{}, :a)
nil
iex> Map.get(%{a: 1}, :a)
1
iex> Map.get(%{a: 1}, :b)
nil
iex> Map.get(%{a: 1}, :b, 3)
3
"""
@spec get(map, key, value) :: value
def get(map, key, default \\ nil) do
case map do
%{^key => value} ->
value
%{} ->
default
other ->
:erlang.error({:badmap, other}, [map, key, default])
end
end
@doc """
Gets the value for a specific `key` in `map`.
If `key` is present in `map` with value `value`, then `value` is
returned. Otherwise, `fun` is evaluated and its result is returned.
This is useful if the default value is very expensive to calculate or
generally difficult to setup and teardown again.
## Examples
iex> map = %{a: 1}
iex> fun = fn ->
...> # some expensive operation here
...> 13
...> end
iex> Map.get_lazy(map, :a, fun)
1
iex> Map.get_lazy(map, :b, fun)
13
"""
@spec get_lazy(map, key, (() -> value)) :: value
def get_lazy(map, key, fun) when is_function(fun, 0) do
case map do
%{^key => value} ->
value
%{} ->
fun.()
other ->
:erlang.error({:badmap, other}, [map, key, fun])
end
end
@doc """
Puts the given `value` under `key` in `map`.
Inlined by the compiler.
## Examples
iex> Map.put(%{a: 1}, :b, 2)
%{a: 1, b: 2}
iex> Map.put(%{a: 1, b: 2}, :a, 3)
%{a: 3, b: 2}
"""
@spec put(map, key, value) :: map
def put(map, key, value) do
:maps.put(key, value, map)
end
@doc """
Deletes the entry in `map` for a specific `key`.
If the `key` does not exist, returns `map` unchanged.
Inlined by the compiler.
## Examples
iex> Map.delete(%{a: 1, b: 2}, :a)
%{b: 2}
iex> Map.delete(%{b: 2}, :a)
%{b: 2}
"""
@spec delete(map, key) :: map
def delete(map, key), do: :maps.remove(key, map)
@doc """
Merges two maps into one.
All keys in `map2` will be added to `map1`, overriding any existing one
(i.e., the keys in `map2` "have precedence" over the ones in `map1`).
If you have a struct and you would like to merge a set of keys into the
struct, do not use this function, as it would merge all keys on the right
side into the struct, even if the key is not part of the struct. Instead,
use `Kernel.struct/2`.
Inlined by the compiler.
## Examples
iex> Map.merge(%{a: 1, b: 2}, %{a: 3, d: 4})
%{a: 3, b: 2, d: 4}
"""
@spec merge(map, map) :: map
defdelegate merge(map1, map2), to: :maps
@doc """
Merges two maps into one, resolving conflicts through the given `fun`.
All keys in `map2` will be added to `map1`. The given function will be invoked
when there are duplicate keys; its arguments are `key` (the duplicate key),
`value1` (the value of `key` in `map1`), and `value2` (the value of `key` in
`map2`). The value returned by `fun` is used as the value under `key` in
the resulting map.
## Examples
iex> Map.merge(%{a: 1, b: 2}, %{a: 3, d: 4}, fn _k, v1, v2 ->
...> v1 + v2
...> end)
%{a: 4, b: 2, d: 4}
"""
@spec merge(map, map, (key, value, value -> value)) :: map
def merge(map1, map2, fun) when is_function(fun, 3) do
if map_size(map1) > map_size(map2) do
folder = fn key, val2, acc ->
update(acc, key, val2, fn val1 -> fun.(key, val1, val2) end)
end
:maps.fold(folder, map1, map2)
else
folder = fn key, val2, acc ->
update(acc, key, val2, fn val1 -> fun.(key, val2, val1) end)
end
:maps.fold(folder, map2, map1)
end
end
@doc """
Updates the `key` in `map` with the given function.
If `key` is present in `map` with value `value`, `fun` is invoked with
argument `value` and its result is used as the new value of `key`. If `key` is
not present in `map`, `initial` is inserted as the value of `key`. The initial
value will not be passed through the update function.
## Examples
iex> Map.update(%{a: 1}, :a, 13, &(&1 * 2))
%{a: 2}
iex> Map.update(%{a: 1}, :b, 11, &(&1 * 2))
%{a: 1, b: 11}
"""
@spec update(map, key, value, (value -> value)) :: map
def update(map, key, initial, fun) when is_function(fun, 1) do
case map do
%{^key => value} ->
put(map, key, fun.(value))
%{} ->
put(map, key, initial)
other ->
:erlang.error({:badmap, other}, [map, key, initial, fun])
end
end
@doc """
Returns and removes the value associated with `key` in `map`.
If `key` is present in `map` with value `value`, `{value, new_map}` is
returned where `new_map` is the result of removing `key` from `map`. If `key`
is not present in `map`, `{default, map}` is returned.
## Examples
iex> Map.pop(%{a: 1}, :a)
{1, %{}}
iex> Map.pop(%{a: 1}, :b)
{nil, %{a: 1}}
iex> Map.pop(%{a: 1}, :b, 3)
{3, %{a: 1}}
"""
@spec pop(map, key, value) :: {value, map}
def pop(map, key, default \\ nil) do
case :maps.take(key, map) do
{_, _} = tuple -> tuple
:error -> {default, map}
end
end
@doc """
Lazily returns and removes the value associated with `key` in `map`.
If `key` is present in `map` with value `value`, `{value, new_map}` is
returned where `new_map` is the result of removing `key` from `map`. If `key`
is not present in `map`, `{fun_result, map}` is returned, where `fun_result`
is the result of applying `fun`.
This is useful if the default value is very expensive to calculate or
generally difficult to setup and teardown again.
## Examples
iex> map = %{a: 1}
iex> fun = fn ->
...> # some expensive operation here
...> 13
...> end
iex> Map.pop_lazy(map, :a, fun)
{1, %{}}
iex> Map.pop_lazy(map, :b, fun)
{13, %{a: 1}}
"""
@spec pop_lazy(map, key, (() -> value)) :: {value, map}
def pop_lazy(map, key, fun) when is_function(fun, 0) do
case map do
%{^key => value} ->
{value, delete(map, key)}
%{} ->
{fun.(), map}
other ->
:erlang.error({:badmap, other}, [map, key, fun])
end
end
@doc """
Drops the given `keys` from `map`.
If `keys` contains keys that are not in `map`, they're simply ignored.
## Examples
iex> Map.drop(%{a: 1, b: 2, c: 3}, [:b, :d])
%{a: 1, c: 3}
"""
@spec drop(map, [key]) :: map
def drop(map, keys)
def drop(map, keys) when is_map(map) and is_list(keys) do
drop_keys(keys, map)
end
def drop(map, keys) when is_map(map) do
IO.warn(
"Map.drop/2 with an Enumerable of keys that is not a list is deprecated. " <>
" Use a list of keys instead."
)
drop(map, Enum.to_list(keys))
end
def drop(non_map, keys) do
:erlang.error({:badmap, non_map}, [non_map, keys])
end
defp drop_keys([], acc), do: acc
defp drop_keys([key | rest], acc) do
drop_keys(rest, delete(acc, key))
end
@doc """
Takes all entries corresponding to the given `keys` in `map` and extracts
them into a separate map.
Returns a tuple with the new map and the old map with removed keys.
Keys for which there are no entries in `map` are ignored.
## Examples
iex> Map.split(%{a: 1, b: 2, c: 3}, [:a, :c, :e])
{%{a: 1, c: 3}, %{b: 2}}
"""
@spec split(map, [key]) :: {map, map}
def split(map, keys)
def split(map, keys) when is_map(map) and is_list(keys) do
split(keys, [], map)
end
def split(map, keys) when is_map(map) do
IO.warn(
"Map.split/2 with an Enumerable of keys that is not a list is deprecated. " <>
" Use a list of keys instead."
)
split(map, Enum.to_list(keys))
end
def split(non_map, keys) do
:erlang.error({:badmap, non_map}, [non_map, keys])
end
defp split([], included, excluded) do
{:maps.from_list(included), excluded}
end
defp split([key | rest], included, excluded) do
case excluded do
%{^key => value} ->
split(rest, [{key, value} | included], delete(excluded, key))
_other ->
split(rest, included, excluded)
end
end
@doc """
Updates `key` with the given function.
If `key` is present in `map` with value `value`, `fun` is invoked with
argument `value` and its result is used as the new value of `key`. If `key` is
not present in `map`, a `KeyError` exception is raised.
## Examples
iex> Map.update!(%{a: 1}, :a, &(&1 * 2))
%{a: 2}
iex> Map.update!(%{a: 1}, :b, &(&1 * 2))
** (KeyError) key :b not found in: %{a: 1}
"""
@spec update!(map, key, (value -> value)) :: map
def update!(map, key, fun) when is_function(fun, 1) do
value = fetch!(map, key)
put(map, key, fun.(value))
end
@doc """
Gets the value from `key` and updates it, all in one pass.
`fun` is called with the current value under `key` in `map` (or `nil` if `key`
is not present in `map`) and must return a two-element tuple: the "get" value
(the retrieved value, which can be operated on before being returned) and the
new value to be stored under `key` in the resulting new map. `fun` may also
return `:pop`, which means the current value shall be removed from `map` and
returned (making this function behave like `Map.pop(map, key)`).
The returned value is a tuple with the "get" value returned by
`fun` and a new map with the updated value under `key`.
## Examples
iex> Map.get_and_update(%{a: 1}, :a, fn current_value ->
...> {current_value, "new value!"}
...> end)
{1, %{a: "new value!"}}
iex> Map.get_and_update(%{a: 1}, :b, fn current_value ->
...> {current_value, "new value!"}
...> end)
{nil, %{b: "new value!", a: 1}}
iex> Map.get_and_update(%{a: 1}, :a, fn _ -> :pop end)
{1, %{}}
iex> Map.get_and_update(%{a: 1}, :b, fn _ -> :pop end)
{nil, %{a: 1}}
"""
@spec get_and_update(map, key, (value -> {get, value} | :pop)) :: {get, map} when get: term
def get_and_update(map, key, fun) when is_function(fun, 1) do
current = get(map, key)
case fun.(current) do
{get, update} ->
{get, put(map, key, update)}
:pop ->
{current, delete(map, key)}
other ->
raise "the given function must return a two-element tuple or :pop, got: #{inspect(other)}"
end
end
@doc """
Gets the value from `key` and updates it. Raises if there is no `key`.
Behaves exactly like `get_and_update/3`, but raises a `KeyError` exception if
`key` is not present in `map`.
## Examples
iex> Map.get_and_update!(%{a: 1}, :a, fn current_value ->
...> {current_value, "new value!"}
...> end)
{1, %{a: "new value!"}}
iex> Map.get_and_update!(%{a: 1}, :b, fn current_value ->
...> {current_value, "new value!"}
...> end)
** (KeyError) key :b not found in: %{a: 1}
iex> Map.get_and_update!(%{a: 1}, :a, fn _ ->
...> :pop
...> end)
{1, %{}}
"""
@spec get_and_update!(map, key, (value -> {get, value} | :pop)) :: {get, map}
when get: term
def get_and_update!(map, key, fun) when is_function(fun, 1) do
value = fetch!(map, key)
case fun.(value) do
{get, update} ->
{get, put(map, key, update)}
:pop ->
{value, delete(map, key)}
other ->
raise "the given function must return a two-element tuple or :pop, got: #{inspect(other)}"
end
end
@doc """
Converts a `struct` to map.
It accepts the struct module or a struct itself and
simply removes the `__struct__` field from the given struct
or from a new struct generated from the given module.
## Example
defmodule User do
defstruct [:name]
end
Map.from_struct(User)
#=> %{name: nil}
Map.from_struct(%User{name: "john"})
#=> %{name: "john"}
"""
@spec from_struct(atom | struct) :: map
def from_struct(struct) when is_atom(struct) do
delete(struct.__struct__(), :__struct__)
end
def from_struct(%_{} = struct) do
delete(struct, :__struct__)
end
@doc """
Checks if two maps are equal.
Two maps are considered to be equal if they contain
the same keys and those keys contain the same values.
## Examples
iex> Map.equal?(%{a: 1, b: 2}, %{b: 2, a: 1})
true
iex> Map.equal?(%{a: 1, b: 2}, %{b: 1, a: 2})
false
"""
@spec equal?(map, map) :: boolean
def equal?(map1, map2)
def equal?(%{} = map1, %{} = map2), do: map1 === map2
def equal?(%{} = map1, map2), do: :erlang.error({:badmap, map2}, [map1, map2])
def equal?(term, other), do: :erlang.error({:badmap, term}, [term, other])
@doc false
@deprecated "Use Kernel.map_size/1 instead"
def size(map) do
map_size(map)
end
end
| 25.550054 | 98 | 0.576424 |
ff234d114ea200ed7dbf875d386e1510bfcac1fa | 222 | exs | Elixir | test/test_helper.exs | keichan34/phoenix_exfile_test_app | 63de22ab04a61ef7f13a53f2b34d3c752a1def7a | [
"MIT"
] | 1 | 2016-04-19T11:56:32.000Z | 2016-04-19T11:56:32.000Z | test/test_helper.exs | keichan34/phoenix_exfile_test_app | 63de22ab04a61ef7f13a53f2b34d3c752a1def7a | [
"MIT"
] | 1 | 2016-08-05T07:52:34.000Z | 2016-09-02T03:45:03.000Z | test/test_helper.exs | keichan34/phoenix_exfile_test_app | 63de22ab04a61ef7f13a53f2b34d3c752a1def7a | [
"MIT"
] | null | null | null | ExUnit.start
Mix.Task.run "ecto.create", ~w(-r PhoenixExfileTestApp.Repo --quiet)
Mix.Task.run "ecto.migrate", ~w(-r PhoenixExfileTestApp.Repo --quiet)
Ecto.Adapters.SQL.begin_test_transaction(PhoenixExfileTestApp.Repo)
| 31.714286 | 69 | 0.788288 |
ff2369de970251b413f3d4b2ac87c3febb6cc25e | 1,426 | exs | Elixir | test/branch_cutter/pull_requests_test.exs | smaximov/branch_cutter | eb750db1fcc9715ab7bbecadd2ccd3368b41dc81 | [
"MIT"
] | null | null | null | test/branch_cutter/pull_requests_test.exs | smaximov/branch_cutter | eb750db1fcc9715ab7bbecadd2ccd3368b41dc81 | [
"MIT"
] | null | null | null | test/branch_cutter/pull_requests_test.exs | smaximov/branch_cutter | eb750db1fcc9715ab7bbecadd2ccd3368b41dc81 | [
"MIT"
] | null | null | null | defmodule BranchCutter.PullRequestsTest do
use BranchCutter.RepoCase, async: true
alias BranchCutter.PullRequests
alias BranchCutter.Schema.PullRequest
describe "insert/3" do
import PullRequests, only: [insert: 3, count: 2]
test "it is successful with valid values and duplicates" do
repo = "repo"
branch = "branch"
number = 42
assert {:ok, %PullRequest{repo: ^repo, branch: ^branch, number: ^number}} =
insert(repo, branch, number)
assert count(repo, branch) == 1
assert {:ok, %PullRequest{repo: ^repo, branch: ^branch, number: ^number}} =
insert(repo, branch, number)
assert count(repo, branch) == 1
end
test "it fails with blank values" do
assert {:error, %Ecto.Changeset{} = changeset} = insert("", "", nil)
assert %{
repo: ["can't be blank"],
branch: ["can't be blank"],
number: ["can't be blank"]
} = errors_on(changeset)
end
end
describe "delete/3" do
import PullRequests, only: [insert: 3, count: 2, delete: 3]
test "it deletes a pull request" do
repo = "repo"
branch = "branch"
number = 42
assert {:ok, _} = insert(repo, branch, number)
assert {1, nil} = delete(repo, branch, number)
assert count(repo, branch) == 0
assert {0, nil} = delete(repo, branch, number)
end
end
end
| 27.423077 | 81 | 0.591865 |
ff236cdb0870e54061856d7faa2b29b2746a4521 | 1,967 | exs | Elixir | config/dev.exs | ilkka/phoenix-elm-graphql-starter | fd88adf0e471eb97feb98a32026c2a1581e55490 | [
"Apache-2.0"
] | null | null | null | config/dev.exs | ilkka/phoenix-elm-graphql-starter | fd88adf0e471eb97feb98a32026c2a1581e55490 | [
"Apache-2.0"
] | null | null | null | config/dev.exs | ilkka/phoenix-elm-graphql-starter | fd88adf0e471eb97feb98a32026c2a1581e55490 | [
"Apache-2.0"
] | null | null | null | use Mix.Config
# For development, we disable any cache and enable
# debugging and code reloading.
#
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with brunch.io to recompile .js and .css sources.
config :phelmx, PhelmxWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../assets", __DIR__)
]
]
# ## SSL Support
#
# In order to use HTTPS in development, a self-signed
# certificate can be generated by running the following
# command from your terminal:
#
# openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout priv/server.key -out priv/server.pem
#
# The `http:` config above can be replaced with:
#
# https: [port: 4000, keyfile: "priv/server.key", certfile: "priv/server.pem"],
#
# If desired, both `http:` and `https:` keys can be
# configured to run both http and https servers on
# different ports.
# Watch static and templates for browser reloading.
config :phelmx, PhelmxWeb.Endpoint,
live_reload: [
patterns: [
~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
~r{priv/gettext/.*(po)$},
~r{lib/phelmx_web/views/.*(ex)$},
~r{lib/phelmx_web/templates/.*(eex)$}
]
]
# Do not include metadata nor timestamps in development logs
config :logger, :console, format: "[$level] $message\n"
# Set a higher stacktrace during development. Avoid configuring such
# in production as building large stacktraces may be expensive.
config :phoenix, :stacktrace_depth, 20
# Configure your database
config :phelmx, Phelmx.Repo,
adapter: Ecto.Adapters.Postgres,
username: "phelmx",
password: "phelmx",
database: "phelmx_dev",
hostname: "localhost",
pool_size: 10
| 29.80303 | 170 | 0.692425 |
ff236cdfa29ea29606cf8f269f5f134f3f6d13c4 | 1,802 | ex | Elixir | test/support/model_case.ex | jwarwick/class_list | 05ac775e7b5d42f258024db361a9de1aeed71c73 | [
"MIT"
] | null | null | null | test/support/model_case.ex | jwarwick/class_list | 05ac775e7b5d42f258024db361a9de1aeed71c73 | [
"MIT"
] | null | null | null | test/support/model_case.ex | jwarwick/class_list | 05ac775e7b5d42f258024db361a9de1aeed71c73 | [
"MIT"
] | null | null | null | defmodule ClassList.ModelCase do
@moduledoc """
This module defines the test case to be used by
model tests.
You may define functions here to be used as helpers in
your model tests. See `errors_on/2`'s definition as reference.
Finally, if the test case interacts with the database,
it cannot be async. For this reason, every test runs
inside a transaction which is reset at the beginning
of the test unless the test case is marked as async.
"""
use ExUnit.CaseTemplate
using do
quote do
alias ClassList.Repo
import Ecto
import Ecto.Changeset
import Ecto.Query
import ClassList.ModelCase
end
end
setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(ClassList.Repo)
unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(ClassList.Repo, {:shared, self()})
end
:ok
end
@doc """
Helper for returning list of errors in a struct when given certain data.
## Examples
Given a User schema that lists `:name` as a required field and validates
`:password` to be safe, it would return:
iex> errors_on(%User{}, %{password: "password"})
[password: "is unsafe", name: "is blank"]
You could then write your assertion like:
assert {:password, "is unsafe"} in errors_on(%User{}, %{password: "password"})
You can also create the changeset manually and retrieve the errors
field directly:
iex> changeset = User.changeset(%User{}, password: "password")
iex> {:password, "is unsafe"} in changeset.errors
true
"""
def errors_on(struct, data) do
struct.__struct__.changeset(struct, data)
|> Ecto.Changeset.traverse_errors(&ClassList.ErrorHelpers.translate_error/1)
|> Enum.flat_map(fn {key, errors} -> for msg <- errors, do: {key, msg} end)
end
end
| 27.30303 | 84 | 0.687014 |
ff23734a4f43d3c84b302a88cc0eeb9f8ceb0854 | 1,141 | exs | Elixir | config/config.exs | robosseum/client-elixir | 65efed560bc8aa79c866db0efcf6463be28527f0 | [
"MIT"
] | null | null | null | config/config.exs | robosseum/client-elixir | 65efed560bc8aa79c866db0efcf6463be28527f0 | [
"MIT"
] | null | null | null | config/config.exs | robosseum/client-elixir | 65efed560bc8aa79c866db0efcf6463be28527f0 | [
"MIT"
] | null | null | null | # This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
# file won't be loaded nor affect the parent project. For this reason,
# if you want to provide default values for your application for
# 3rd-party users, it should be done in your "mix.exs" file.
# You can configure your application as:
#
# config :robosseum_client, key: :value
#
# and access this configuration in your application as:
#
# Application.get_env(:robosseum_client, :key)
#
# You can also configure a 3rd-party app:
#
# config :logger, level: :info
#
# It is also possible to import configuration files, relative to this
# directory. For example, you can emulate configuration per environment
# by uncommenting the line below and defining dev.exs, test.exs and such.
# Configuration from the imported file will override the ones defined
# here (which is why it is important to import them last).
#
# import_config "#{Mix.env}.exs"
| 36.806452 | 73 | 0.755478 |
ff23afc408114d01e24357ea98aad5e1797782ac | 1,380 | ex | Elixir | clients/compute/lib/google_api/compute/v1/model/forwarding_rule_reference.ex | pojiro/elixir-google-api | 928496a017d3875a1929c6809d9221d79404b910 | [
"Apache-2.0"
] | 1 | 2021-12-20T03:40:53.000Z | 2021-12-20T03:40:53.000Z | clients/compute/lib/google_api/compute/v1/model/forwarding_rule_reference.ex | pojiro/elixir-google-api | 928496a017d3875a1929c6809d9221d79404b910 | [
"Apache-2.0"
] | 1 | 2020-08-18T00:11:23.000Z | 2020-08-18T00:44:16.000Z | clients/compute/lib/google_api/compute/v1/model/forwarding_rule_reference.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.Compute.V1.Model.ForwardingRuleReference do
@moduledoc """
## Attributes
* `forwardingRule` (*type:* `String.t`, *default:* `nil`) -
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:forwardingRule => String.t() | nil
}
field(:forwardingRule)
end
defimpl Poison.Decoder, for: GoogleApi.Compute.V1.Model.ForwardingRuleReference do
def decode(value, options) do
GoogleApi.Compute.V1.Model.ForwardingRuleReference.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.Compute.V1.Model.ForwardingRuleReference do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 29.361702 | 82 | 0.73913 |
ff23c026fcbe3c6d85cc71af772d364a6bb166c3 | 1,007 | exs | Elixir | priv/repo/migrations/20210221114143_add_chat_tokens.exs | Megami-Studios/glimesh.tv | 57dde3a328fabdcc3305be48ae1b82df27b83c9b | [
"MIT"
] | 328 | 2020-07-23T22:13:49.000Z | 2022-03-31T21:22:28.000Z | priv/repo/migrations/20210221114143_add_chat_tokens.exs | Megami-Studios/glimesh.tv | 57dde3a328fabdcc3305be48ae1b82df27b83c9b | [
"MIT"
] | 362 | 2020-07-23T22:38:38.000Z | 2022-03-24T02:11:16.000Z | priv/repo/migrations/20210221114143_add_chat_tokens.exs | Megami-Studios/glimesh.tv | 57dde3a328fabdcc3305be48ae1b82df27b83c9b | [
"MIT"
] | 72 | 2020-07-23T22:50:46.000Z | 2022-02-02T11:59:32.000Z | defmodule Glimesh.Repo.Migrations.AddChatTokens do
use Ecto.Migration
import Ecto.Query
def change do
alter table(:chat_messages) do
add :tokens, {:array, :map}, default: []
end
flush()
channels =
Glimesh.Repo.all(
from(u in "channels",
select: %Glimesh.Streams.Channel{id: u.id, disable_hyperlinks: u.disable_hyperlinks}
)
)
Enum.each(channels, fn channel ->
chat_messages =
Glimesh.Repo.all(
from(m in Glimesh.Chat.ChatMessage,
where: m.channel_id == ^channel.id,
order_by: [desc: :inserted_at]
)
)
config = Glimesh.Chat.get_chat_parser_config(channel)
Enum.each(chat_messages, fn msg ->
tokens = Glimesh.Chat.Parser.parse(msg.message, config)
changeset =
msg
|> Ecto.Changeset.change()
|> Ecto.Changeset.put_embed(:tokens, tokens)
Glimesh.Repo.update!(changeset)
end)
end)
end
end
| 22.886364 | 94 | 0.593843 |
ff23cdeb1973f45a9f9cf08c5fa59b9e0841aa56 | 1,605 | ex | Elixir | lib/sftp_client/key_provider.ex | zoten/sftp_client | 814d06e36915f60bf98149d790051d03bee189f5 | [
"MIT"
] | null | null | null | lib/sftp_client/key_provider.ex | zoten/sftp_client | 814d06e36915f60bf98149d790051d03bee189f5 | [
"MIT"
] | null | null | null | lib/sftp_client/key_provider.ex | zoten/sftp_client | 814d06e36915f60bf98149d790051d03bee189f5 | [
"MIT"
] | null | null | null | defmodule SFTPClient.KeyProvider do
@moduledoc """
A provider that loads keys for authentication from the given location.
Implements the `:ssh_client_key_api` behavior.
"""
@behaviour :ssh_client_key_api
require Logger
@impl true
defdelegate add_host_key(host, public_key, opts), to: :ssh_file
@impl true
defdelegate is_host_key(key, host, algorithm, opts), to: :ssh_file
@impl true
def user_key(algorithm, opts) do
provider_opts = opts[:key_cb_private]
case provider_opts[:private_key_path] do
nil ->
:ssh_file.user_key(algorithm, opts)
path ->
decode_private_key(path, provider_opts[:private_key_pass_phrase])
end
end
defp decode_private_key(path, pass_phrase) do
full_path = Path.expand(path)
case File.read(full_path) do
{:ok, key_contents} ->
key_contents
|> :public_key.pem_decode()
|> List.first()
|> case do
nil ->
Logger.error("Unable to decode key: #{path}")
{:error, 'Unable to decode key'}
{_type, _key, :not_encrypted} = entry ->
{:ok, :public_key.pem_entry_decode(entry)}
_entry when is_nil(pass_phrase) ->
Logger.error("Passphrase required for key: #{path}")
{:error, 'Passphrase required'}
entry ->
pass_phrase = String.to_charlist(pass_phrase)
{:ok, :public_key.pem_entry_decode(entry, pass_phrase)}
end
_ ->
Logger.error("Specified key not found: #{full_path}")
{:error, 'Key not found'}
end
end
end
| 26.311475 | 73 | 0.627414 |
ff23fee7960ceb4062794633e5810be6d0d76d96 | 485 | exs | Elixir | test/bencode/encode_eqc.exs | olof/elixir-bencode | e9bd497f22ef5f4c481378ca1efbfde4a453b472 | [
"Apache-2.0"
] | 19 | 2015-12-05T13:50:41.000Z | 2022-01-31T20:20:48.000Z | test/bencode/encode_eqc.exs | olof/elixir-bencode | e9bd497f22ef5f4c481378ca1efbfde4a453b472 | [
"Apache-2.0"
] | 7 | 2016-02-24T13:46:42.000Z | 2020-03-23T01:03:26.000Z | test/bencode/encode_eqc.exs | olof/elixir-bencode | e9bd497f22ef5f4c481378ca1efbfde4a453b472 | [
"Apache-2.0"
] | 5 | 2016-02-24T13:18:29.000Z | 2019-09-09T08:59:52.000Z | defmodule Bencode.EncodeEQC do
use ExUnit.Case, async: true
use EQC.ExUnit
# numbers
property "encode numbers" do
forall input <- int() do
ensure Bencode.encode!(input) == "i#{input}e"
end
end
property "encode strings" do
forall input <- utf8() do
ensure Bencode.encode!(input) == "#{byte_size input}:#{input}"
end
end
# figure out a way to model lists and property test them
# figure out a way to model maps and property test them
end
| 23.095238 | 68 | 0.665979 |
ff2428d16e6bbbd757b47c6a23f1418320805567 | 367 | ex | Elixir | lib/bitcrowd_ecto.ex | bitcrowd/bitcrowd_ecto | 6e2d41d7dbe1fa1398b545c12385cde2db94285c | [
"Apache-2.0"
] | 2 | 2022-01-11T08:03:49.000Z | 2022-02-11T10:25:30.000Z | lib/bitcrowd_ecto.ex | bitcrowd/bitcrowd_ecto | 6e2d41d7dbe1fa1398b545c12385cde2db94285c | [
"Apache-2.0"
] | 3 | 2022-02-03T21:28:14.000Z | 2022-03-25T09:03:15.000Z | lib/bitcrowd_ecto.ex | bitcrowd/bitcrowd_ecto | 6e2d41d7dbe1fa1398b545c12385cde2db94285c | [
"Apache-2.0"
] | null | null | null | # SPDX-License-Identifier: Apache-2.0
defmodule BitcrowdEcto do
@readme Path.join([__DIR__, "../README.md"])
@external_resource @readme
@moduledoc @readme
|> File.read!()
|> String.split("<!-- MDOC -->")
|> Enum.drop(1)
|> Enum.take_every(2)
|> Enum.join("\n")
@moduledoc since: "0.1.0"
end
| 22.9375 | 46 | 0.531335 |
ff24428997020a33c3a90ecd58c94c216f6a34e7 | 95 | exs | Elixir | test/conduit/plug/created_at_test.exs | log4b/conduit | 5ecf5aa0edd831f54c28d596f1cb2d414fc99c6e | [
"MIT"
] | 119 | 2016-11-21T13:19:22.000Z | 2021-11-07T17:29:05.000Z | test/conduit/plug/created_at_test.exs | log4b/conduit | 5ecf5aa0edd831f54c28d596f1cb2d414fc99c6e | [
"MIT"
] | 104 | 2018-02-02T20:42:46.000Z | 2021-08-03T05:36:09.000Z | test/conduit/plug/created_at_test.exs | log4b/conduit | 5ecf5aa0edd831f54c28d596f1cb2d414fc99c6e | [
"MIT"
] | 21 | 2018-08-03T02:38:21.000Z | 2022-03-16T18:26:58.000Z | defmodule Conduit.Plug.CreatedAtTest do
use ExUnit.Case
doctest Conduit.Plug.CreatedAt
end
| 19 | 39 | 0.821053 |
ff245e700039e6bb584feea4b5b559d94e2d3d62 | 32 | ex | Elixir | lib/badapi/tester.ex | fusillicode/badapi | ca00999bd1a33c1798d1965d56c6ad590631eef9 | [
"MIT"
] | null | null | null | lib/badapi/tester.ex | fusillicode/badapi | ca00999bd1a33c1798d1965d56c6ad590631eef9 | [
"MIT"
] | null | null | null | lib/badapi/tester.ex | fusillicode/badapi | ca00999bd1a33c1798d1965d56c6ad590631eef9 | [
"MIT"
] | null | null | null | defmodule Badapi.Tester do
end
| 8 | 26 | 0.8125 |
ff2513280dcd8d58be9ec351496b213bd3dc171a | 104 | exs | Elixir | test/schemas/previous_translation_test.exs | leonardocouy/accent | 29fb324395ff998cc5cdc6947c60070ffabe647c | [
"BSD-3-Clause"
] | null | null | null | test/schemas/previous_translation_test.exs | leonardocouy/accent | 29fb324395ff998cc5cdc6947c60070ffabe647c | [
"BSD-3-Clause"
] | null | null | null | test/schemas/previous_translation_test.exs | leonardocouy/accent | 29fb324395ff998cc5cdc6947c60070ffabe647c | [
"BSD-3-Clause"
] | null | null | null | defmodule AccentTest.PreviousTranslation do
use ExUnit.Case
doctest Accent.PreviousTranslation
end
| 17.333333 | 43 | 0.846154 |
ff25221003a2cad61eebe98f6df1477b98c407ff | 972 | ex | Elixir | lib/shenu/message/color.ex | jsdelivrbot/shenu | 98acf65b915b62528eccd824020e8007931ee01c | [
"MIT"
] | 3 | 2016-06-19T00:21:54.000Z | 2021-09-28T22:04:07.000Z | lib/shenu/message/color.ex | jsdelivrbot/shenu | 98acf65b915b62528eccd824020e8007931ee01c | [
"MIT"
] | null | null | null | lib/shenu/message/color.ex | jsdelivrbot/shenu | 98acf65b915b62528eccd824020e8007931ee01c | [
"MIT"
] | 1 | 2018-12-06T22:51:26.000Z | 2018-12-06T22:51:26.000Z | defmodule Shenu.Message.Color do
@moduledoc """
RGBA color
"""
use Shenu.Message
defmessage %{
type: "object",
properties: %{
r: %{
type: "integer",
minimum: 0,
maximum: 255,
default: 0
},
g: %{
type: "integer",
minimum: 0,
maximum: 255,
default: 0
},
b: %{
type: "integer",
minimum: 0,
maximum: 255,
default: 0
},
a: %{
type: "number",
minimum: 0.0,
maximum: 1.0,
default: 1.0
}
},
additionalProperties: false
}
end
defimpl Shenu.Message, for: Shenu.Message.Color do
def difference(m, m, _) do
0
end
def difference(a, b, :default) do
difference(a, b, :cie94)
end
def difference(a, b, :cie94) do
ColorUtils.distance(convert(a), convert(b))
end
defp convert(%{r: r, g: g, b: b}) do
%ColorUtils.RGB{red: r, green: g, blue: b}
end
end
| 17.672727 | 50 | 0.504115 |
ff252c31507575fa69baa2c7687304c6e36e2754 | 1,397 | exs | Elixir | test/helix/users/follows_test.exs | Eein/twitch-api | cc53145b8425f7f8d474e9f20f083ce6856f9d20 | [
"MIT"
] | 1 | 2020-02-04T18:38:59.000Z | 2020-02-04T18:38:59.000Z | test/helix/users/follows_test.exs | Eein/helix | cc53145b8425f7f8d474e9f20f083ce6856f9d20 | [
"MIT"
] | null | null | null | test/helix/users/follows_test.exs | Eein/helix | cc53145b8425f7f8d474e9f20f083ce6856f9d20 | [
"MIT"
] | null | null | null | defmodule TwitchApi.Helix.Users.FollowsTest do
use ExUnit.Case, async: true
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
doctest TwitchApi.Helix.Users.Follows
alias TwitchApi.Client
alias TwitchApi.Helix.Users.Follows
setup do
ExVCR.Config.filter_request_headers("Client-ID")
ExVCR.Config.filter_request_headers("Authorization")
{:ok, _token} = TwitchApi.TokenCache.get()
HTTPoison.start()
end
test "users-follows request returns HTTP 200" do
use_cassette "users/follows-to" do
client = Client.new()
res = Follows.get(client, %{to_id: "23161357"})
data = res.body["data"]
assert Enum.at(data, 0)["to_name"] == "LIRIK"
assert Enum.empty?(res.body["data"]) == false
end
end
test "users-follows request to and from returns HTTP 200" do
use_cassette "users/follows-to-and-from" do
client = Client.new()
res = Follows.get(client, %{from_id: "50400274", to_id: "23161357"})
data = res.body["data"]
assert Enum.at(data, 0)["to_name"] == "LIRIK"
assert Enum.empty?(res.body["data"]) == false
end
end
test "users-follows request without any id returns bad request" do
use_cassette "users/follows-bad-req" do
client = Client.new()
message = ~r/^This endpoint requires from_id/
assert_raise RuntimeError, message, fn -> Follows.get(client) end
end
end
end
| 31.044444 | 74 | 0.675734 |
ff253781a8af82c461375aa86219900f09195c24 | 40,669 | ex | Elixir | clients/cloud_search/lib/google_api/cloud_search/v1/api/settings.ex | MMore/elixir-google-api | 0574ec1439d9bbfe22d63965be1681b0f45a94c9 | [
"Apache-2.0"
] | null | null | null | clients/cloud_search/lib/google_api/cloud_search/v1/api/settings.ex | MMore/elixir-google-api | 0574ec1439d9bbfe22d63965be1681b0f45a94c9 | [
"Apache-2.0"
] | null | null | null | clients/cloud_search/lib/google_api/cloud_search/v1/api/settings.ex | MMore/elixir-google-api | 0574ec1439d9bbfe22d63965be1681b0f45a94c9 | [
"Apache-2.0"
] | null | null | null | # Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.
defmodule GoogleApi.CloudSearch.V1.Api.Settings do
@moduledoc """
API calls for all endpoints tagged `Settings`.
"""
alias GoogleApi.CloudSearch.V1.Connection
alias GoogleApi.Gax.{Request, Response}
@library_version Mix.Project.config() |> Keyword.get(:version, "")
@doc """
Get customer settings. **Note:** This API requires an admin account to execute.
## Parameters
* `connection` (*type:* `GoogleApi.CloudSearch.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").
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.CloudSearch.V1.Model.CustomerSettings{}}` on success
* `{:error, info}` on failure
"""
@spec cloudsearch_settings_get_customer(Tesla.Env.client(), keyword(), keyword()) ::
{:ok, GoogleApi.CloudSearch.V1.Model.CustomerSettings.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def cloudsearch_settings_get_customer(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
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/settings/customer", %{})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.CustomerSettings{}])
end
@doc """
Update customer settings. **Note:** This API requires an admin account to execute.
## Parameters
* `connection` (*type:* `GoogleApi.CloudSearch.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").
* `:updateMask` (*type:* `String.t`) - Update mask to control which fields get updated. If you specify a field in the update_mask but don't specify its value here, that field will be cleared. If the mask is not present or empty, all fields will be updated. Currently supported field paths: vpc_settings and audit_logging_settings
* `:body` (*type:* `GoogleApi.CloudSearch.V1.Model.CustomerSettings.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.CloudSearch.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec cloudsearch_settings_update_customer(Tesla.Env.client(), keyword(), keyword()) ::
{:ok, GoogleApi.CloudSearch.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def cloudsearch_settings_update_customer(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,
:updateMask => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:patch)
|> Request.url("/v1/settings/customer", %{})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.Operation{}])
end
@doc """
Creates a datasource. **Note:** This API requires an admin account to execute.
## Parameters
* `connection` (*type:* `GoogleApi.CloudSearch.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.CloudSearch.V1.Model.DataSource.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.CloudSearch.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec cloudsearch_settings_datasources_create(Tesla.Env.client(), keyword(), keyword()) ::
{:ok, GoogleApi.CloudSearch.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def cloudsearch_settings_datasources_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/settings/datasources", %{})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.Operation{}])
end
@doc """
Deletes a datasource. **Note:** This API requires an admin account to execute.
## Parameters
* `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the datasource. Format: datasources/{source_id}.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:"debugOptions.enableDebugging"` (*type:* `boolean()`) - If you are asked by Google to help with debugging, set this field. Otherwise, ignore this field.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.CloudSearch.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec cloudsearch_settings_datasources_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.CloudSearch.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def cloudsearch_settings_datasources_delete(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:"debugOptions.enableDebugging" => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/settings/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.Operation{}])
end
@doc """
Gets a datasource. **Note:** This API requires an admin account to execute.
## Parameters
* `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the datasource resource. Format: datasources/{source_id}.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:"debugOptions.enableDebugging"` (*type:* `boolean()`) - If you are asked by Google to help with debugging, set this field. Otherwise, ignore this field.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.CloudSearch.V1.Model.DataSource{}}` on success
* `{:error, info}` on failure
"""
@spec cloudsearch_settings_datasources_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.CloudSearch.V1.Model.DataSource.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def cloudsearch_settings_datasources_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:"debugOptions.enableDebugging" => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/settings/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.DataSource{}])
end
@doc """
Lists datasources. **Note:** This API requires an admin account to execute.
## Parameters
* `connection` (*type:* `GoogleApi.CloudSearch.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").
* `:"debugOptions.enableDebugging"` (*type:* `boolean()`) - If you are asked by Google to help with debugging, set this field. Otherwise, ignore this field.
* `:pageSize` (*type:* `integer()`) - Maximum number of datasources to fetch in a request. The max value is 1000. The default value is 1000.
* `:pageToken` (*type:* `String.t`) - Starting index of the results.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.CloudSearch.V1.Model.ListDataSourceResponse{}}` on success
* `{:error, info}` on failure
"""
@spec cloudsearch_settings_datasources_list(Tesla.Env.client(), keyword(), keyword()) ::
{:ok, GoogleApi.CloudSearch.V1.Model.ListDataSourceResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def cloudsearch_settings_datasources_list(connection, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:"debugOptions.enableDebugging" => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/settings/datasources", %{})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.ListDataSourceResponse{}])
end
@doc """
Updates a datasource. **Note:** This API requires an admin account to execute.
## Parameters
* `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the datasource resource. Format: datasources/{source_id}. The name is ignored when creating a datasource.
* `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.CloudSearch.V1.Model.UpdateDataSourceRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.CloudSearch.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec cloudsearch_settings_datasources_update(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.CloudSearch.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def cloudsearch_settings_datasources_update(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:put)
|> Request.url("/v1/settings/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.Operation{}])
end
@doc """
Creates a search application. **Note:** This API requires an admin account to execute.
## Parameters
* `connection` (*type:* `GoogleApi.CloudSearch.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.CloudSearch.V1.Model.SearchApplication.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.CloudSearch.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec cloudsearch_settings_searchapplications_create(Tesla.Env.client(), keyword(), keyword()) ::
{:ok, GoogleApi.CloudSearch.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def cloudsearch_settings_searchapplications_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/settings/searchapplications", %{})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.Operation{}])
end
@doc """
Deletes a search application. **Note:** This API requires an admin account to execute.
## Parameters
* `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - The name of the search application to be deleted. Format: applications/{application_id}.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:"debugOptions.enableDebugging"` (*type:* `boolean()`) - If you are asked by Google to help with debugging, set this field. Otherwise, ignore this field.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.CloudSearch.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec cloudsearch_settings_searchapplications_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.CloudSearch.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def cloudsearch_settings_searchapplications_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:"debugOptions.enableDebugging" => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/settings/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.Operation{}])
end
@doc """
Gets the specified search application. **Note:** This API requires an admin account to execute.
## Parameters
* `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the search application. Format: searchapplications/{application_id}.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:"debugOptions.enableDebugging"` (*type:* `boolean()`) - If you are asked by Google to help with debugging, set this field. Otherwise, ignore this field.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.CloudSearch.V1.Model.SearchApplication{}}` on success
* `{:error, info}` on failure
"""
@spec cloudsearch_settings_searchapplications_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.CloudSearch.V1.Model.SearchApplication.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def cloudsearch_settings_searchapplications_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:"debugOptions.enableDebugging" => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/settings/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.SearchApplication{}])
end
@doc """
Lists all search applications. **Note:** This API requires an admin account to execute.
## Parameters
* `connection` (*type:* `GoogleApi.CloudSearch.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").
* `:"debugOptions.enableDebugging"` (*type:* `boolean()`) - If you are asked by Google to help with debugging, set this field. Otherwise, ignore this field.
* `:pageSize` (*type:* `integer()`) - The maximum number of items to return.
* `:pageToken` (*type:* `String.t`) - The next_page_token value returned from a previous List request, if any. The default value is 10
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.CloudSearch.V1.Model.ListSearchApplicationsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec cloudsearch_settings_searchapplications_list(Tesla.Env.client(), keyword(), keyword()) ::
{:ok, GoogleApi.CloudSearch.V1.Model.ListSearchApplicationsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def cloudsearch_settings_searchapplications_list(connection, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:"debugOptions.enableDebugging" => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/settings/searchapplications", %{})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.ListSearchApplicationsResponse{}]
)
end
@doc """
Resets a search application to default settings. This will return an empty response. **Note:** This API requires an admin account to execute.
## Parameters
* `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - The name of the search application to be reset. Format: applications/{application_id}.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:body` (*type:* `GoogleApi.CloudSearch.V1.Model.ResetSearchApplicationRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.CloudSearch.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec cloudsearch_settings_searchapplications_reset(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.CloudSearch.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def cloudsearch_settings_searchapplications_reset(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/settings/{+name}:reset", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.Operation{}])
end
@doc """
Updates a search application. **Note:** This API requires an admin account to execute.
## Parameters
* `connection` (*type:* `GoogleApi.CloudSearch.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the Search Application. Format: searchapplications/{application_id}.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:body` (*type:* `GoogleApi.CloudSearch.V1.Model.SearchApplication.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.CloudSearch.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec cloudsearch_settings_searchapplications_update(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.CloudSearch.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def cloudsearch_settings_searchapplications_update(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:put)
|> Request.url("/v1/settings/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.CloudSearch.V1.Model.Operation{}])
end
end
| 46.214773 | 337 | 0.615801 |
ff25761fe604ee5ec4bfb7d3a7b4ca2823b5662f | 1,709 | ex | Elixir | lib/mix/tasks/erlang_cookie.ex | CMcDonald82/phoenix-api-starter | c3ece669ea047dc523c867e7609486f1a1818a1f | [
"MIT"
] | 1 | 2018-05-29T11:50:17.000Z | 2018-05-29T11:50:17.000Z | lib/mix/tasks/erlang_cookie.ex | CMcDonald82/phoenix-api-starter | c3ece669ea047dc523c867e7609486f1a1818a1f | [
"MIT"
] | null | null | null | lib/mix/tasks/erlang_cookie.ex | CMcDonald82/phoenix-api-starter | c3ece669ea047dc523c867e7609486f1a1818a1f | [
"MIT"
] | null | null | null | defmodule Mix.Tasks.ErlangCookie do
use Mix.Task
@shortdoc "Creates an Erlang cookie and outputs the value to a file"
@moduledoc """
This task creates a "magic cookie" for the Erlang node
(see the "Security" section at http://erlang.org/doc/reference_manual/distributed.html)
Once the cookie has been created, it will be output to a file .erlang_cookie within the top-level directory of this project.
The cookie created by this task (it should be in the .erlang_cookie file) should then be exported as an environment
variable called ERLANG_COOKIE both locally and on the remote server.
"""
@doc """
This function runs the task
"""
def run([]) do
with :ok <- create_erlang_cookie() do
:ok
end
|> case do
:ok -> print_conclusion_message()
{:error, error} -> print_error_message(error)
end
end
@doc """
This run function handles all other cases
"""
def run(_) do
"""
This task should be run with no args:
mix erlang_cookie
"""
|> print_error_message
end
def create_erlang_cookie do
cookie = :crypto.hash(:sha256, :crypto.strong_rand_bytes(25))
|> Base.encode16
File.write!(".erlang_cookie", cookie)
:ok
rescue
_ -> {:error, "Failed to create erlang magic cookie"}
end
defp print_conclusion_message do
Mix.Shell.IO.info """
Erlang magic cookie successfully created!
Check the .erlang_cookie file
Copy the cookie in that file and export the environment variable ERLANG_COOKIE on the remote host.
export ERLANG_COOKIE=<value copied from .erlang_cookie file>
"""
end
defp print_error_message(error) do
Mix.Shell.IO.error(error)
end
end | 26.292308 | 127 | 0.689292 |
ff2577d68cf70dc0aebedfbf8219206508288ff5 | 930 | exs | Elixir | mix.exs | christopher-dG/osu-ex | ee1c4bc49e5c146a7bcd0d6b976a19d605d695ed | [
"MIT"
] | null | null | null | mix.exs | christopher-dG/osu-ex | ee1c4bc49e5c146a7bcd0d6b976a19d605d695ed | [
"MIT"
] | null | null | null | mix.exs | christopher-dG/osu-ex | ee1c4bc49e5c146a7bcd0d6b976a19d605d695ed | [
"MIT"
] | null | null | null | defmodule OsuEx.MixProject do
use Mix.Project
def project do
[
app: :osu_ex,
version: "0.2.0",
elixir: "~> 1.7",
start_permanent: Mix.env() == :prod,
deps: deps(),
package: package(),
name: "osu!ex",
description: "osu! tools for Elixir.",
source_url: "https://github.com/christopher-dG/osu-ex",
homepage_url: "https://github.com/christopher-dG/osu-ex"
]
end
defp deps do
[
{:httpoison, "~> 1.5"},
{:jason, "~> 1.1"},
{:ex_doc, "~> 0.19", only: :dev, runtime: false}
]
end
defp package do
[
licenses: ["MIT"],
links: %{
"GitHub" => "https://github.com/christopher-dG/osu-ex",
"osu! API Documentation" => "https://github.com/ppy/osu-api/wiki",
"Replay File Format Documentation" =>
"https://osu.ppy.sh/help/wiki/osu!_File_Formats/Osr_(file_format)"
}
]
end
end
| 23.846154 | 76 | 0.548387 |
ff25b8f65ae1694699f568457c3b3423d4c6a78d | 1,744 | ex | Elixir | DIR819_v1.06/src/opensource/inadyn/inadyn-mt/debian/manpage.1.ex | Sirherobrine23/Dir819gpl_code | 8af92d65416198755974e3247b7bbe7f1151d525 | [
"BSD-2-Clause"
] | 1 | 2022-03-19T06:38:01.000Z | 2022-03-19T06:38:01.000Z | DIR819_v1.06/src/opensource/inadyn/inadyn-mt/debian/manpage.1.ex | Sirherobrine23/Dir819gpl_code | 8af92d65416198755974e3247b7bbe7f1151d525 | [
"BSD-2-Clause"
] | null | null | null | DIR819_v1.06/src/opensource/inadyn/inadyn-mt/debian/manpage.1.ex | Sirherobrine23/Dir819gpl_code | 8af92d65416198755974e3247b7bbe7f1151d525 | [
"BSD-2-Clause"
] | 1 | 2022-03-19T06:38:03.000Z | 2022-03-19T06:38:03.000Z | .\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH INADYN-MT SECTION "June 4, 2010"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh disable hyphenation
.\" .hy enable hyphenation
.\" .ad l left justify
.\" .ad b justify to both left and right margins
.\" .nf disable filling
.\" .fi enable filling
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
inadyn-mt \- program to do something
.SH SYNOPSIS
.B inadyn-mt
.RI [ options ] " files" ...
.br
.B bar
.RI [ options ] " files" ...
.SH DESCRIPTION
This manual page documents briefly the
.B inadyn-mt
and
.B bar
commands.
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
.\" respectively.
\fBinadyn-mt\fP is a program that...
.SH OPTIONS
These programs follow the usual GNU command line syntax, with long
options starting with two dashes (`-').
A summary of options is included below.
For a complete description, see the Info files.
.TP
.B \-h, \-\-help
Show summary of options.
.TP
.B \-v, \-\-version
Show version of program.
.SH SEE ALSO
.BR bar (1),
.BR baz (1).
.br
The programs are documented fully by
.IR "The Rise and Fall of a Fooish Bar" ,
available via the Info system.
.SH AUTHOR
inadyn-mt was written by <upstream author>.
.PP
This manual page was written by root <root@unknown>,
for the Debian project (and may be used by others).
| 29.066667 | 70 | 0.669725 |
ff25d5f6a47da4ac19fa448159b96e74a5529384 | 1,260 | ex | Elixir | lib/coxir/voice/server.ex | Xh4H/coxir | 72295f796e9e540891c63a21126be4d10e5841fc | [
"Apache-2.0"
] | null | null | null | lib/coxir/voice/server.ex | Xh4H/coxir | 72295f796e9e540891c63a21126be4d10e5841fc | [
"Apache-2.0"
] | 3 | 2018-08-27T06:12:34.000Z | 2018-10-19T05:42:34.000Z | lib/coxir/voice/server.ex | Xh4H/coxir | 72295f796e9e540891c63a21126be4d10e5841fc | [
"Apache-2.0"
] | null | null | null | defmodule Coxir.Voice.Server do
@moduledoc false
use Supervisor
alias Coxir.Voice.{Handler, Gateway, Audio}
def start_link(state) do
Supervisor.start_link __MODULE__, state
end
def init(state) do
state = state
|> Map.merge(
%{
server: self()
}
)
children = [
worker(Handler, [state])
]
options = [
strategy: :rest_for_one
]
Supervisor.init(children, options)
end
def update(server, data) do
server
|> get_handler
|> send({:update, data})
end
def get_handler(server) do
server
|> get_child(Handler)
end
def get_gateway(server) do
server
|> get_child(Gateway)
end
def get_audio(server) do
server
|> get_child(Audio)
end
def start_child(server, module, state) do
child = worker(module, [state])
server
|> Supervisor.start_child(child)
|> case do
{:ok, pid} ->
pid
_error ->
nil
end
end
defp get_child(server, module) do
server
|> Supervisor.which_children
|> Enum.find(
fn {_id, _pid, _type, [mod]} ->
mod == module
end
)
|> case do
{_id, pid, _type, _modules} ->
pid
_none ->
nil
end
end
end
| 16.8 | 45 | 0.571429 |
ff25e0d1b16fde49a745fca6ff8e7d2519ed7790 | 150 | ex | Elixir | web/controllers/page_controller.ex | koenighotze/callforpaper | 3ca57abc0cd8d857dedf20e70bce841264d0fe30 | [
"MIT"
] | 1 | 2017-01-25T21:34:37.000Z | 2017-01-25T21:34:37.000Z | web/controllers/page_controller.ex | koenighotze/callforpaper | 3ca57abc0cd8d857dedf20e70bce841264d0fe30 | [
"MIT"
] | 40 | 2017-02-09T07:22:25.000Z | 2020-10-28T13:43:12.000Z | web/controllers/page_controller.ex | koenighotze/callforpaper | 3ca57abc0cd8d857dedf20e70bce841264d0fe30 | [
"MIT"
] | null | null | null | defmodule Callforpapers.PageController do
use Callforpapers.Web, :controller
def index(conn, _params) do
render conn, "index.html"
end
end
| 18.75 | 41 | 0.753333 |
ff25f5d45f2dc04bfaf54a97219fc05d09251f27 | 3,671 | ex | Elixir | services/fc_identity/lib/fc_identity/policies/user_policy.ex | dclausen/freshcom | 7e1d6397c8ab222cfd03830232cee0718f050490 | [
"BSD-3-Clause"
] | null | null | null | services/fc_identity/lib/fc_identity/policies/user_policy.ex | dclausen/freshcom | 7e1d6397c8ab222cfd03830232cee0718f050490 | [
"BSD-3-Clause"
] | null | null | null | services/fc_identity/lib/fc_identity/policies/user_policy.ex | dclausen/freshcom | 7e1d6397c8ab222cfd03830232cee0718f050490 | [
"BSD-3-Clause"
] | null | null | null | defmodule FCIdentity.UserPolicy do
@moduledoc false
use OK.Pipe
alias FCIdentity.{
RegisterUser,
AddUser,
DeleteUser,
GeneratePasswordResetToken,
ChangePassword,
ChangeUserRole,
UpdateUserInfo,
GenerateEmailVerificationToken,
VerifyEmail
}
def authorize(%{requester_role: "sysdev"} = cmd, _), do: {:ok, cmd}
def authorize(%{requester_role: "system"} = cmd, _), do: {:ok, cmd}
def authorize(%{requester_role: "appdev"} = cmd, _), do: {:ok, cmd}
def authorize(%{client_type: "unkown"}, _), do: {:error, :access_denied}
def authorize(%AddUser{requester_role: role} = cmd, _) when role in ["owner", "administrator"],
do: {:ok, cmd}
def authorize(%RegisterUser{} = cmd, _),
do: {:ok, cmd}
def authorize(%GeneratePasswordResetToken{client_type: "system"} = cmd, %{type: "standard"}), do: {:ok, cmd}
def authorize(%GeneratePasswordResetToken{} = cmd, %{type: "managed"}), do: {:ok, cmd}
# Changing user's own password
def authorize(%ChangePassword{requester_id: rid, requester_type: "standard", user_id: uid, client_type: "system"} = cmd, _) when rid == uid,
do: {:ok, cmd}
def authorize(%ChangePassword{requester_id: rid, requester_type: "managed", user_id: uid} = cmd, _) when rid == uid,
do: {:ok, cmd}
# Reseting password
def authorize(%ChangePassword{requester_id: nil} = cmd, _),
do: {:ok, cmd}
# Managing other user's password
def authorize(%ChangePassword{} = cmd, state),
do: default_authorize(cmd, state, ["owner", "administrator"])
# Updating user's own info
def authorize(%UpdateUserInfo{requester_id: rid, user_id: uid} = cmd, _) when rid == uid,
do: {:ok, cmd}
# Support specailist can update customer's info
def authorize(%UpdateUserInfo{} = cmd, %{role: "customer"} = state),
do: default_authorize(cmd, state, ["owner", "administrator", "support_specialist"])
def authorize(%UpdateUserInfo{} = cmd, state),
do: default_authorize(cmd, state, ["owner", "administrator"])
def authorize(%DeleteUser{} = cmd, state),
do: default_authorize(cmd, state, ["owner", "administrator"])
def authorize(%ChangeUserRole{} = cmd, state),
do: default_authorize(cmd, state, ["owner", "administrator"])
# User can generate evt for self
def authorize(%GenerateEmailVerificationToken{requester_id: rid, user_id: uid} = cmd, _) when rid == uid,
do: {:ok, cmd}
def authorize(%GenerateEmailVerificationToken{} = cmd, %{role: "customer"} = state),
do: default_authorize(cmd, state, ["owner", "administrator", "support_specialist"])
# Using verification token does not require requester to be identified
def authorize(%VerifyEmail{requester_id: nil} = cmd, _),
do: {:ok, cmd}
def authorize(%VerifyEmail{} = cmd, %{role: "customer"} = state),
do: default_authorize(cmd, state, ["owner", "administrator", "support_specialist"])
def authorize(%VerifyEmail{} = cmd, state),
do: default_authorize(cmd, state, ["owner", "administrator"])
def authorize(_, _), do: {:error, :access_denied}
defp default_authorize(_, %{role: "owner"}, _), do: {:error, :access_denied}
defp default_authorize(cmd, state, roles) do
cmd
|> authorize_by_account(state.account_id)
~>> authorize_by_role(roles)
end
defp authorize_by_account(%{account_id: t_aid} = cmd, aid) when t_aid == aid do
{:ok, cmd}
end
defp authorize_by_account(_, _), do: {:error, :access_denied}
defp authorize_by_role(%{requester_role: role} = cmd, roles) do
if role in roles do
{:ok, cmd}
else
{:error, :access_denied}
end
end
defp authorize_by_role(_, _), do: {:error, :access_denied}
end
| 34.308411 | 142 | 0.674476 |
ff2604530115560313d52f9491ed1ac6c7366488 | 2,679 | exs | Elixir | test/datafeed_test.exs | icanmakeitbetter/decipher_api | 3e2152f8fd87f4a92489d08e0bd4f53d18e3c0d2 | [
"MIT"
] | null | null | null | test/datafeed_test.exs | icanmakeitbetter/decipher_api | 3e2152f8fd87f4a92489d08e0bd4f53d18e3c0d2 | [
"MIT"
] | null | null | null | test/datafeed_test.exs | icanmakeitbetter/decipher_api | 3e2152f8fd87f4a92489d08e0bd4f53d18e3c0d2 | [
"MIT"
] | null | null | null | defmodule DecipherAPITest.DatafeedTest do
alias DecipherAPITest.Support.InMemoryHTTPClient
alias DecipherAPITest.Support.FakeData
alias DecipherAPI.Datafeed
alias DecipherAPI.Datafeed.ResultSet
use ExUnit.Case, async: true
@survey_id FakeData.survey_id()
@account_info FakeData.account_info
@datafeed Datafeed.new(@account_info, @survey_id)
test "that new returns a new struct" do
assert Datafeed.new(FakeData.account_info(), @survey_id) == @datafeed
end
test "that get_results returns the correct value" do
assert Datafeed.get_results(@datafeed) ==
FakeData.http_datafeed_body_map()
end
test "that advance returns a true response for the acknowledge code" do
assert Datafeed.advance(%ResultSet{ack: "asdf-asdf-asdf-asdf"}, @datafeed) == true
end
test "that reset returns" do
assert Datafeed.reset(@datafeed) == {:ok, "Reset successful."}
end
test "we hit the complete false function head of check_if_more_results" do
{:ok, called} = Agent.start_link(fn() -> false end)
success = Datafeed.check_if_more_results(
%ResultSet{complete?: false},
@datafeed,
fn(_result, _metadata) ->
Agent.update(called, fn(_bool) -> true end)
end)
assert success == :ok
assert Agent.get(called, &(&1))
end
test "that we process results without passing in a datamap" do
InMemoryHTTPClient.queue_response(:get, :datafeed, FakeData.datafeed_complete_false())
success = Datafeed.get_and_process(
@datafeed,
fn(result, _metadata) ->
assert %{"q1" => _q1, "q2" => _q2} = result
end)
assert success == :ok
end
test "that we process results when passing in a datamap" do
InMemoryHTTPClient.queue_response(:get, :datafeed, FakeData.raw_all_question_datafeed_response())
datamap =
FakeData.raw_datamap
success = Datafeed.get_and_process(
@datafeed,
datamap,
fn(result, _metadata) ->
Enum.each(result, fn response ->
assert [%DecipherAPI.Datamap.Variables{}, _response] = response
end)
end)
assert success == :ok
end
test "that we error out in processing results when appropriate" do
InMemoryHTTPClient.queue_response(:get, :datafeed, FakeData.datafeed_error_response())
failure = Datafeed.get_and_process(
@datafeed,
fn(result, _metadata) ->
assert %{"q1" => _q1, "q2" => _q2} = result
end)
assert {:error, _} = failure
end
end
| 32.670732 | 101 | 0.637178 |
ff2614a70d2fd47227c1ddf5171b044eee23d2f2 | 1,134 | exs | Elixir | mix.exs | zvkemp/hmac_auth_ex | 8d6f4e68400807c01e9e6a8091ef308fe1f7d694 | [
"MIT"
] | 1 | 2021-05-11T18:34:46.000Z | 2021-05-11T18:34:46.000Z | mix.exs | zvkemp/hmac_auth_ex | 8d6f4e68400807c01e9e6a8091ef308fe1f7d694 | [
"MIT"
] | null | null | null | mix.exs | zvkemp/hmac_auth_ex | 8d6f4e68400807c01e9e6a8091ef308fe1f7d694 | [
"MIT"
] | null | null | null | defmodule HMACAuth.MixProject do
use Mix.Project
def project do
[app: :hmac_auth_ex,
version: "0.3.0",
elixir: "~> 1.3",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps(),
package: package(),
description: description(),
source_url: github_url()]
end
# Configuration for the OTP application
#
# Type "mix help compile.app" for more information
def application do
[]
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
[
{:plug, "~> 1.3"},
{:dialyxir, "~> 0.5", only: :dev, runtime: :false}
]
end
defp description do
"One-time token (shared secret) HTTP authorization with TTL"
end
defp github_url do
"https://github.com/zvkemp/hmac_auth_ex"
end
defp package do
[
maintainers: ["Zach Kemp"],
licenses: ["MIT"],
links: %{"GitHub" => github_url()}
]
end
end
| 20.618182 | 77 | 0.594356 |
ff2618f583ec4c21afce3ddb1e0143d0575ae457 | 2,595 | ex | Elixir | clients/fusion_tables/lib/google_api/fusion_tables/v2/model/template.ex | matehat/elixir-google-api | c1b2523c2c4cdc9e6ca4653ac078c94796b393c3 | [
"Apache-2.0"
] | 1 | 2018-12-03T23:43:10.000Z | 2018-12-03T23:43:10.000Z | clients/fusion_tables/lib/google_api/fusion_tables/v2/model/template.ex | matehat/elixir-google-api | c1b2523c2c4cdc9e6ca4653ac078c94796b393c3 | [
"Apache-2.0"
] | null | null | null | clients/fusion_tables/lib/google_api/fusion_tables/v2/model/template.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 "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 class is auto generated by the elixir code generator program.
# Do not edit the class manually.
defmodule GoogleApi.FusionTables.V2.Model.Template do
@moduledoc """
Represents the contents of InfoWindow templates.
## Attributes
* `automaticColumnNames` (*type:* `list(String.t)`, *default:* `nil`) - List of columns from which the template is to be automatically constructed. Only one of body or automaticColumns can be specified.
* `body` (*type:* `String.t`, *default:* `nil`) - Body of the template. It contains HTML with {column_name} to insert values from a particular column. The body is sanitized to remove certain tags, e.g., script. Only one of body or automaticColumns can be specified.
* `kind` (*type:* `String.t`, *default:* `fusiontables#template`) - The kind of item this is. For a template, this is always fusiontables#template.
* `name` (*type:* `String.t`, *default:* `nil`) - Optional name assigned to a template.
* `tableId` (*type:* `String.t`, *default:* `nil`) - Identifier for the table for which the template is defined.
* `templateId` (*type:* `integer()`, *default:* `nil`) - Identifier for the template, unique within the context of a particular table.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:automaticColumnNames => list(String.t()),
:body => String.t(),
:kind => String.t(),
:name => String.t(),
:tableId => String.t(),
:templateId => integer()
}
field(:automaticColumnNames, type: :list)
field(:body)
field(:kind)
field(:name)
field(:tableId)
field(:templateId)
end
defimpl Poison.Decoder, for: GoogleApi.FusionTables.V2.Model.Template do
def decode(value, options) do
GoogleApi.FusionTables.V2.Model.Template.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.FusionTables.V2.Model.Template do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 41.854839 | 269 | 0.703276 |
ff26198e95297f6df1f715bdd9e46d1e6bff6343 | 1,574 | exs | Elixir | test/budget/calculations/daily_test.exs | corybuecker/simple-budget | d86241ff712552267da87052120468b01d2b8f41 | [
"MIT"
] | 2 | 2019-04-02T01:06:40.000Z | 2019-05-13T01:12:24.000Z | test/budget/calculations/daily_test.exs | corybuecker/simple-budget | d86241ff712552267da87052120468b01d2b8f41 | [
"MIT"
] | 7 | 2018-12-27T12:33:38.000Z | 2021-03-08T22:31:14.000Z | test/budget/calculations/daily_test.exs | corybuecker/simple-budget | d86241ff712552267da87052120468b01d2b8f41 | [
"MIT"
] | null | null | null | defmodule SimpleBudget.Calculations.DailyTest do
use SimpleBudget.DataCase
alias SimpleBudget.Accounts
alias SimpleBudget.Calculations.Daily
alias SimpleBudget.Goals
alias SimpleBudget.Savings
setup do
{:ok, credit} = Accounts.create_account(%{name: "some name", balance: 750, debt: false})
{:ok, _debt} = Accounts.create_account(%{name: "some name", balance: 5, debt: true})
{:ok, _adjustment} =
Accounts.create_adjustment(%{account_id: credit.id, title: "adjustment", total: -50.0})
{:ok, _adjustment} =
Accounts.create_adjustment(%{account_id: credit.id, title: "adjustment", total: -3.0})
{:ok, _saving} = Savings.create_saving(%{title: "savings", amount: 30.0})
{:ok, _goal} =
Goals.create_goal(%{
title: "goal",
start_date: Timex.shift(Timex.today(), days: -1),
end_date: Timex.shift(Timex.today(), days: 1),
target: 100
})
:ok
end
test "calculates the remaining amount per day" do
# not a great test since it duplicates the implementation, TODO: find a
# way to freeze Timex to a given datetime.
days_left =
if Timex.today() == Timex.today() |> Timex.end_of_month() do
1
else
Timex.Interval.new(from: Timex.today(), until: Timex.today() |> Timex.end_of_month())
|> Timex.Interval.duration(:days)
end
assert Daily.all() ==
%{
remaining: Decimal.from_float(612.0),
remaining_per_day: Decimal.div(Decimal.from_float(612.0), days_left)
}
end
end
| 31.48 | 93 | 0.634053 |
ff2626607d362ce42279484029d420eb50e2f6ce | 74,929 | ex | Elixir | clients/service_management/lib/google_api/service_management/v1/api/services.ex | ukrbublik/elixir-google-api | 364cec36bc76f60bec94cbcad34844367a29d174 | [
"Apache-2.0"
] | null | null | null | clients/service_management/lib/google_api/service_management/v1/api/services.ex | ukrbublik/elixir-google-api | 364cec36bc76f60bec94cbcad34844367a29d174 | [
"Apache-2.0"
] | null | null | null | clients/service_management/lib/google_api/service_management/v1/api/services.ex | ukrbublik/elixir-google-api | 364cec36bc76f60bec94cbcad34844367a29d174 | [
"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.ServiceManagement.V1.Api.Services do
@moduledoc """
API calls for all endpoints tagged `Services`.
"""
alias GoogleApi.ServiceManagement.V1.Connection
alias GoogleApi.Gax.{Request, Response}
@library_version Mix.Project.config() |> Keyword.get(:version, "")
@doc """
Creates a new managed service. A managed service is immutable, and is subject to mandatory 30-day data retention. You cannot move a service or recreate it within 30 days after deletion. One producer project can own no more than 500 services. For security and reliability purposes, a production service should be hosted in a dedicated producer project. Operation
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.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.ServiceManagement.V1.Model.ManagedService.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_create(Tesla.Env.client(), keyword(), keyword()) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_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/services", %{})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Operation{}])
end
@doc """
Deletes a managed service. This method will change the service to the `Soft-Delete` state for 30 days. Within this period, service producers may call UndeleteService to restore the service. After 30 days, the service will be permanently deleted. Operation
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `service_name` (*type:* `String.t`) - Required. The name of the service. See the [overview](/service-management/overview) for naming requirements. For example: `example.googleapis.com`.
* `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.ServiceManagement.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_delete(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_delete(
connection,
service_name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/services/{serviceName}", %{
"serviceName" => URI.encode(service_name, &(URI.char_unreserved?(&1) || &1 == ?/))
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Operation{}])
end
@doc """
Disables a service for a project, so it can no longer be be used for the project. It prevents accidental usage that may cause unexpected billing charges or security leaks. Operation
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `service_name` (*type:* `String.t`) - Required. Name of the service to disable. Specifying an unknown service name will cause the request to fail.
* `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.ServiceManagement.V1.Model.DisableServiceRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_disable(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_disable(
connection,
service_name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/services/{serviceName}:disable", %{
"serviceName" => URI.encode(service_name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Operation{}])
end
@doc """
Enables a service for a project, so it can be used for the project. See [Cloud Auth Guide](https://cloud.google.com/docs/authentication) for more information. Operation
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `service_name` (*type:* `String.t`) - Required. Name of the service to enable. Specifying an unknown service name will cause the request to fail.
* `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.ServiceManagement.V1.Model.EnableServiceRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_enable(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_enable(
connection,
service_name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/services/{serviceName}:enable", %{
"serviceName" => URI.encode(service_name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Operation{}])
end
@doc """
Generates and returns a report (errors, warnings and changes from existing configurations) associated with GenerateConfigReportRequest.new_value If GenerateConfigReportRequest.old_value is specified, GenerateConfigReportRequest will contain a single ChangeReport based on the comparison between GenerateConfigReportRequest.new_value and GenerateConfigReportRequest.old_value. If GenerateConfigReportRequest.old_value is not specified, this method will compare GenerateConfigReportRequest.new_value with the last pushed service configuration.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.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.ServiceManagement.V1.Model.GenerateConfigReportRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.GenerateConfigReportResponse{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_generate_config_report(
Tesla.Env.client(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.GenerateConfigReportResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_generate_config_report(
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/services:generateConfigReport", %{})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.GenerateConfigReportResponse{}]
)
end
@doc """
Gets a managed service. Authentication is required unless the service is public.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `service_name` (*type:* `String.t`) - Required. The name of the service. See the `ServiceManager` overview for naming requirements. For example: `example.googleapis.com`.
* `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.ServiceManagement.V1.Model.ManagedService{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.ManagedService.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_get(connection, service_name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/services/{serviceName}", %{
"serviceName" => URI.encode(service_name, &(URI.char_unreserved?(&1) || &1 == ?/))
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.ManagedService{}])
end
@doc """
Gets a service configuration (version) for a managed service.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `service_name` (*type:* `String.t`) - Required. The name of the service. See the [overview](/service-management/overview) for naming requirements. For example: `example.googleapis.com`.
* `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").
* `:configId` (*type:* `String.t`) - Required. The id of the service configuration resource. This field must be specified for the server to return all fields, including `SourceInfo`.
* `:view` (*type:* `String.t`) - Specifies which parts of the Service Config should be returned in the response.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.Service{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_get_config(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Service.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_get_config(
connection,
service_name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:configId => :query,
:view => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/services/{serviceName}/config", %{
"serviceName" => URI.encode(service_name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Service{}])
end
@doc """
Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:body` (*type:* `GoogleApi.ServiceManagement.V1.Model.GetIamPolicyRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.Policy{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_get_iam_policy(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Policy.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_get_iam_policy(
connection,
resource,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+resource}:getIamPolicy", %{
"resource" => URI.encode(resource, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Policy{}])
end
@doc """
Lists managed services. Returns all public services. For authenticated users, also returns all services the calling user has "servicemanagement.services.get" permission for. **BETA:** If the caller specifies the `consumer_id`, it returns only the services enabled on the consumer. The `consumer_id` must have the format of "project:{PROJECT-ID}".
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.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").
* `:consumerId` (*type:* `String.t`) - Include services consumed by the specified consumer. The Google Service Management implementation accepts the following forms: - project:
* `:pageSize` (*type:* `integer()`) - The max number of items to include in the response list. Page size is 50 if not specified. Maximum value is 100.
* `:pageToken` (*type:* `String.t`) - Token identifying which result to start with; returned by a previous list call.
* `:producerProjectId` (*type:* `String.t`) - Include services produced by the specified project.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.ListServicesResponse{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_list(Tesla.Env.client(), keyword(), keyword()) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.ListServicesResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_list(connection, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:consumerId => :query,
:pageSize => :query,
:pageToken => :query,
:producerProjectId => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/services", %{})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.ListServicesResponse{}]
)
end
@doc """
Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:body` (*type:* `GoogleApi.ServiceManagement.V1.Model.SetIamPolicyRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.Policy{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_set_iam_policy(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Policy.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_set_iam_policy(
connection,
resource,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+resource}:setIamPolicy", %{
"resource" => URI.encode(resource, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Policy{}])
end
@doc """
Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:body` (*type:* `GoogleApi.ServiceManagement.V1.Model.TestIamPermissionsRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.TestIamPermissionsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_test_iam_permissions(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.TestIamPermissionsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_test_iam_permissions(
connection,
resource,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+resource}:testIamPermissions", %{
"resource" => URI.encode(resource, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.TestIamPermissionsResponse{}]
)
end
@doc """
Revives a previously deleted managed service. The method restores the service using the configuration at the time the service was deleted. The target service must exist and must have been deleted within the last 30 days. Operation
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `service_name` (*type:* `String.t`) - Required. The name of the service. See the [overview](/service-management/overview) for naming requirements. For example: `example.googleapis.com`.
* `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.ServiceManagement.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_undelete(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_undelete(
connection,
service_name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/services/{serviceName}:undelete", %{
"serviceName" => URI.encode(service_name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Operation{}])
end
@doc """
Creates a new service configuration (version) for a managed service. This method only stores the service configuration. To roll out the service configuration to backend systems please call CreateServiceRollout. Only the 100 most recent service configurations and ones referenced by existing rollouts are kept for each service. The rest will be deleted eventually.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `service_name` (*type:* `String.t`) - Required. The name of the service. See the [overview](/service-management/overview) for naming requirements. For example: `example.googleapis.com`.
* `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.ServiceManagement.V1.Model.Service.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.Service{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_configs_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Service.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_configs_create(
connection,
service_name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/services/{serviceName}/configs", %{
"serviceName" => URI.encode(service_name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Service{}])
end
@doc """
Gets a service configuration (version) for a managed service.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `service_name` (*type:* `String.t`) - Required. The name of the service. See the [overview](/service-management/overview) for naming requirements. For example: `example.googleapis.com`.
* `config_id` (*type:* `String.t`) - Required. The id of the service configuration resource. This field must be specified for the server to return all fields, including `SourceInfo`.
* `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`) - Specifies which parts of the Service Config should be returned in the response.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.Service{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_configs_get(
Tesla.Env.client(),
String.t(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Service.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_configs_get(
connection,
service_name,
config_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/services/{serviceName}/configs/{configId}", %{
"serviceName" => URI.encode(service_name, &URI.char_unreserved?/1),
"configId" => URI.encode(config_id, &(URI.char_unreserved?(&1) || &1 == ?/))
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Service{}])
end
@doc """
Lists the history of the service configuration for a managed service, from the newest to the oldest.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `service_name` (*type:* `String.t`) - Required. The name of the service. See the [overview](/service-management/overview) for naming requirements. For example: `example.googleapis.com`.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - The max number of items to include in the response list. Page size is 50 if not specified. Maximum value is 100.
* `:pageToken` (*type:* `String.t`) - The token of the page to retrieve.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.ListServiceConfigsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_configs_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.ListServiceConfigsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_configs_list(
connection,
service_name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/services/{serviceName}/configs", %{
"serviceName" => URI.encode(service_name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.ListServiceConfigsResponse{}]
)
end
@doc """
Creates a new service configuration (version) for a managed service based on user-supplied configuration source files (for example: OpenAPI Specification). This method stores the source configurations as well as the generated service configuration. To rollout the service configuration to other services, please call CreateServiceRollout. Only the 100 most recent configuration sources and ones referenced by existing service configurtions are kept for each service. The rest will be deleted eventually. Operation
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `service_name` (*type:* `String.t`) - Required. The name of the service. See the [overview](/service-management/overview) for naming requirements. For example: `example.googleapis.com`.
* `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.ServiceManagement.V1.Model.SubmitConfigSourceRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_configs_submit(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_configs_submit(
connection,
service_name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/services/{serviceName}/configs:submit", %{
"serviceName" => URI.encode(service_name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Operation{}])
end
@doc """
Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:body` (*type:* `GoogleApi.ServiceManagement.V1.Model.GetIamPolicyRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.Policy{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_consumers_get_iam_policy(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Policy.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_consumers_get_iam_policy(
connection,
resource,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+resource}:getIamPolicy", %{
"resource" => URI.encode(resource, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Policy{}])
end
@doc """
Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:body` (*type:* `GoogleApi.ServiceManagement.V1.Model.SetIamPolicyRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.Policy{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_consumers_set_iam_policy(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Policy.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_consumers_set_iam_policy(
connection,
resource,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+resource}:setIamPolicy", %{
"resource" => URI.encode(resource, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Policy{}])
end
@doc """
Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:body` (*type:* `GoogleApi.ServiceManagement.V1.Model.TestIamPermissionsRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.TestIamPermissionsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_consumers_test_iam_permissions(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.TestIamPermissionsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_consumers_test_iam_permissions(
connection,
resource,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+resource}:testIamPermissions", %{
"resource" => URI.encode(resource, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.TestIamPermissionsResponse{}]
)
end
@doc """
Creates a new service configuration rollout. Based on rollout, the Google Service Management will roll out the service configurations to different backend services. For example, the logging configuration will be pushed to Google Cloud Logging. Please note that any previous pending and running Rollouts and associated Operations will be automatically cancelled so that the latest Rollout will not be blocked by previous Rollouts. Only the 100 most recent (in any state) and the last 10 successful (if not already part of the set of 100 most recent) rollouts are kept for each service. The rest will be deleted eventually. Operation
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `service_name` (*type:* `String.t`) - Required. The name of the service. See the [overview](/service-management/overview) for naming requirements. For example: `example.googleapis.com`.
* `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.ServiceManagement.V1.Model.Rollout.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.Operation{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_rollouts_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Operation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_rollouts_create(
connection,
service_name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/services/{serviceName}/rollouts", %{
"serviceName" => URI.encode(service_name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Operation{}])
end
@doc """
Gets a service configuration rollout.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `service_name` (*type:* `String.t`) - Required. The name of the service. See the [overview](/service-management/overview) for naming requirements. For example: `example.googleapis.com`.
* `rollout_id` (*type:* `String.t`) - Required. The id of the rollout resource.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.Rollout{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_rollouts_get(
Tesla.Env.client(),
String.t(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.Rollout.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_rollouts_get(
connection,
service_name,
rollout_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/services/{serviceName}/rollouts/{rolloutId}", %{
"serviceName" => URI.encode(service_name, &URI.char_unreserved?/1),
"rolloutId" => URI.encode(rollout_id, &(URI.char_unreserved?(&1) || &1 == ?/))
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.Rollout{}])
end
@doc """
Lists the history of the service configuration rollouts for a managed service, from the newest to the oldest.
## Parameters
* `connection` (*type:* `GoogleApi.ServiceManagement.V1.Connection.t`) - Connection to server
* `service_name` (*type:* `String.t`) - Required. The name of the service. See the [overview](/service-management/overview) for naming requirements. For example: `example.googleapis.com`.
* `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`) - Required. Use `filter` to return subset of rollouts. The following filters are supported: -- To limit the results to only those in [status](google.api.servicemanagement.v1.RolloutStatus) 'SUCCESS', use filter='status=SUCCESS' -- To limit the results to those in [status](google.api.servicemanagement.v1.RolloutStatus) 'CANCELLED' or 'FAILED', use filter='status=CANCELLED OR status=FAILED'
* `:pageSize` (*type:* `integer()`) - The max number of items to include in the response list. Page size is 50 if not specified. Maximum value is 100.
* `:pageToken` (*type:* `String.t`) - The token of the page to retrieve.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.ServiceManagement.V1.Model.ListServiceRolloutsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec servicemanagement_services_rollouts_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.ServiceManagement.V1.Model.ListServiceRolloutsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def servicemanagement_services_rollouts_list(
connection,
service_name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:filter => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/services/{serviceName}/rollouts", %{
"serviceName" => URI.encode(service_name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.ServiceManagement.V1.Model.ListServiceRolloutsResponse{}]
)
end
end
| 48.185852 | 633 | 0.629703 |
ff265ab1b222eadefa332d4eceb4ae12a07ef57c | 457 | exs | Elixir | source/backend/api_app/config/test.exs | edwinvautier/aio-group3-proj01 | 2ca3d834f358a38692e8ae4d6266bbea130a6cb5 | [
"MIT"
] | 3 | 2020-04-05T15:26:55.000Z | 2020-06-17T15:01:33.000Z | source/backend/api_app/config/test.exs | edwinvautier/aio-group3-proj01 | 2ca3d834f358a38692e8ae4d6266bbea130a6cb5 | [
"MIT"
] | 48 | 2020-04-01T16:00:47.000Z | 2020-04-28T16:22:12.000Z | source/backend/api_app/config/test.exs | edwinvautier/aio-group3-proj01 | 2ca3d834f358a38692e8ae4d6266bbea130a6cb5 | [
"MIT"
] | 4 | 2020-03-30T15:36:55.000Z | 2020-06-17T15:01:36.000Z | use Mix.Config
# Configure your database
config :api_app, ApiApp.Repo,
username: "postgres",
password: "postgres",
database: "api_app_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :api_app, ApiAppWeb.Endpoint,
http: [port: 4002],
server: false
# Print only warnings and errors during test
config :logger, level: :warn
| 24.052632 | 56 | 0.730853 |
ff265e1592d0951cf64a7aa83039cbeee6cd6356 | 89 | ex | Elixir | .env.ex | MindfulMinun/discord-haruka | 88bb12fa516423825364082a408054c3cec9f3ed | [
"MIT"
] | 2 | 2018-08-03T05:45:38.000Z | 2018-10-13T15:50:10.000Z | .env.ex | MindfulMinun/discord-haruka | 88bb12fa516423825364082a408054c3cec9f3ed | [
"MIT"
] | 8 | 2018-10-28T16:30:03.000Z | 2022-02-15T23:37:04.000Z | .env.ex | MindfulMinun/discord-haruka | 88bb12fa516423825364082a408054c3cec9f3ed | [
"MIT"
] | 1 | 2022-02-18T05:32:10.000Z | 2022-02-18T05:32:10.000Z | # Follow instructions in README.md
DISCORD_TOKEN=
KANJI_ALIVE_KEY=
WA_APPID=
HARUKA_OPS=
| 14.833333 | 34 | 0.831461 |
ff2668ff1fdeb3286e762ccc96f7dcee164d8919 | 2,260 | exs | Elixir | mix.exs | xinz/protox | 0baa4acd0ab6694fdb3d52fd875832c377028833 | [
"MIT"
] | null | null | null | mix.exs | xinz/protox | 0baa4acd0ab6694fdb3d52fd875832c377028833 | [
"MIT"
] | null | null | null | mix.exs | xinz/protox | 0baa4acd0ab6694fdb3d52fd875832c377028833 | [
"MIT"
] | null | null | null | defmodule Protox.Mixfile do
use Mix.Project
def project do
[
app: :protox,
version: "1.2.3",
elixir: "~> 1.7",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
deps: deps(),
test_coverage: [tool: ExCoveralls],
elixirc_paths: elixirc_paths(Mix.env()),
escript: escript(),
name: "Protox",
source_url: "https://github.com/ahamez/protox",
description: description(),
package: package(),
dialyzer: [plt_file: {:no_warn, "priv/plts/dialyzer.plt"}],
docs: docs()
]
end
# Do not compile conformance and benchmarks related files when in production
defp elixirc_paths(:prod), do: ["lib"]
defp elixirc_paths(_), do: ["lib", "conformance", "benchmarks"]
def application do
[
extra_applications: [
:crypto,
:mix
]
]
end
defp deps do
[
{:benchee, "~> 1.0", only: [:dev], runtime: false},
{:benchee_html, "~> 1.0", only: [:dev], runtime: false},
{:benchee_markdown, "~> 0.2", only: [:dev], runtime: false},
{:credo, "~> 1.4", only: [:test, :dev], runtime: false},
{:dialyxir, "~> 1.0", only: [:test, :dev], runtime: false},
{:excoveralls, "~> 0.13", only: [:test], runtime: false},
{:ex_doc, "~> 0.22", only: [:dev], runtime: false},
{:git_hooks, "~> 0.5", only: [:test, :dev], runtime: false},
{:inch_ex, "~> 2.0.0", only: [:docs], runtime: false},
{:propcheck, "~> 1.2", only: [:test, :dev]}
]
end
defp description do
"""
A fast, easy to use and 100% conformant Elixir library for Google Protocol Buffers (aka protobuf)
"""
end
def escript do
[
# do not start any application: avoid propcheck app to fail when running escript
app: nil,
main_module: Protox.Conformance.Escript,
name: "protox_conformance"
]
end
defp package do
[
name: :protox,
files: ["lib", "mix.exs", "README*", "LICENSE"],
maintainers: ["Alexandre Hamez"],
licenses: ["MIT"],
links: %{"GitHub" => "https://github.com/ahamez/protox"}
]
end
defp docs do
[
main: "readme",
extras: ["README.md", "documentation/reference.md"]
]
end
end
| 26.904762 | 101 | 0.564159 |
ff266b73bca5d46c6c5099cb89dcb748e84947ba | 2,014 | exs | Elixir | test/level/spaces/user_test.exs | pradyumna2905/level | 186878a128521074923edd7171eda2f1b181b4f4 | [
"Apache-2.0"
] | null | null | null | test/level/spaces/user_test.exs | pradyumna2905/level | 186878a128521074923edd7171eda2f1b181b4f4 | [
"Apache-2.0"
] | null | null | null | test/level/spaces/user_test.exs | pradyumna2905/level | 186878a128521074923edd7171eda2f1b181b4f4 | [
"Apache-2.0"
] | null | null | null | defmodule Level.Users.UserTest do
use Level.DataCase, async: true
alias Level.Users.User
describe "create_changeset/2" do
test "validates with valid data" do
changeset = User.create_changeset(%User{}, valid_user_params())
assert changeset.valid?
end
test "sets the default time zone if one is not provided" do
{_value, params} = Map.pop(valid_user_params(), :time_zone)
changeset = User.create_changeset(%User{}, params)
%{time_zone: time_zone} = changeset.changes
assert changeset.valid?
assert time_zone == "UTC"
end
test "sets the default time zone if provided value is blank" do
params = Map.put(valid_user_params(), :time_zone, "")
changeset = User.create_changeset(%User{}, params)
%{time_zone: time_zone} = changeset.changes
assert changeset.valid?
assert time_zone == "UTC"
end
test "hashes the password" do
changeset = User.create_changeset(%User{}, valid_user_params())
%{password: password, password_hash: password_hash} = changeset.changes
assert password_hash
assert Comeonin.Bcrypt.checkpw(password, password_hash)
end
test "sets random session salt" do
changeset = User.create_changeset(%User{}, valid_user_params())
%{session_salt: salt} = changeset.changes
assert String.length(salt) == 32
end
end
describe "email_format/0" do
test "matches valid email addresses" do
assert Regex.match?(User.email_format(), "derrick@gmail.com")
assert Regex.match?(User.email_format(), "der-rick@gmail.com")
assert Regex.match?(User.email_format(), "der.ric%k@gmail.co")
assert Regex.match?(User.email_format(), "derrick+123@level.live")
assert Regex.match?(User.email_format(), "OLDERGENTLEMAN@GMAIL.COM")
end
test "does not match invalid addresses" do
refute Regex.match?(User.email_format(), "der rick@gmail.com")
refute Regex.match?(User.email_format(), "foo@")
end
end
end
| 33.566667 | 77 | 0.682721 |
ff267cfbdd982843a9d81398e8de5010dd521394 | 27,867 | ex | Elixir | lib/mint/core/transport/ssl.ex | ryochin/mint | 1ea7731d921840ad75a47fa9415525c3d94b9980 | [
"Apache-2.0"
] | 477 | 2019-10-28T14:53:23.000Z | 2022-03-30T08:13:21.000Z | lib/mint/core/transport/ssl.ex | ryochin/mint | 1ea7731d921840ad75a47fa9415525c3d94b9980 | [
"Apache-2.0"
] | 108 | 2019-11-05T04:21:04.000Z | 2022-02-24T18:36:15.000Z | lib/mint/core/transport/ssl.ex | ryochin/mint | 1ea7731d921840ad75a47fa9415525c3d94b9980 | [
"Apache-2.0"
] | 56 | 2019-11-10T01:19:56.000Z | 2022-03-25T18:08:06.000Z | defmodule Mint.Core.Transport.SSL do
@moduledoc false
require Logger
require Record
@behaviour Mint.Core.Transport
# From RFC7540 appendix A
@blocked_ciphers MapSet.new([
{:null, :null, :null},
{:rsa, :null, :md5},
{:rsa, :null, :sha},
{:rsa_export, :rc4_40, :md5},
{:rsa, :rc4_128, :md5},
{:rsa, :rc4_128, :sha},
{:rsa_export, :rc2_cbc_40, :md5},
{:rsa, :idea_cbc, :sha},
{:rsa_export, :des40_cbc, :sha},
{:rsa, :des_cbc, :sha},
{:rsa, :"3des_ede_cbc", :sha},
{:dh_dss_export, :des40_cbc, :sha},
{:dh_dss, :des_cbc, :sha},
{:dh_dss, :"3des_ede_cbc", :sha},
{:dh_rsa_export, :des40_cbc, :sha},
{:dh_rsa, :des_cbc, :sha},
{:dh_rsa, :"3des_ede_cbc", :sha},
{:dhe_dss_export, :des40_cbc, :sha},
{:dhe_dss, :des_cbc, :sha},
{:dhe_dss, :"3des_ede_cbc", :sha},
{:dhe_rsa_export, :des40_cbc, :sha},
{:dhe_rsa, :des_cbc, :sha},
{:dhe_rsa, :"3des_ede_cbc", :sha},
{:dh_anon_export, :rc4_40, :md5},
{:dh_anon, :rc4_128, :md5},
{:dh_anon_export, :des40_cbc, :sha},
{:dh_anon, :des_cbc, :sha},
{:dh_anon, :"3des_ede_cbc", :sha},
{:krb5, :des_cbc, :sha},
{:krb5, :"3des_ede_cbc", :sha},
{:krb5, :rc4_128, :sha},
{:krb5, :idea_cbc, :sha},
{:krb5, :des_cbc, :md5},
{:krb5, :"3des_ede_cbc", :md5},
{:krb5, :rc4_128, :md5},
{:krb5, :idea_cbc, :md5},
{:krb5_export, :des_cbc_40, :sha},
{:krb5_export, :rc2_cbc_40, :sha},
{:krb5_export, :rc4_40, :sha},
{:krb5_export, :des_cbc_40, :md5},
{:krb5_export, :rc2_cbc_40, :md5},
{:krb5_export, :rc4_40, :md5},
{:psk, :null, :sha},
{:dhe_psk, :null, :sha},
{:rsa_psk, :null, :sha},
{:rsa, :aes_128_cbc, :sha},
{:dh_dss, :aes_128_cbc, :sha},
{:dh_rsa, :aes_128_cbc, :sha},
{:dhe_dss, :aes_128_cbc, :sha},
{:dhe_rsa, :aes_128_cbc, :sha},
{:dh_anon, :aes_128_cbc, :sha},
{:rsa, :aes_256_cbc, :sha},
{:dh_dss, :aes_256_cbc, :sha},
{:dh_rsa, :aes_256_cbc, :sha},
{:dhe_dss, :aes_256_cbc, :sha},
{:dhe_rsa, :aes_256_cbc, :sha},
{:dh_anon, :aes_256_cbc, :sha},
{:rsa, :null, :sha256},
{:rsa, :aes_128_cbc, :sha256},
{:rsa, :aes_256_cbc, :sha256},
{:dh_dss, :aes_128_cbc, :sha256},
{:dh_rsa, :aes_128_cbc, :sha256},
{:dhe_dss, :aes_128_cbc, :sha256},
{:rsa, :camellia_128_cbc, :sha},
{:dh_dss, :camellia_128_cbc, :sha},
{:dh_rsa, :camellia_128_cbc, :sha},
{:dhe_dss, :camellia_128_cbc, :sha},
{:dhe_rsa, :camellia_128_cbc, :sha},
{:dh_anon, :camellia_128_cbc, :sha},
{:dhe_rsa, :aes_128_cbc, :sha256},
{:dh_dss, :aes_256_cbc, :sha256},
{:dh_rsa, :aes_256_cbc, :sha256},
{:dhe_dss, :aes_256_cbc, :sha256},
{:dhe_rsa, :aes_256_cbc, :sha256},
{:dh_anon, :aes_128_cbc, :sha256},
{:dh_anon, :aes_256_cbc, :sha256},
{:rsa, :camellia_256_cbc, :sha},
{:dh_dss, :camellia_256_cbc, :sha},
{:dh_rsa, :camellia_256_cbc, :sha},
{:dhe_dss, :camellia_256_cbc, :sha},
{:dhe_rsa, :camellia_256_cbc, :sha},
{:dh_anon, :camellia_256_cbc, :sha},
{:psk, :rc4_128, :sha},
{:psk, :"3des_ede_cbc", :sha},
{:psk, :aes_128_cbc, :sha},
{:psk, :aes_256_cbc, :sha},
{:dhe_psk, :rc4_128, :sha},
{:dhe_psk, :"3des_ede_cbc", :sha},
{:dhe_psk, :aes_128_cbc, :sha},
{:dhe_psk, :aes_256_cbc, :sha},
{:rsa_psk, :rc4_128, :sha},
{:rsa_psk, :"3des_ede_cbc", :sha},
{:rsa_psk, :aes_128_cbc, :sha},
{:rsa_psk, :aes_256_cbc, :sha},
{:rsa, :seed_cbc, :sha},
{:dh_dss, :seed_cbc, :sha},
{:dh_rsa, :seed_cbc, :sha},
{:dhe_dss, :seed_cbc, :sha},
{:dhe_rsa, :seed_cbc, :sha},
{:dh_anon, :seed_cbc, :sha},
{:rsa, :aes_128_gcm, :sha256},
{:rsa, :aes_256_gcm, :sha384},
{:dh_rsa, :aes_128_gcm, :sha256},
{:dh_rsa, :aes_256_gcm, :sha384},
{:dh_dss, :aes_128_gcm, :sha256},
{:dh_dss, :aes_256_gcm, :sha384},
{:dh_anon, :aes_128_gcm, :sha256},
{:dh_anon, :aes_256_gcm, :sha384},
{:psk, :aes_128_gcm, :sha256},
{:psk, :aes_256_gcm, :sha384},
{:rsa_psk, :aes_128_gcm, :sha256},
{:rsa_psk, :aes_256_gcm, :sha384},
{:psk, :aes_128_cbc, :sha256},
{:psk, :aes_256_cbc, :sha384},
{:psk, :null, :sha256},
{:psk, :null, :sha384},
{:dhe_psk, :aes_128_cbc, :sha256},
{:dhe_psk, :aes_256_cbc, :sha384},
{:dhe_psk, :null, :sha256},
{:dhe_psk, :null, :sha384},
{:rsa_psk, :aes_128_cbc, :sha256},
{:rsa_psk, :aes_256_cbc, :sha384},
{:rsa_psk, :null, :sha256},
{:rsa_psk, :null, :sha384},
{:rsa, :camellia_128_cbc, :sha256},
{:dh_dss, :camellia_128_cbc, :sha256},
{:dh_rsa, :camellia_128_cbc, :sha256},
{:dhe_dss, :camellia_128_cbc, :sha256},
{:dhe_rsa, :camellia_128_cbc, :sha256},
{:dh_anon, :camellia_128_cbc, :sha256},
{:rsa, :camellia_256_cbc, :sha256},
{:dh_dss, :camellia_256_cbc, :sha256},
{:dh_rsa, :camellia_256_cbc, :sha256},
{:dhe_dss, :camellia_256_cbc, :sha256},
{:dhe_rsa, :camellia_256_cbc, :sha256},
{:dh_anon, :camellia_256_cbc, :sha256},
{:ecdh_ecdsa, :null, :sha},
{:ecdh_ecdsa, :rc4_128, :sha},
{:ecdh_ecdsa, :"3des_ede_cbc", :sha},
{:ecdh_ecdsa, :aes_128_cbc, :sha},
{:ecdh_ecdsa, :aes_256_cbc, :sha},
{:ecdhe_ecdsa, :null, :sha},
{:ecdhe_ecdsa, :rc4_128, :sha},
{:ecdhe_ecdsa, :"3des_ede_cbc", :sha},
{:ecdhe_ecdsa, :aes_128_cbc, :sha},
{:ecdhe_ecdsa, :aes_256_cbc, :sha},
{:ecdh_rsa, :null, :sha},
{:ecdh_rsa, :rc4_128, :sha},
{:ecdh_rsa, :"3des_ede_cbc", :sha},
{:ecdh_rsa, :aes_128_cbc, :sha},
{:ecdh_rsa, :aes_256_cbc, :sha},
{:ecdhe_rsa, :null, :sha},
{:ecdhe_rsa, :rc4_128, :sha},
{:ecdhe_rsa, :"3des_ede_cbc", :sha},
{:ecdhe_rsa, :aes_128_cbc, :sha},
{:ecdhe_rsa, :aes_256_cbc, :sha},
{:ecdh_anon, :null, :sha},
{:ecdh_anon, :rc4_128, :sha},
{:ecdh_anon, :"3des_ede_cbc", :sha},
{:ecdh_anon, :aes_128_cbc, :sha},
{:ecdh_anon, :aes_256_cbc, :sha},
{:srp_sha, :"3des_ede_cbc", :sha},
{:srp_sha_rsa, :"3des_ede_cbc", :sha},
{:srp_sha_dss, :"3des_ede_cbc", :sha},
{:srp_sha, :aes_128_cbc, :sha},
{:srp_sha_rsa, :aes_128_cbc, :sha},
{:srp_sha_dss, :aes_128_cbc, :sha},
{:srp_sha, :aes_256_cbc, :sha},
{:srp_sha_rsa, :aes_256_cbc, :sha},
{:srp_sha_dss, :aes_256_cbc, :sha},
{:ecdhe_ecdsa, :aes_128_cbc, :sha256},
{:ecdhe_ecdsa, :aes_256_cbc, :sha384},
{:ecdh_ecdsa, :aes_128_cbc, :sha256},
{:ecdh_ecdsa, :aes_256_cbc, :sha384},
{:ecdhe_rsa, :aes_128_cbc, :sha256},
{:ecdhe_rsa, :aes_256_cbc, :sha384},
{:ecdh_rsa, :aes_128_cbc, :sha256},
{:ecdh_rsa, :aes_256_cbc, :sha384},
{:ecdh_ecdsa, :aes_128_gcm, :sha256},
{:ecdh_ecdsa, :aes_256_gcm, :sha384},
{:ecdh_rsa, :aes_128_gcm, :sha256},
{:ecdh_rsa, :aes_256_gcm, :sha384},
{:ecdhe_psk, :rc4_128, :sha},
{:ecdhe_psk, :"3des_ede_cbc", :sha},
{:ecdhe_psk, :aes_128_cbc, :sha},
{:ecdhe_psk, :aes_256_cbc, :sha},
{:ecdhe_psk, :aes_128_cbc, :sha256},
{:ecdhe_psk, :aes_256_cbc, :sha384},
{:ecdhe_psk, :null, :sha},
{:ecdhe_psk, :null, :sha256},
{:ecdhe_psk, :null, :sha384},
{:rsa, :aria_128_cbc, :sha256},
{:rsa, :aria_256_cbc, :sha384},
{:dh_dss, :aria_128_cbc, :sha256},
{:dh_dss, :aria_256_cbc, :sha384},
{:dh_rsa, :aria_128_cbc, :sha256},
{:dh_rsa, :aria_256_cbc, :sha384},
{:dhe_dss, :aria_128_cbc, :sha256},
{:dhe_dss, :aria_256_cbc, :sha384},
{:dhe_rsa, :aria_128_cbc, :sha256},
{:dhe_rsa, :aria_256_cbc, :sha384},
{:dh_anon, :aria_128_cbc, :sha256},
{:dh_anon, :aria_256_cbc, :sha384},
{:ecdhe_ecdsa, :aria_128_cbc, :sha256},
{:ecdhe_ecdsa, :aria_256_cbc, :sha384},
{:ecdh_ecdsa, :aria_128_cbc, :sha256},
{:ecdh_ecdsa, :aria_256_cbc, :sha384},
{:ecdhe_rsa, :aria_128_cbc, :sha256},
{:ecdhe_rsa, :aria_256_cbc, :sha384},
{:ecdh_rsa, :aria_128_cbc, :sha256},
{:ecdh_rsa, :aria_256_cbc, :sha384},
{:rsa, :aria_128_gcm, :sha256},
{:rsa, :aria_256_gcm, :sha384},
{:dh_rsa, :aria_128_gcm, :sha256},
{:dh_rsa, :aria_256_gcm, :sha384},
{:dh_dss, :aria_128_gcm, :sha256},
{:dh_dss, :aria_256_gcm, :sha384},
{:dh_anon, :aria_128_gcm, :sha256},
{:dh_anon, :aria_256_gcm, :sha384},
{:ecdh_ecdsa, :aria_128_gcm, :sha256},
{:ecdh_ecdsa, :aria_256_gcm, :sha384},
{:ecdh_rsa, :aria_128_gcm, :sha256},
{:ecdh_rsa, :aria_256_gcm, :sha384},
{:psk, :aria_128_cbc, :sha256},
{:psk, :aria_256_cbc, :sha384},
{:dhe_psk, :aria_128_cbc, :sha256},
{:dhe_psk, :aria_256_cbc, :sha384},
{:rsa_psk, :aria_128_cbc, :sha256},
{:rsa_psk, :aria_256_cbc, :sha384},
{:psk, :aria_128_gcm, :sha256},
{:psk, :aria_256_gcm, :sha384},
{:rsa_psk, :aria_128_gcm, :sha256},
{:rsa_psk, :aria_256_gcm, :sha384},
{:ecdhe_psk, :aria_128_cbc, :sha256},
{:ecdhe_psk, :aria_256_cbc, :sha384},
{:ecdhe_ecdsa, :camellia_128_cbc, :sha256},
{:ecdhe_ecdsa, :camellia_256_cbc, :sha384},
{:ecdh_ecdsa, :camellia_128_cbc, :sha256},
{:ecdh_ecdsa, :camellia_256_cbc, :sha384},
{:ecdhe_rsa, :camellia_128_cbc, :sha256},
{:ecdhe_rsa, :camellia_256_cbc, :sha384},
{:ecdh_rsa, :camellia_128_cbc, :sha256},
{:ecdh_rsa, :camellia_256_cbc, :sha384},
{:rsa, :camellia_128_gcm, :sha256},
{:rsa, :camellia_256_gcm, :sha384},
{:dh_rsa, :camellia_128_gcm, :sha256},
{:dh_rsa, :camellia_256_gcm, :sha384},
{:dh_dss, :camellia_128_gcm, :sha256},
{:dh_dss, :camellia_256_gcm, :sha384},
{:dh_anon, :camellia_128_gcm, :sha256},
{:dh_anon, :camellia_256_gcm, :sha384},
{:ecdh_ecdsa, :camellia_128_gcm, :sha256},
{:ecdh_ecdsa, :camellia_256_gcm, :sha384},
{:ecdh_rsa, :camellia_128_gcm, :sha256},
{:ecdh_rsa, :camellia_256_gcm, :sha384},
{:psk, :camellia_128_gcm, :sha256},
{:psk, :camellia_256_gcm, :sha384},
{:rsa_psk, :camellia_128_gcm, :sha256},
{:rsa_psk, :camellia_256_gcm, :sha384},
{:psk, :camellia_128_cbc, :sha256},
{:psk, :camellia_256_cbc, :sha384},
{:dhe_psk, :camellia_128_cbc, :sha256},
{:dhe_psk, :camellia_256_cbc, :sha384},
{:rsa_psk, :camellia_128_cbc, :sha256},
{:rsa_psk, :camellia_256_cbc, :sha384},
{:ecdhe_psk, :camellia_128_cbc, :sha256},
{:ecdhe_psk, :camellia_256_cbc, :sha384},
{:rsa, :aes_128, :ccm},
{:rsa, :aes_256, :ccm},
{:rsa, :aes_128, :ccm_8},
{:rsa, :aes_256, :ccm_8},
{:psk, :aes_128, :ccm},
{:psk, :aes_256, :ccm},
{:psk, :aes_128, :ccm_8},
{:psk, :aes_256, :ccm_8}
])
@transport_opts [
packet: :raw,
mode: :binary,
active: false
]
@default_versions [:"tlsv1.3", :"tlsv1.2"]
@default_timeout 30_000
Record.defrecordp(
:certificate,
:Certificate,
Record.extract(:Certificate, from_lib: "public_key/include/OTP-PUB-KEY.hrl")
)
Record.defrecordp(
:tbs_certificate,
:OTPTBSCertificate,
Record.extract(:OTPTBSCertificate, from_lib: "public_key/include/OTP-PUB-KEY.hrl")
)
# TODO: Document how to enable revocation checking:
# crl_check: true
# crl_cache: {:ssl_crl_cache, {:internal, [http: 30_000]}}
@impl true
def connect(address, port, opts) do
hostname = Mint.Core.Util.hostname(opts, address)
opts = Keyword.delete(opts, :hostname)
connect(address, hostname, port, opts)
end
defp connect(address, hostname, port, opts) when is_binary(address),
do: connect(String.to_charlist(address), hostname, port, opts)
defp connect(address, hostname, port, opts) do
timeout = Keyword.get(opts, :timeout, @default_timeout)
inet6? = Keyword.get(opts, :inet6, false)
opts = ssl_opts(String.to_charlist(hostname), opts)
if inet6? do
# Try inet6 first, then fall back to the defaults provided by
# ssl/gen_tcp if connection fails.
case :ssl.connect(address, port, [:inet6 | opts], timeout) do
{:ok, sslsocket} ->
{:ok, sslsocket}
_error ->
wrap_err(:ssl.connect(address, port, opts, timeout))
end
else
# Use the defaults provided by ssl/gen_tcp.
wrap_err(:ssl.connect(address, port, opts, timeout))
end
end
@impl true
def upgrade(socket, :http, hostname, _port, opts) do
hostname = String.to_charlist(hostname)
timeout = Keyword.get(opts, :timeout, @default_timeout)
# Seems like this is not set in :ssl.connect/2 correctly, so set it explicitly
Mint.Core.Transport.TCP.setopts(socket, active: false)
wrap_err(:ssl.connect(socket, ssl_opts(hostname, opts), timeout))
end
def upgrade(_socket, :https, _hostname, _port, _opts) do
raise "nested SSL sessions are not supported"
end
@impl true
def negotiated_protocol(socket) do
wrap_err(:ssl.negotiated_protocol(socket))
end
@impl true
def send(socket, payload) do
wrap_err(:ssl.send(socket, payload))
end
@impl true
def close(socket) do
wrap_err(:ssl.close(socket))
end
@impl true
def recv(socket, bytes, timeout) do
wrap_err(:ssl.recv(socket, bytes, timeout))
end
@impl true
def controlling_process(socket, pid) do
# We do this dance because it's what gen_tcp does in Erlang. However, ssl
# doesn't do this so we need to do it ourselves. Implementation roughly
# taken from this:
# https://github.com/erlang/otp/blob/fc1f0444e32b039194189af97fb3d5358a2b91e3/lib/kernel/src/inet.erl#L1696-L1754
with {:ok, active: active} <- getopts(socket, [:active]),
:ok <- setopts(socket, active: false),
:ok <- forward_messages_to_new_controlling_process(socket, pid),
:ok <- wrap_err(:ssl.controlling_process(socket, pid)) do
if(active == :once, do: setopts(socket, active: :once), else: :ok)
end
end
defp forward_messages_to_new_controlling_process(socket, pid) do
receive do
{:ssl, ^socket, _data} = message ->
Kernel.send(pid, message)
forward_messages_to_new_controlling_process(socket, pid)
{:ssl_error, ^socket, error} ->
{:error, error}
{:ssl_closed, ^socket} ->
{:error, :closed}
after
0 ->
:ok
end
end
@impl true
def setopts(socket, opts) do
wrap_err(:ssl.setopts(socket, opts))
end
@impl true
def getopts(socket, opts) do
wrap_err(:ssl.getopts(socket, opts))
end
@impl true
def wrap_error(reason) do
%Mint.TransportError{reason: reason}
end
defp ssl_opts(hostname, opts) do
default_ssl_opts(hostname)
|> Keyword.merge(opts)
|> Keyword.merge(@transport_opts)
|> Keyword.drop([:timeout, :inet6])
|> add_verify_opts(hostname)
|> remove_incompatible_ssl_opts()
|> add_ciphers_opt()
end
defp add_verify_opts(opts, hostname) do
verify = Keyword.get(opts, :verify)
if verify == :verify_peer do
opts
|> add_cacerts()
|> add_partial_chain_fun()
|> customize_hostname_check(hostname)
else
opts
end
end
defp remove_incompatible_ssl_opts(opts) do
# These are the TLS versions that are compatible with :reuse_sessions and :secure_renegotiate
# If none of the compatible TLS versions are present in the transport options, then
# :reuse_sessions and :secure_renegotiate will be removed from the transport options.
compatible_versions = [:tlsv1, :"tlsv1.1", :"tlsv1.2"]
versions_opt = Keyword.get(opts, :versions, [])
if Enum.any?(compatible_versions, &(&1 in versions_opt)) do
opts
else
opts
|> Keyword.delete(:reuse_sessions)
|> Keyword.delete(:secure_renegotiate)
end
end
defp customize_hostname_check(opts, host_or_ip) do
if ssl_version() >= [9, 0] do
# From OTP 20.0 use built-in support for custom hostname checks
add_customize_hostname_check(opts)
else
# Before OTP 20.0 use mint_shims for hostname check, from a custom
# verify_fun
add_verify_fun(opts, host_or_ip)
end
end
defp add_customize_hostname_check(opts) do
customize_hostname_check_present? = Keyword.has_key?(opts, :customize_hostname_check)
if not customize_hostname_check_present? do
Keyword.put(opts, :customize_hostname_check, match_fun: &match_fun/2)
else
opts
end
end
defp add_verify_fun(opts, host_or_ip) do
verify_fun_present? = Keyword.has_key?(opts, :verify_fun)
if not verify_fun_present? do
reference_ids = [dns_id: host_or_ip, ip: host_or_ip]
Keyword.put(opts, :verify_fun, {&verify_fun/3, reference_ids})
else
opts
end
end
def verify_fun(_, {:bad_cert, _} = reason, _), do: {:fail, reason}
def verify_fun(_, {:extension, _}, state), do: {:unknown, state}
def verify_fun(_, :valid, state), do: {:valid, state}
def verify_fun(cert, :valid_peer, state) do
if :mint_shims.pkix_verify_hostname(cert, state, match_fun: &match_fun/2) do
{:valid, state}
else
{:fail, {:bad_cert, :hostname_check_failed}}
end
end
# Wildcard domain handling for DNS ID entries in the subjectAltName X.509
# extension. Note that this is a subset of the wildcard patterns implemented
# by OTP when matching against the subject CN attribute, but this is the only
# wildcard usage defined by the CA/Browser Forum's Baseline Requirements, and
# therefore the only pattern used in commercially issued certificates.
defp match_fun({:dns_id, reference}, {:dNSName, [?*, ?. | presented]}) do
case domain_without_host(reference) do
'' ->
:default
domain ->
# TODO: replace with `:string.casefold/1` eventually
:string.to_lower(domain) == :string.to_lower(presented)
end
end
defp match_fun(_reference, _presented), do: :default
defp domain_without_host([]), do: []
defp domain_without_host([?. | domain]), do: domain
defp domain_without_host([_ | more]), do: domain_without_host(more)
defp add_ciphers_opt(opts) do
Keyword.put_new_lazy(opts, :ciphers, fn ->
versions = opts[:versions]
get_ciphers_for_versions(versions)
end)
end
defp default_ssl_opts(hostname) do
# TODO: Add revocation check
# Note: the :ciphers option is added once the :versions option
# has been merged with the user-specified value
[
server_name_indication: hostname,
versions: ssl_versions(),
verify: :verify_peer,
depth: 4,
secure_renegotiate: true,
reuse_sessions: true
]
end
@doc false
def ssl_versions() do
available_versions = :ssl.versions()[:available]
versions = Enum.filter(@default_versions, &(&1 in available_versions))
# Remove buggy TLS 1.3 versions
if ssl_version() < [10, 0] do
versions -- [:"tlsv1.3"]
else
versions
end
end
defp add_cacerts(opts) do
if Keyword.has_key?(opts, :cacertfile) || Keyword.has_key?(opts, :cacerts) do
opts
else
raise_on_missing_castore!()
Keyword.put(opts, :cacertfile, CAStore.file_path())
end
end
defp add_partial_chain_fun(opts) do
if Keyword.has_key?(opts, :partial_chain) do
opts
else
case Keyword.fetch(opts, :cacerts) do
{:ok, cacerts} ->
cacerts = decode_cacerts(cacerts)
fun = &partial_chain(cacerts, &1)
Keyword.put(opts, :partial_chain, fun)
:error ->
path = Keyword.fetch!(opts, :cacertfile)
cacerts = get_cacertfile(path)
fun = &partial_chain(cacerts, &1)
Keyword.put(opts, :partial_chain, fun)
end
end
end
defp get_cacertfile(path) do
if Application.get_env(:mint, :persistent_term) do
case :persistent_term.get({:mint, {:cacertfile, path}}, :error) do
{:ok, cacerts} ->
cacerts
:error ->
cacerts = decode_cacertfile(path)
:persistent_term.put({:mint, {:cacertfile, path}}, {:ok, cacerts})
cacerts
end
else
decode_cacertfile(path)
end
end
defp decode_cacertfile(path) do
path
|> File.read!()
|> :public_key.pem_decode()
|> Enum.filter(&match?({:Certificate, _, :not_encrypted}, &1))
|> Enum.map(&:public_key.pem_entry_decode/1)
end
defp decode_cacerts(certs) do
Enum.map(certs, &:public_key.pkix_decode_cert(&1, :plain))
end
def partial_chain(cacerts, certs) do
# TODO: Shim this with OTP 21.1 implementation?
certs =
certs
|> Enum.map(&{&1, :public_key.pkix_decode_cert(&1, :plain)})
|> Enum.drop_while(&cert_expired?/1)
trusted =
Enum.find_value(certs, fn {der, cert} ->
trusted? =
Enum.find(cacerts, fn cacert ->
extract_public_key_info(cacert) == extract_public_key_info(cert)
end)
if trusted?, do: der
end)
if trusted do
{:trusted_ca, trusted}
else
:unknown_ca
end
end
defp cert_expired?({_der, cert}) do
now = DateTime.utc_now()
{not_before, not_after} = extract_validity(cert)
DateTime.compare(now, not_before) == :lt or
DateTime.compare(now, not_after) == :gt
end
defp extract_validity(cert) do
{:Validity, not_before, not_after} =
cert
|> certificate(:tbsCertificate)
|> tbs_certificate(:validity)
{to_datetime!(not_before), to_datetime!(not_after)}
end
defp extract_public_key_info(cert) do
cert
|> certificate(:tbsCertificate)
|> tbs_certificate(:subjectPublicKeyInfo)
end
defp to_datetime!({:utcTime, time}) do
"20#{time}"
|> to_datetime!()
end
defp to_datetime!({:generalTime, time}) do
time
|> to_string()
|> to_datetime!()
end
defp to_datetime!(
<<year::binary-size(4), month::binary-size(2), day::binary-size(2), hour::binary-size(2),
minute::binary-size(2), second::binary-size(2), "Z"::binary>>
) do
{:ok, datetime, _} =
DateTime.from_iso8601("#{year}-#{month}-#{day}T#{hour}:#{minute}:#{second}Z")
datetime
end
defp blocked_cipher?(%{cipher: cipher, key_exchange: kex, prf: prf}),
do: blocked_cipher?({kex, cipher, prf})
defp blocked_cipher?({kex, cipher, _mac, prf}), do: blocked_cipher?({kex, cipher, prf})
defp blocked_cipher?({_kex, _cipher, _prf} = suite), do: suite in @blocked_ciphers
defp raise_on_missing_castore! do
Code.ensure_loaded?(CAStore) ||
raise "default CA trust store not available; " <>
"please add `:castore` to your project's dependencies or " <>
"specify the trust store using the `:cacertfile`/`:cacerts` option"
end
defp wrap_err({:error, reason}), do: {:error, wrap_error(reason)}
defp wrap_err(other), do: other
@doc false
def ssl_version() do
Application.spec(:ssl, :vsn)
|> List.to_string()
|> String.split(".")
|> Enum.map(&String.to_integer/1)
end
@doc false
def get_ciphers_for_versions(versions) do
if ssl_version() >= [8, 2, 4] do
# :ssl.filter_cipher_suites/2 is available in ssl v8.2.4+
versions
|> Enum.flat_map(&:ssl.filter_cipher_suites(:ssl.cipher_suites(:all, &1), []))
|> Enum.uniq()
else
:ssl.cipher_suites(:all)
end
|> Enum.reject(&blocked_cipher?/1)
end
end
| 38.226337 | 117 | 0.524599 |
ff269b67b30ce01b841732f127158ab3cff5f975 | 5,459 | ex | Elixir | apps/site/lib/trip_info.ex | noisecapella/dotcom | d5ef869412102d2230fac3dcc216f01a29726227 | [
"MIT"
] | 42 | 2019-05-29T16:05:30.000Z | 2021-08-09T16:03:37.000Z | apps/site/lib/trip_info.ex | noisecapella/dotcom | d5ef869412102d2230fac3dcc216f01a29726227 | [
"MIT"
] | 872 | 2019-05-29T17:55:50.000Z | 2022-03-30T09:28:43.000Z | apps/site/lib/trip_info.ex | noisecapella/dotcom | d5ef869412102d2230fac3dcc216f01a29726227 | [
"MIT"
] | 12 | 2019-07-01T18:33:21.000Z | 2022-03-10T02:13:57.000Z | defmodule TripInfo do
require Routes.Route
alias Fares.OneWay
@moduledoc """
Wraps the important information about a trip.
* route: the %Routes.Route{} the trip is on
* origin_id: the ID of the stop where we consider the trip to start.
This is either the real start, or the origin the user selected.
* destination_id: the ID of the stop where we consider the trip to end.
This is either the real end, or the destination that the user selected.
* vehicle: a %Vehicles.Vehicle{} that's on this trip, or nil
* status: a text status of the trip relative to the schedule
* times: a list of PredictedSchedules, for stops between either
1) the origin and destination or 2) the vehicle and destination
* stop_count: number of stops between either 1) the origin and the destination
or 2) the vehicle and destination
* duration: the number of minutes the trip takes between origin_id and destination_id
* base_fare: The minimum, non-discounted, one-way fare for the trip
"""
@type time :: PredictedSchedule.t()
@type time_list :: [time]
@type t :: %__MODULE__{
route: Routes.Route.t(),
origin_id: String.t(),
destination_id: String.t(),
vehicle: Vehicles.Vehicle.t() | nil,
vehicle_stop_name: String.t() | nil,
status: String.t(),
times: time_list,
stop_count: pos_integer,
duration: pos_integer | nil,
base_fare: Fares.Fare.t()
}
defstruct route: nil,
origin_id: nil,
destination_id: nil,
vehicle: nil,
vehicle_stop_name: nil,
status: "operating at normal schedule",
times: [],
stop_count: 0,
duration: -1,
base_fare: nil
@doc """
Given a list of times and options, creates a new TripInfo struct or returns an error.
"""
@spec from_list(time_list, Keyword.t()) :: TripInfo.t() | {:error, any}
def from_list(times, opts \\ []) do
origin_id = time_stop_id(opts[:origin_id], times, :first)
destination_id = time_stop_id(opts[:destination_id], times, :last)
vehicle_stop_name = opts[:vehicle_stop_name]
starting_stop_ids =
if opts[:vehicle] do
[origin_id, opts[:vehicle].stop_id]
else
[origin_id]
end
times
|> clamp_times_to_origin_destination(origin_id, destination_id)
|> do_from_list(starting_stop_ids, destination_id, vehicle_stop_name, opts)
end
# finds a stop ID. If one isn't provided, or is provided as nil, then
# use a List function to get the stop ID from the times list.
@spec time_stop_id(String.t(), time_list, :first | :last) :: String.t() | nil
defp time_stop_id(stop_id_from_opts, times, list_function)
defp time_stop_id(stop_id, _, _) when is_binary(stop_id) do
stop_id
end
defp time_stop_id(_, [], _) do
nil
end
defp time_stop_id(_, times, list_function) do
List
|> apply(list_function, [times])
|> PredictedSchedule.stop()
|> (fn stop -> stop.id end).()
end
defp do_from_list(
[time, _ | _] = times,
[origin_id | _],
destination_id,
vehicle_stop_name,
opts
)
when is_binary(origin_id) and is_binary(destination_id) do
route = PredictedSchedule.route(time)
trip = PredictedSchedule.trip(time)
duration = duration(times, origin_id)
stop_count = Enum.count(times)
base_fare = OneWay.recommended_fare(route, trip, origin_id, destination_id)
%TripInfo{
route: route,
origin_id: origin_id,
destination_id: destination_id,
vehicle: opts[:vehicle],
times: times,
duration: duration,
stop_count: stop_count,
vehicle_stop_name: vehicle_stop_name,
base_fare: base_fare
}
end
defp do_from_list(_times, _starting_stop_ids, _destination_id, _vehicle_stop_name, _opts) do
{:error, "not enough times to build a trip"}
end
# Filters the list of times to those between origin and destination,
# inclusive. If the origin is after the trip, or one/both are not
# included, the behavior is undefined.
@spec clamp_times_to_origin_destination(time_list, String.t(), String.t()) :: time_list
defp clamp_times_to_origin_destination(times, origin_id, destination_id) do
case Enum.drop_while(times, &(origin_id != PredictedSchedule.stop(&1).id)) do
[origin | rest] ->
[origin | clamp_to_destination(rest, destination_id, [])]
[] ->
[]
end
end
defp clamp_to_destination([], _destination_id, _acc) do
# if we get to the end of the list without finding the destination, don't
# return anything.
[]
end
defp clamp_to_destination([time | rest], destination_id, acc) do
if PredictedSchedule.stop(time).id == destination_id do
[time | acc]
|> Enum.reverse()
else
clamp_to_destination(rest, destination_id, [time | acc])
end
end
defp duration(times, origin_id) do
first = Enum.find(times, &(PredictedSchedule.stop(&1).id == origin_id))
last = List.last(times)
duration_diff(PredictedSchedule.time(last), PredictedSchedule.time(first))
end
@spec duration_diff(DateTime.t() | nil, DateTime.t() | nil) ::
Timex.Duration.t() | integer | {:error, term}
defp duration_diff(nil, _), do: nil
defp duration_diff(_, nil), do: nil
defp duration_diff(last, first), do: Timex.diff(last, first, :minutes)
end
| 33.906832 | 94 | 0.663675 |
ff26c67856a925794bc17d87e9e37192ed3b4f74 | 2,036 | exs | Elixir | apps/artemis/test/artemis/contexts/user_recognition/delete_user_recognition_test.exs | artemis-platform/artemis_teams | 9930c3d9528e37b76f0525390e32b66eed7eadde | [
"MIT"
] | 2 | 2020-04-23T02:29:18.000Z | 2020-07-07T13:13:17.000Z | apps/artemis/test/artemis/contexts/user_recognition/delete_user_recognition_test.exs | chrislaskey/artemis_teams | 9930c3d9528e37b76f0525390e32b66eed7eadde | [
"MIT"
] | 4 | 2020-04-26T20:35:36.000Z | 2020-11-10T22:13:19.000Z | apps/artemis/test/artemis/contexts/user_recognition/delete_user_recognition_test.exs | chrislaskey/artemis_teams | 9930c3d9528e37b76f0525390e32b66eed7eadde | [
"MIT"
] | null | null | null | defmodule Artemis.DeleteUserRecognitionTest do
use Artemis.DataCase
import Artemis.Factories
alias Artemis.UserRecognition
alias Artemis.DeleteUserRecognition
describe "call!" do
test "raises an exception when id not found" do
invalid_id = 50_000_000
assert_raise Artemis.Context.Error, fn ->
DeleteUserRecognition.call!(invalid_id, Mock.system_user())
end
end
test "deletes a record when passed valid params" do
record = insert(:user_recognition)
%UserRecognition{} = DeleteUserRecognition.call!(record, Mock.system_user())
assert Repo.get(UserRecognition, record.id) == nil
end
test "deletes a record when passed an id and valid params" do
record = insert(:user_recognition)
%UserRecognition{} = DeleteUserRecognition.call!(record.id, Mock.system_user())
assert Repo.get(UserRecognition, record.id) == nil
end
end
describe "call" do
test "returns an error when record not found" do
invalid_id = 50_000_000
{:error, _} = DeleteUserRecognition.call(invalid_id, Mock.system_user())
end
test "deletes a record when passed valid params" do
record = insert(:user_recognition)
{:ok, _} = DeleteUserRecognition.call(record, Mock.system_user())
assert Repo.get(UserRecognition, record.id) == nil
end
test "deletes a record when passed an id and valid params" do
record = insert(:user_recognition)
{:ok, _} = DeleteUserRecognition.call(record.id, Mock.system_user())
assert Repo.get(UserRecognition, record.id) == nil
end
end
describe "broadcasts" do
test "publishes event and record" do
ArtemisPubSub.subscribe(Artemis.Event.get_broadcast_topic())
{:ok, user_recognition} = DeleteUserRecognition.call(insert(:user_recognition), Mock.system_user())
assert_received %Phoenix.Socket.Broadcast{
event: "user-recognition:deleted",
payload: %{
data: ^user_recognition
}
}
end
end
end
| 27.513514 | 105 | 0.689587 |
ff26d1404ab49ffba03eb6c7beb4b12874e5f77f | 1,720 | ex | Elixir | elixir_runtime/lib/mix/tasks/build.ex | Sailias/aws-lambda-elixir-runtime | 70808bdebda270b8402a0b6ac875f0a948a920e6 | [
"MIT-0"
] | 3 | 2019-09-10T22:12:27.000Z | 2022-01-06T01:21:04.000Z | elixir_runtime/lib/mix/tasks/build.ex | StratoSpire/aws-lambda-elixir-runtime | 68259e321edf6e975a2e7e257a98603b243de87a | [
"MIT-0"
] | null | null | null | elixir_runtime/lib/mix/tasks/build.ex | StratoSpire/aws-lambda-elixir-runtime | 68259e321edf6e975a2e7e257a98603b243de87a | [
"MIT-0"
] | 2 | 2020-08-13T05:37:17.000Z | 2022-01-06T01:24:02.000Z | defmodule Mix.Tasks.Lambda.Build.Docker do
use Mix.Task
@shortdoc "Uses Docker to build a release zip for deployment to Lambda"
@moduledoc """
Uses Docker to build a release zip for deployment to Lambda.
```
mix lambda.build
```
## Examples
```
❯ mix lambda.build
Building elixir_lambda_example version 0.1.0
. . .
Lambda release built
Artifact: _build/dev/rel/elixir_lambda_example/lambda.dev.zip
```
"""
def run(_args) do
version = Mix.Project.config()[:version]
app = app_name()
env = Mix.env()
dockerfile = Path.expand("#{__DIR__}/../../../priv/docker/Dockerfile.build")
image = "#{app}:#{version}_#{env}"
container = "#{app}_#{version}_#{env}"
release_dir = "_build/#{env}/rel/#{app}"
zipfile = "_build/#{env}/rel/#{app}_lambda.zip"
Mix.shell().info("Building #{app} version #{version} #{env} release")
File.mkdir_p(release_dir)
commands = [
"docker rm #{container} > /dev/null 2>&1 || true",
"docker build --build-arg MIX_ENV=#{env} -t #{image} -f #{dockerfile} .",
"docker run --name #{container} #{image}",
"docker cp #{container}:/workspace/#{zipfile} #{zipfile}",
"docker rm #{container}"
]
Enum.each(commands, fn command ->
Mix.shell().cmd(command)
|> case do
0 ->
:ok
status ->
Mix.shell().error("Build failed")
Mix.raise("Exit status: #{inspect(status)}")
end
end)
Mix.shell().info("Lambda release built")
Mix.shell().info("Artifact: #{release_dir}/lambda.#{env}.zip")
end
defp app_name() do
Mix.Project.config()
|> Keyword.fetch!(:app)
|> to_string
end
end
| 26.060606 | 80 | 0.590116 |
ff26d626ceb79427ccdf5754009bb36d20ae62dc | 3,595 | ex | Elixir | web/controllers/list_controller.ex | robot-overlord/todo-example | 2877bf3dc94e857a576fdc922c040c6af2f68ec0 | [
"MIT"
] | 1 | 2017-07-20T17:41:13.000Z | 2017-07-20T17:41:13.000Z | web/controllers/list_controller.ex | robot-overlord/todo-example | 2877bf3dc94e857a576fdc922c040c6af2f68ec0 | [
"MIT"
] | null | null | null | web/controllers/list_controller.ex | robot-overlord/todo-example | 2877bf3dc94e857a576fdc922c040c6af2f68ec0 | [
"MIT"
] | null | null | null | defmodule Todo.ListController do
alias Todo.{List, User, Item}
use Todo.Web, :controller
@spec index(Plug.Conn.t(), map()) :: Plug.Conn.t()
def index(conn, _params) do
render(conn, "index.html", lists: Repo.all(List), conn: conn)
end
@spec show(Plug.Conn.t(), map()) :: Plug.Conn.t()
def show(conn, %{"id" => id}) do
list =
List
|> Repo.get!(id)
|> Repo.preload([:users, [items: :list]])
render(conn, "show.html", list: list, conn: conn)
end
@spec new(Plug.Conn.t(), map()) :: Plug.Conn.t()
def new(conn, _params), do: render(conn, "new.html", changeset: List.changeset(%List{}))
@spec create(Plug.Conn.t(), map()) :: Plug.Conn.t()
def create(conn, %{"list" => list_params}) do
List
|> struct()
|> List.changeset(list_params)
|> Repo.insert()
|> case do
{:ok, %{name: name} = list} ->
Todo.EventChannel.broadcast_create(list)
conn
|> put_flash(:info, "#{name} created!")
|> redirect(to: list_path(conn, :show, list))
{:error, changeset} ->
conn
|> put_status(422)
|> put_flash(:error, "Problem creating list!")
|> render("new.html", conn: conn, changeset: changeset)
end
end
@spec edit(Plug.Conn.t(), map()) :: Plug.Conn.t()
def edit(conn, %{"id" => id}) do
list = Repo.one!(from list in List, where: list.id == ^id, preload: [:items, :users])
all_users = Repo.all(from user in User, select: {user.name, user.id})
list_items = Enum.map(list.items, fn item -> {item.name, item.id} end)
render(
conn,
"edit.html",
changeset: List.changeset(list),
conn: conn,
list: list,
all_users: all_users,
member_ids: Enum.map(list.users, fn list -> list.id end),
list_items: list_items,
list_item_ids: Enum.map(list.items, fn item -> item.id end)
)
end
@spec update(Plug.Conn.t(), map()) :: Plug.Conn.t()
def update(conn, %{"id" => id, "list" => list_params}) do
list = Repo.one!(from list in List, where: list.id == ^id, preload: [:items, :users])
item_ids = Map.get(list_params, "item_ids", [])
items = Repo.all(from item in Item, where: item.id in ^item_ids)
member_ids = Map.get(list_params, "user_ids", [])
members = Repo.all(from member in User, where: member.id in ^member_ids)
normalized_params =
list_params
|> Map.put("items", items)
|> Map.put("users", members)
changeset = List.changeset(list, normalized_params)
changeset
|> Repo.update()
|> case do
{:ok, %{name: name} = list} ->
Todo.EventChannel.broadcast_update(changeset)
conn
|> put_flash(:info, "#{name} updated!")
|> redirect(to: list_path(conn, :show, list))
{:error, changeset} ->
conn
|> put_status(422)
|> put_flash(:error, "Problem updating list!")
|> render("edit.html", conn: conn, changeset: changeset)
end
end
@spec delete(Plug.Conn.t(), map()) :: Plug.Conn.t()
def delete(conn, %{"id" => id}) do
List
|> Repo.get!(id)
|> Repo.delete()
|> case do
{:ok, deleted} ->
Todo.EventChannel.broadcast_destroy(deleted)
redirect(conn, to: list_path(conn, :index))
{:error, survivor} ->
conn
|> put_status(422)
|> put_flash(:error, "Problem deleting list!")
|> render("show.html", conn: conn, list: Repo.preload(survivor, [:items, :members]))
end
end
end
| 30.726496 | 95 | 0.564673 |
ff26e10f8319609f8dfe128c17d47ea6fa8a23e8 | 3,240 | exs | Elixir | test/broker_test.exs | lafka/cicadabus | d40a9d8456dff80f81706a4425833b877abdcf36 | [
"BSD-3-Clause"
] | null | null | null | test/broker_test.exs | lafka/cicadabus | d40a9d8456dff80f81706a4425833b877abdcf36 | [
"BSD-3-Clause"
] | null | null | null | test/broker_test.exs | lafka/cicadabus | d40a9d8456dff80f81706a4425833b877abdcf36 | [
"BSD-3-Clause"
] | null | null | null | defmodule CicadaBus.BrokerTest do
use ExUnit.Case
alias CicadaBus.Event
alias CicadaBus
alias __MODULE__.Broker
defmodule Broker do
use CicadaBus.Handler
# this makes a queue but for each
deftopic "match/short/topic"
deftopic "match/wildcard/suffix/**"
deftopic "match/wildcard/*/path"
deftopic "match/wildcard/**/tail"
defhandle "inline/**", ev, _opts do
case ev.value do
{pid, ref} ->
send pid, {ref, :ok, 1}
_ ->
nil
end
end
defhandle "inline/**", %{value: {pid, ref}}, _opts do
send pid, {ref, :ok, 2}
end
defhandle "inline/**", %{meta: %{guarantee: :drop}} = ev, _opts do
{pid, ref} = ev.value
send pid, {ref, :should_fail, 3}
end
end
# Check matching. The explicit call to Broker.handle/1 means this is
# handeled outside of normal queue handling
test "topic matching", opts do
{:ok, broker} = Broker.start_link("match/**")
# Explicit
assert :ok = Broker.input(Event.new("match/short/topic", opts[:test]), broker, sync: true)
# wildcard suffix
assert :ok = Broker.input(Event.new("match/wildcard/suffix/should/match", opts[:test]), broker, sync: true)
# single wildcard path
assert :ok = Broker.input(Event.new("match/wildcard/single/path", opts[:test]), broker, sync: true)
# wildcard tail match
assert :ok = Broker.input(Event.new("match/wildcard/path/with/tail", opts[:test]), broker, sync: true)
# Matches even though there's no subscribers
assert :ok = Broker.input(Event.new("match/no-subscribers", opts[:test]), broker, sync: true)
# Dropped since the event is not accepted
assert :drop = Broker.input(Event.new("unmatched/ev", opts[:test]), broker, sync: true)
end
test "get topic" do
topic = "**"
{:ok, pid} = Broker.start_link(topic)
assert {:ok, "**"} == CicadaBus.topic(pid)
end
test "subscribe -> unsubscribe" do
topic = "**"
{:ok, pid} = Broker.start_link(topic)
{:ok, state} = Broker.subscribe(pid)
:ok = Broker.unsubscribe(state, pid)
assert {:error, :no_subscription} == Broker.unsubscribe(state, pid)
end
test "auto-unsubscribe on failure" do
topic = "**"
{:ok, pid} = Broker.start_link(topic)
{parent, ref} = {self(), make_ref()}
{child, monref} = spawn_monitor(fn ->
{:ok, state} = Broker.subscribe(pid)
send parent, {ref, :init, state}
Process.hibernate(:timer, :sleep, [10])
end)
assert_receive {^ref, :init, state}
send child, :continue
assert_receive {:DOWN, ^monref, :process, ^child, :normal}
assert {:error, :no_subscription} == Broker.unsubscribe(state, pid)
end
test "root level subscription" do
{:ok, broker} = Broker.start_link("**")
{:ok, ref} = Broker.subscribe(broker)
:ok = Broker.input(ev = Event.new("enqueue", :value), broker)
assert_receive {^ref, {:event, _ackref, ^ev}}
end
test "inline handler" do
{:ok, broker} = Broker.start_link("**")
:ok = Broker.input(Event.new("inline/event", {self(), ref = make_ref()}), broker)
assert_receive {^ref, :ok, 1}
assert_receive {^ref, :ok, 2}
refute_receive {^ref, :should_fail, 3}
end
end
| 26.341463 | 111 | 0.625926 |
ff26ed0aa54398a417cb4536c5645fe45e371b45 | 761 | ex | Elixir | test/support/channel_case.ex | swarut/movies-elixir-phoenix | d88f28c0e8c43529d3a28f98cce6034213a93b0d | [
"MIT"
] | 25 | 2015-10-26T18:20:30.000Z | 2022-01-28T17:53:01.000Z | test/support/channel_case.ex | swarut/movies-elixir-phoenix | d88f28c0e8c43529d3a28f98cce6034213a93b0d | [
"MIT"
] | 1 | 2015-10-28T08:43:36.000Z | 2015-10-28T08:43:36.000Z | test/support/channel_case.ex | swarut/movies-elixir-phoenix | d88f28c0e8c43529d3a28f98cce6034213a93b0d | [
"MIT"
] | 8 | 2016-08-10T16:26:02.000Z | 2021-09-29T06:11:39.000Z | defmodule MoviesElixirPhoenix.ChannelCase do
@moduledoc """
This module defines the test case to be used by
channel tests.
Such tests rely on `Phoenix.ChannelTest` and also
import other functionality to make it easier
to build and query models.
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 channels
use Phoenix.ChannelTest
# The default endpoint for testing
@endpoint MoviesElixirPhoenix.Endpoint
end
end
setup tags do
:ok
end
end
| 22.382353 | 56 | 0.726675 |
ff26fed4ff285d1f449b3360d58474965cfcca54 | 1,113 | exs | Elixir | config/config.exs | akshbn/larva | 396b3571c2f25b65d93739438819e52551d1f537 | [
"MIT"
] | null | null | null | config/config.exs | akshbn/larva | 396b3571c2f25b65d93739438819e52551d1f537 | [
"MIT"
] | null | null | null | config/config.exs | akshbn/larva | 396b3571c2f25b65d93739438819e52551d1f537 | [
"MIT"
] | null | null | null | # This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
# file won't be loaded nor affect the parent project. For this reason,
# if you want to provide default values for your application for
# 3rd-party users, it should be done in your "mix.exs" file.
# You can configure for your application as:
#
# config :larva, key: :value
#
# And access this configuration in your application as:
#
# Application.get_env(:larva, :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"
| 35.903226 | 73 | 0.750225 |
ff271ac86dc65ff98840f481379a6051fd863a50 | 271 | ex | Elixir | lib/porterage/deliverer_state.ex | mneudert/porterage | a49857a6e7b39e182c49b8f06275e83685b87b67 | [
"Apache-2.0"
] | 1 | 2020-01-13T23:59:51.000Z | 2020-01-13T23:59:51.000Z | lib/porterage/deliverer_state.ex | mneudert/porterage | a49857a6e7b39e182c49b8f06275e83685b87b67 | [
"Apache-2.0"
] | null | null | null | lib/porterage/deliverer_state.ex | mneudert/porterage | a49857a6e7b39e182c49b8f06275e83685b87b67 | [
"Apache-2.0"
] | null | null | null | defmodule Porterage.DelivererState do
@moduledoc false
alias Porterage.Deliverer
@type t :: %__MODULE__{
deliverer: module,
substate: Deliverer.state(),
supervisor: pid
}
defstruct [:deliverer, :substate, :supervisor]
end
| 19.357143 | 48 | 0.645756 |
ff271b927a6e33798772d9a2c9b8593a7ce5e183 | 1,216 | ex | Elixir | lib/squadster_web/views/error_helpers.ex | Squadster/squadster-api | cf04af79317148d7a08c649d5b5d0197722acb7a | [
"MIT"
] | null | null | null | lib/squadster_web/views/error_helpers.ex | Squadster/squadster-api | cf04af79317148d7a08c649d5b5d0197722acb7a | [
"MIT"
] | null | null | null | lib/squadster_web/views/error_helpers.ex | Squadster/squadster-api | cf04af79317148d7a08c649d5b5d0197722acb7a | [
"MIT"
] | null | null | null | defmodule SquadsterWeb.ErrorHelpers do
@moduledoc """
Conveniences for translating and building error messages.
"""
@doc """
Translates an error message using gettext.
"""
def translate_error({msg, opts}) do
# When using gettext, we typically pass the strings we want
# to translate as a static argument:
#
# # Translate "is invalid" in the "errors" domain
# dgettext("errors", "is invalid")
#
# # Translate the number of files with plural rules
# dngettext("errors", "1 file", "%{count} files", count)
#
# Because the error messages we show in our forms and APIs
# are defined inside Ecto, we need to translate them dynamically.
# This requires us to call the Gettext module passing our gettext
# backend as first argument.
#
# Note we use the "errors" domain, which means translations
# should be written to the errors.po file. The :count option is
# set by Ecto and indicates we should also apply plural rules.
if count = opts[:count] do
Gettext.dngettext(SquadsterWeb.Gettext, "errors", msg, msg, count, opts)
else
Gettext.dgettext(SquadsterWeb.Gettext, "errors", msg, opts)
end
end
end
| 35.764706 | 78 | 0.672697 |
ff27206eb0aaeeb0854db5cae023d2ba1291e05b | 881 | exs | Elixir | priv/repo/migrations/20180523013618_create_cms_jobs.exs | DavidAlphaFox/coderplanets_server | 3fd47bf3bba6cc04c9a34698201a60ad2f3e8254 | [
"Apache-2.0"
] | 1 | 2019-05-07T15:03:54.000Z | 2019-05-07T15:03:54.000Z | priv/repo/migrations/20180523013618_create_cms_jobs.exs | DavidAlphaFox/coderplanets_server | 3fd47bf3bba6cc04c9a34698201a60ad2f3e8254 | [
"Apache-2.0"
] | null | null | null | priv/repo/migrations/20180523013618_create_cms_jobs.exs | DavidAlphaFox/coderplanets_server | 3fd47bf3bba6cc04c9a34698201a60ad2f3e8254 | [
"Apache-2.0"
] | null | null | null | defmodule MastaniServer.Repo.Migrations.CreateCmsJobs do
use Ecto.Migration
def change do
create table(:cms_jobs) do
add(:title, :string)
add(:company, :string)
add(:bonus, :string)
add(:company_logo, :string)
add(:location, :string)
add(:desc, :text)
add(:body, :text)
add(:author_id, references(:cms_authors, on_delete: :delete_all), null: false)
add(:views, :integer, default: 0)
add(:link_addr, :string)
add(:link_source, :string)
add(:min_salary, :integer, default: 0)
add(:max_salary, :integer, default: 10_000_000)
add(:min_experience, :integer, default: 1)
add(:max_experience, :integer, default: 3)
add(:min_education, :string)
add(:digest, :string)
add(:length, :integer)
timestamps()
end
create(index(:cms_jobs, [:author_id]))
end
end
| 28.419355 | 84 | 0.628831 |
ff273943a9951a617ce71312952c4211cff22789 | 6,762 | ex | Elixir | lib/util/env.ex | IvanPereyra-23/PaaS | 0179c7b57645473308b0a295a70b6284ed220fbf | [
"Apache-2.0"
] | 1 | 2020-08-27T18:43:11.000Z | 2020-08-27T18:43:11.000Z | lib/util/env.ex | IvanPereyra-23/PaaS | 0179c7b57645473308b0a295a70b6284ed220fbf | [
"Apache-2.0"
] | null | null | null | lib/util/env.ex | IvanPereyra-23/PaaS | 0179c7b57645473308b0a295a70b6284ed220fbf | [
"Apache-2.0"
] | 1 | 2020-08-27T18:43:21.000Z | 2020-08-27T18:43:21.000Z | # Copyright(c) 2015-2020 ACCESS CO., LTD. All rights reserved.
use Croma
defmodule Antikythera.Env do
@moduledoc """
Module to provide helpers to access environment variables defined by antikythera.
## Environments and deployments
Antikythera instances and gears may run in the following two modes:
- As a mix project, when invoked by running `iex` or `mix` command-line tool.
- As an OTP release, which is generated by e.g. `antikythera_core.generate_release` task.
In general there are multiple deployments per antikythera instance.
To distingish the target deployment from code, antikythera defines the following environment variables:
- At compile time (for metaprogramming):
`ANTIKYTHERA_COMPILE_ENV` must be appropriately set; the value can be retrieved by `compile_env/0`.
- At runtime:
`ANTIKYTHERA_RUNTIME_ENV` must be appropriately set; the value can be retrieved by `runtime_env/0`.
It is the responsibility of antikythera instance administrators to correctly set these environment variables
when compiling/running antikythera and gears.
Possible values returned by `compile_env/0` and `runtime_env/0` are:
- names of deployments given by `:deployments` application config
- `:local` (running an OTP release at local machine for testing purpose)
- `:undefined`
As an example, if you set `:dev` and `:prod` in `:deployments`, then you get:
| | Mix.env() at compile-time | Mix.env() at runtime | compile_env(), runtime_env() |
|---------------------------+----------------------------------------+-------------------------+------------------------------|
| $ iex -S mix | :dev (toplevel), :prod (dependencies) | :dev | :undefined |
| $ mix test | :test (toplevel), :prod (dependencies) | :test | :undefined |
| $ mix antikythera_local.* | :prod | (:mix is not available) | :local |
| :dev deployment | :prod | (:mix is not available) | :dev |
| :prod deployment | :prod | (:mix is not available) | :prod |
You can use these values to distinguish the current context from your code.
"""
deployment_envs = Application.fetch_env!(:antikythera, :deployments) |> Keyword.keys()
use Croma.SubtypeOfAtom, values: (deployment_envs ++ [:local, :undefined])
alias Antikythera.{GearName, GearNameStr, Url}
alias AntikytheraCore.Handler.CowboyRouting, as: Routing
defmodule Mapping do
Enum.each(deployment_envs, fn env ->
env_str = Atom.to_string(env)
def env_var_to_atom(unquote(env_str)), do: unquote(env)
end)
def env_var_to_atom("local"), do: :local
def env_var_to_atom(_ ), do: :undefined
Enum.each(deployment_envs, fn env ->
def cloud?(unquote(env)), do: true
end)
def cloud?(_), do: false
end
defun no_listen?() :: boolean do
case System.get_env() do
%{"NO_LISTEN" => "true"} -> true
%{"TEST_MODE" => "blackbox_" <> _} -> true
_otherwise -> false
end
end
defun runtime_env() :: t , do: System.get_env("ANTIKYTHERA_RUNTIME_ENV") |> Mapping.env_var_to_atom()
defun running_on_mix_task?() :: boolean, do: System.get_env("ANTIKYTHERA_MIX_TASK_MODE") == "true"
defun running_with_release?() :: boolean, do: !running_on_mix_task?() && runtime_env() != :undefined
defun running_in_cloud?() :: boolean, do: !running_on_mix_task?() && Mapping.cloud?(runtime_env())
@compile_env System.get_env("ANTIKYTHERA_COMPILE_ENV") |> Mapping.env_var_to_atom()
@compiling_for_mix_task? System.get_env("ANTIKYTHERA_MIX_TASK_MODE") == "true"
@compiling_for_release? @compile_env != :undefined
@compiling_for_cloud? Mapping.cloud?(@compile_env)
defun compile_env() :: t , do: @compile_env
defun compiling_for_mix_task?() :: boolean, do: @compiling_for_mix_task?
defun compiling_for_release?() :: boolean, do: !compiling_for_mix_task?() && @compiling_for_release?
defun compiling_for_cloud?() :: boolean, do: !compiling_for_mix_task?() && @compiling_for_cloud?
@antikythera_instance_name Application.fetch_env!(:antikythera, :antikythera_instance_name)
defun antikythera_instance_name() :: atom, do: @antikythera_instance_name
@gear_action_timeout_default 10_000
@gear_action_timeout String.to_integer(System.get_env("GEAR_ACTION_TIMEOUT") || "#{@gear_action_timeout_default}")
@doc """
Timeout (in milli-seconds) for gear actions.
This can be configurable by specifying `"GEAR_ACTION_TIMEOUT"` environment variable when compiling antikythera.
Defaults to `#{@gear_action_timeout_default}`.
"""
defun gear_action_timeout() :: pos_integer, do: @gear_action_timeout
@default_port 8080
@default_port_during_test 8081
# To see which port number to use, we have to get the current mix environment at runtime,
# since `Mix.env()` always returns `:prod` during compilation of antikythera within a gear project.
# However, when running with an OTP release, `Mix.env/0` is not available at runtime
# (as `:mix` is not included in antikythera's runtime dependencies).
# Therefore we need both compile-time- and runtime-branching.
if @compiling_for_release? do
defp default_port_at_runtime(), do: @default_port
else
defp default_port_at_runtime(), do: (if Mix.env() == :test, do: @default_port_during_test, else: @default_port)
end
@doc """
TCP port to listen to for incoming web requests.
The port can be specified by `"PORT"` runtime environment variable.
Defaults to `#{@default_port_during_test}` during `mix test`, and `#{@default_port}` otherwise
(thus one can run both `iex -S mix` and `mix test` at the same time).
"""
defun port_to_listen() :: non_neg_integer do
case System.get_env("PORT") do
nil -> default_port_at_runtime()
port_str -> String.to_integer(port_str)
end
end
defun default_base_url(gear_name :: v[GearName.t | GearNameStr.t], env :: v[t] \\ @compile_env) :: Url.t do
if Mapping.cloud?(env) do
"https://" <> Routing.default_domain(gear_name, env)
else
"http://" <> Routing.default_domain(gear_name, env) <> ":#{port_to_listen()}"
end
end
defun asset_base_url(gear_name :: v[GearName.t | GearNameStr.t]) :: Url.t do
case Application.fetch_env!(:antikythera, :asset_cdn_endpoint) do
nil -> default_base_url(gear_name)
base_url -> base_url
end
end
end
| 47.286713 | 133 | 0.653505 |
ff274e69da7522c280805f6a6c1ffa9c874037b9 | 4,556 | ex | Elixir | clients/composer/lib/google_api/composer/v1beta1/model/status.ex | nuxlli/elixir-google-api | ecb8679ac7282b7dd314c3e20c250710ec6a7870 | [
"Apache-2.0"
] | null | null | null | clients/composer/lib/google_api/composer/v1beta1/model/status.ex | nuxlli/elixir-google-api | ecb8679ac7282b7dd314c3e20c250710ec6a7870 | [
"Apache-2.0"
] | null | null | null | clients/composer/lib/google_api/composer/v1beta1/model/status.ex | nuxlli/elixir-google-api | ecb8679ac7282b7dd314c3e20c250710ec6a7870 | [
"Apache-2.0"
] | null | null | null | # Copyright 2017 Google Inc.
#
# 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 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.Composer.V1beta1.Model.Status do
@moduledoc """
The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). The error model is designed to be: - Simple to use and understand for most users - Flexible enough to meet unexpected needs # Overview The `Status` message contains three pieces of data: error code, error message, and error details. The error code should be an enum value of google.rpc.Code, but it may accept additional error codes if needed. The error message should be a developer-facing English message that helps developers *understand* and *resolve* the error. If a localized user-facing error message is needed, put the localized message in the error details or localize it in the client. The optional error details may contain arbitrary information about the error. There is a predefined set of error detail types in the package `google.rpc` that can be used for common error conditions. # Language mapping The `Status` message is the logical representation of the error model, but it is not necessarily the actual wire format. When the `Status` message is exposed in different client libraries and different wire protocols, it can be mapped differently. For example, it will likely be mapped to some exceptions in Java, but more likely mapped to some error codes in C. # Other uses The error model and the `Status` message can be used in a variety of environments, either with or without APIs, to provide a consistent developer experience across different environments. Example uses of this error model include: - Partial errors. If a service needs to return partial errors to the client, it may embed the `Status` in the normal response to indicate the partial errors. - Workflow errors. A typical workflow has multiple steps. Each step may have a `Status` message for error reporting. - Batch operations. If a client uses batch request and batch response, the `Status` message should be used directly inside batch response, one for each error sub-response. - Asynchronous operations. If an API call embeds asynchronous operation results in its response, the status of those operations should be represented directly using the `Status` message. - Logging. If some API errors are stored in logs, the message `Status` could be used directly after any stripping needed for security/privacy reasons.
## Attributes
- code (integer()): The status code, which should be an enum value of google.rpc.Code. Defaults to: `null`.
- details ([Object]): A list of messages that carry the error details. There is a common set of message types for APIs to use. Defaults to: `null`.
- message (String.t): A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client. Defaults to: `null`.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:code => any(),
:details => list(GoogleApi.Composer.V1beta1.Model.Object.t()),
:message => any()
}
field(:code)
field(:details, as: GoogleApi.Composer.V1beta1.Model.Object, type: :list)
field(:message)
end
defimpl Poison.Decoder, for: GoogleApi.Composer.V1beta1.Model.Status do
def decode(value, options) do
GoogleApi.Composer.V1beta1.Model.Status.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.Composer.V1beta1.Model.Status do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 84.37037 | 2,549 | 0.756365 |
ff275b64a999986afeaf0832d1fe9daed9fbcd54 | 2,583 | ex | Elixir | clients/health_care/lib/google_api/health_care/v1/model/deidentify_config.ex | MasashiYokota/elixir-google-api | 975dccbff395c16afcb62e7a8e411fbb58e9ab01 | [
"Apache-2.0"
] | null | null | null | clients/health_care/lib/google_api/health_care/v1/model/deidentify_config.ex | MasashiYokota/elixir-google-api | 975dccbff395c16afcb62e7a8e411fbb58e9ab01 | [
"Apache-2.0"
] | 1 | 2020-12-18T09:25:12.000Z | 2020-12-18T09:25:12.000Z | clients/health_care/lib/google_api/health_care/v1/model/deidentify_config.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.HealthCare.V1.Model.DeidentifyConfig do
@moduledoc """
Configures de-id options specific to different types of content. Each submessage customizes the handling of an https://tools.ietf.org/html/rfc6838 media type or subtype. Configs are applied in a nested manner at runtime.
## Attributes
* `dicom` (*type:* `GoogleApi.HealthCare.V1.Model.DicomConfig.t`, *default:* `nil`) - Configures de-id of application/DICOM content.
* `fhir` (*type:* `GoogleApi.HealthCare.V1.Model.FhirConfig.t`, *default:* `nil`) - Configures de-id of application/FHIR content.
* `image` (*type:* `GoogleApi.HealthCare.V1.Model.ImageConfig.t`, *default:* `nil`) - Configures de-identification of image pixels wherever they are found in the source_dataset.
* `text` (*type:* `GoogleApi.HealthCare.V1.Model.TextConfig.t`, *default:* `nil`) - Configures de-identification of text wherever it is found in the source_dataset.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:dicom => GoogleApi.HealthCare.V1.Model.DicomConfig.t(),
:fhir => GoogleApi.HealthCare.V1.Model.FhirConfig.t(),
:image => GoogleApi.HealthCare.V1.Model.ImageConfig.t(),
:text => GoogleApi.HealthCare.V1.Model.TextConfig.t()
}
field(:dicom, as: GoogleApi.HealthCare.V1.Model.DicomConfig)
field(:fhir, as: GoogleApi.HealthCare.V1.Model.FhirConfig)
field(:image, as: GoogleApi.HealthCare.V1.Model.ImageConfig)
field(:text, as: GoogleApi.HealthCare.V1.Model.TextConfig)
end
defimpl Poison.Decoder, for: GoogleApi.HealthCare.V1.Model.DeidentifyConfig do
def decode(value, options) do
GoogleApi.HealthCare.V1.Model.DeidentifyConfig.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.HealthCare.V1.Model.DeidentifyConfig do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 46.125 | 222 | 0.740612 |
ff27604f7d72393b065504a90d33b759d1134517 | 16,756 | ex | Elixir | lib/estructura/hooks.ex | am-kantox/estructura | e319603bbe629e9c15cd7f6521ae82b4cfa3bcc5 | [
"MIT"
] | 12 | 2022-01-21T21:13:30.000Z | 2022-02-06T03:06:24.000Z | lib/estructura/hooks.ex | am-kantox/estructura | e319603bbe629e9c15cd7f6521ae82b4cfa3bcc5 | [
"MIT"
] | 7 | 2022-01-21T05:55:54.000Z | 2022-03-28T11:01:09.000Z | lib/estructura/hooks.ex | am-kantox/estructura | e319603bbe629e9c15cd7f6521ae82b4cfa3bcc5 | [
"MIT"
] | 1 | 2022-02-01T21:19:00.000Z | 2022-02-01T21:19:00.000Z | defmodule Estructura.Hooks do
@moduledoc false
alias Estructura.Config, as: Cfg
@spec access_ast(boolean(), [Cfg.key()]) :: Macro.t()
defp access_ast(false, _fields), do: []
defp access_ast(lazy?, fields) when lazy? in [true, :lazy] and is_list(fields) do
opening =
quote generated: true, location: :keep do
alias Estructura.Lazy
@behaviour Access
@doc """
Puts the value for the given key into the structure, passing coercion _and_ validation,
returns `{:ok, updated_struct}` or `{:error, reason}` if there is no such key
"""
@spec put(%__MODULE__{}, Cfg.key(), any()) ::
{:ok, %__MODULE__{}} | {:error, any}
def put(data, key, value)
@doc """
Puts the value for the given key into the structure, passing coercion _and_ validation,
returns the value or raises if there is no such key
"""
@spec put(%__MODULE__{}, Cfg.key(), any()) :: %__MODULE__{} | no_return
def put!(data, key, value)
@doc """
Gets the value for the given key from the structure
"""
@spec get(%__MODULE__{}, Cfg.key(), any()) :: any()
def get(data, key, default \\ nil)
end
clauses =
for key <- fields do
quote generated: true, location: :keep do
def put(%__MODULE__{unquote(key) => _} = data, unquote(key), value) do
with {:ok, value} <- coerce(unquote(key), value),
{:ok, value} <- validate(unquote(key), value),
do: {:ok, %__MODULE__{data | unquote(key) => value}}
end
def put!(%__MODULE__{unquote(key) => _} = data, unquote(key), value) do
case put(data, unquote(key), value) do
{:ok, updated_data} -> updated_data
{:error, reason} -> raise ArgumentError, reason
end
end
if unquote(lazy?) in [:lazy] do
def get(
%__MODULE__{unquote(key) => %Lazy{} = value} = data,
unquote(key),
default
) do
case Lazy.apply(value, data) do
%Lazy{value: {:ok, value}} -> value
_ -> default
end
end
end
def get(%__MODULE__{unquote(key) => value}, unquote(key), _), do: value
if unquote(lazy?) in [:lazy] do
@impl Access
def fetch(
%__MODULE__{unquote(key) => %Lazy{} = value} = data,
unquote(key)
) do
case Lazy.apply(value, data) do
%Lazy{value: {:ok, value}} -> {:ok, value}
_ -> :error
end
end
end
@impl Access
def fetch(%__MODULE__{unquote(key) => value}, unquote(key)), do: {:ok, value}
if unquote(lazy?) in [:lazy] do
@impl Access
def pop(
%__MODULE__{unquote(key) => %Lazy{} = value} = data,
unquote(key)
) do
case Lazy.apply(value, data) do
%Lazy{value: {:ok, value}} = result ->
{value, put!(data, unquote(key), Lazy.put(result, value))}
_ ->
{nil, data}
end
end
end
@impl Access
def pop(%__MODULE__{unquote(key) => value} = data, unquote(key)),
do: {value, %{data | unquote(key) => nil}}
if unquote(lazy?) in [:lazy] do
@impl Access
def get_and_update(
%__MODULE__{unquote(key) => %Lazy{} = value} = data,
unquote(key),
fun
) do
case Lazy.apply(value, data) do
%Lazy{value: {:ok, value}} = result ->
case fun.(value) do
:pop ->
{value, result}
{current_value, new_value} ->
{current_value, put!(data, unquote(key), Lazy.put(result, new_value))}
end
_ ->
{nil, data}
end
end
end
@impl Access
def get_and_update(%__MODULE__{unquote(key) => value} = data, unquote(key), fun) do
case fun.(value) do
:pop -> pop(data, unquote(key))
{current_value, new_value} -> {current_value, put!(data, unquote(key), new_value)}
end
end
end
end
closing =
quote generated: true, location: :keep do
def put(%__MODULE__{}, key, _),
do: {:error, Exception.message(%KeyError{key: key, term: __MODULE__})}
def put!(%__MODULE__{}, key, _),
do: raise(KeyError, key: key, term: __MODULE__)
def get(%__MODULE__{}, _key, default),
do: default
@impl Access
def fetch(%__MODULE__{}, _key), do: :error
@impl Access
def pop(%__MODULE__{} = data, _key), do: {nil, data}
@impl Access
def get_and_update(%__MODULE__{}, key, _),
do: raise(KeyError, key: key, term: __MODULE__)
end
[opening | clauses] ++ [closing]
end
@spec coercion_ast(boolean() | [Cfg.key()], module(), [Cfg.key()]) :: Macro.t()
defp coercion_ast(false, _, all_fields),
do: [
quote do
@compile {:inline, coerce: 2}
defp coerce(key, value) when key in unquote(all_fields), do: {:ok, value}
end
]
defp coercion_ast(true, module, all_fields), do: coercion_ast(all_fields, module, all_fields)
defp coercion_ast(fields, module, all_fields) when is_list(fields) do
coercible = Module.concat(module, Coercible)
doc =
quote do
@moduledoc false
"""
The behaviour for `#{inspect(unquote(module))}` specifying callbacks
to be implemented in it for coercion of particular fields.
"""
end
callbacks =
for key <- fields do
quote generated: true, location: :keep do
@doc """
Coercion function to be called for `#{unquote(key)}` key
when put through `put/3` and/or `Access`
"""
@callback unquote(:"coerce_#{key}")(value) :: {:ok, value} | {:error, value}
when value: any()
end
end
Module.create(coercible, [doc | callbacks], __ENV__)
behaviour_clause = quote(do: @behaviour(unquote(coercible)))
coerce_clauses =
for key <- fields do
quote generated: true, location: :keep do
defp coerce(unquote(key), value),
do: apply(__MODULE__, unquote(:"coerce_#{key}"), [value])
end
end
[behaviour_clause | coerce_clauses] ++ coercion_ast(false, module, all_fields)
end
@spec validation_ast(boolean() | [Cfg.key()], module(), [Cfg.key()]) :: Macro.t()
defp validation_ast(false, _, all_fields),
do: [
quote do
defp validate(key, value) when key in unquote(all_fields), do: {:ok, value}
end
]
defp validation_ast(true, module, all_fields),
do: validation_ast(all_fields, module, all_fields)
defp validation_ast(fields, module, all_fields) when is_list(fields) do
validateable = Module.concat(module, Validatable)
doc =
quote do
@moduledoc false
"""
The behaviour for `#{inspect(unquote(module))}` specifying callbacks
to be implemented in it for validation of particular fields.
"""
end
callbacks =
for key <- fields do
quote generated: true, location: :keep do
@doc """
Validation function to be called for `#{unquote(key)}` key
when put through `put/3` and/or `Access`
"""
@callback unquote(:"validate_#{key}")(value) :: {:ok, value} | {:error, value}
when value: any()
end
end
Module.create(validateable, [doc | callbacks], __ENV__)
behaviour_clause = quote(do: @behaviour(unquote(validateable)))
validate_clauses =
for key <- fields do
quote generated: true, location: :keep do
defp validate(unquote(key), value),
do: apply(__MODULE__, unquote(:"validate_#{key}"), [value])
end
end
[behaviour_clause | validate_clauses] ++ validation_ast(false, module, all_fields)
end
@spec enumerable_ast(boolean(), [Cfg.key()]) :: Macro.t()
defp enumerable_ast(false, _fields), do: []
defp enumerable_ast(true, fields) when is_list(fields) do
count = Enum.count(fields)
quote generated: true, location: :keep, bind_quoted: [fields: fields, count: count] do
module = __MODULE__
defimpl Enumerable, for: __MODULE__ do
def count(_), do: {:ok, unquote(count)}
for key <- fields do
def member?(%unquote(module){} = s, {unquote(key), value}),
do: {:ok, match?(%{unquote(key) => ^value}, s)}
end
def member?(%unquote(module){}, _), do: {:ok, false}
if function_exported?(Enumerable.List, :slice, 4) do
def slice(%unquote(module){} = s) do
size = unquote(count)
list = s |> Map.from_struct() |> :maps.to_list()
{:ok, size, &Enumerable.List.slice(list, &1, &2, size)}
end
else
def slice(%unquote(module){}), do: {:error, __MODULE__}
end
def reduce(s, acc, fun) do
s
|> Map.from_struct()
|> :maps.to_list()
|> Enumerable.List.reduce(acc, fun)
end
end
end
end
@spec collectable_ast(false | atom()) :: Macro.t()
defp collectable_ast(false), do: []
defp collectable_ast(field) when is_atom(field) do
quote generated: true, location: :keep, bind_quoted: [field: field] do
module = __MODULE__
defimpl Collectable, for: __MODULE__ do
@dialyzer {:nowarn_function, into: 1}
def into(%unquote(module){unquote(field) => %MapSet{} = old_value} = s) do
fun = fn
list, {:cont, x} ->
[x | list]
list, :done ->
%unquote(module){s | unquote(field) => MapSet.union(old_value, MapSet.new(list))}
_, :halt ->
:ok
end
{[], fun}
end
def into(%unquote(module){unquote(field) => old_value} = s) when is_list(old_value) do
fun = fn
list, {:cont, x} ->
[x | list]
list, :done ->
%unquote(module){s | unquote(field) => old_value ++ list}
_, :halt ->
:ok
end
{[], fun}
end
def into(%unquote(module){unquote(field) => %{} = old_value} = s) do
fun = fn
list, {:cont, x} ->
[x | list]
list, :done ->
%unquote(module){s | unquote(field) => Map.merge(old_value, Map.new(list))}
_, :halt ->
:ok
end
{[], fun}
end
def into(%unquote(module){unquote(field) => old_value} = s) when is_binary(old_value) do
fun = fn
acc, {:cont, x} when is_binary(x) and is_list(acc) ->
[acc | x]
acc, {:cont, x} when is_bitstring(x) and is_bitstring(acc) ->
<<acc::bitstring, x::bitstring>>
acc, {:cont, x} when is_bitstring(x) ->
<<IO.iodata_to_binary(acc)::bitstring, x::bitstring>>
acc, :done when is_bitstring(acc) ->
%unquote(module){s | unquote(field) => acc}
acc, :done ->
%unquote(module){s | unquote(field) => IO.iodata_to_binary(acc)}
__acc, :halt ->
:ok
end
{[old_value], fun}
end
def into(%unquote(module){unquote(field) => old_value} = s)
when is_bitstring(old_value) do
fun = fn
acc, {:cont, x} when is_bitstring(x) ->
<<acc::bitstring, x::bitstring>>
acc, :done ->
%unquote(module){s | unquote(field) => acc}
_acc, :halt ->
:ok
end
{old_value, fun}
end
end
end
end
@spec generator_ast(false | keyword()) :: Macro.t()
defp generator_ast(false), do: []
if match?({:module, StreamData}, Code.ensure_compiled(StreamData)) do
defp generator_ast([{_, _} | _] = types) do
fields = Keyword.keys(types)
quote generated: true, location: :keep do
module = __MODULE__
defp fix_gen(many) when is_list(many), do: Enum.map(many, &fix_gen/1)
defp fix_gen(capture) when is_function(capture, 0),
do: with(info <- Function.info(capture), do: fix_gen({info[:module], info[:name]}))
defp fix_gen({key, {mod, fun, args} = value})
when is_atom(mod) and is_atom(fun) and is_list(args),
do: {key, fix_gen(value)}
defp fix_gen({key, {mod, fun}}) when is_atom(mod) and is_atom(fun),
do: fix_gen({key, {mod, fun, []}})
defp fix_gen({mod, fun, args}) when is_atom(mod) and is_atom(fun) and is_list(args) do
{{:., [], [mod, fun]}, [], fix_gen(args)}
end
defp fix_gen({mod, fun}) when is_atom(mod) and is_atom(fun), do: fix_gen({mod, fun, []})
defp fix_gen(value), do: Macro.escape(value)
# @dialyzer {:nowarn_function, generation_leaf: 1}
defp generation_leaf(args),
do: {{:., [], [StreamData, :constant]}, [], [{:{}, [], args}]}
defp generation_clause({arg, gen}, acc) do
{{:., [], [StreamData, :bind]}, [], [gen, {:fn, [], [{:->, [], [[arg], acc]}]}]}
end
defp generation_bound do
args =
Enum.map(unquote(types), fn {arg, gen} ->
{Macro.var(arg, nil), fix_gen(gen)}
end)
init_args = Enum.map(args, &elem(&1, 0))
Enum.reduce(args, generation_leaf(init_args), &generation_clause/2)
end
defmacrop do_generation, do: generation_bound()
@doc "See `#{inspect(__MODULE__)}.__generator__/1`"
@spec __generator__() :: StreamData.t(%__MODULE__{})
def __generator__, do: __generator__(%__MODULE__{})
@doc """
Returns the generator to be used in `StreamData`-powered property testing, based
on the specification given to `use #{inspect(__MODULE__)}`, which was
```elixir
#{inspect(Module.get_attribute(__MODULE__, :__estructura__), pretty: true, width: 80)}
```
The argument given would be used as a template to generate new values.
"""
@spec __generator__(%__MODULE__{}) :: StreamData.t(%__MODULE__{})
def __generator__(%__MODULE__{} = this) do
do_generation()
|> StreamData.map(&Tuple.to_list/1)
|> StreamData.map(&Enum.zip(unquote(fields), &1))
|> StreamData.map(&struct(this, &1))
end
defoverridable __generator__: 1
end
end
end
##############################################################################
@spec fields(module()) :: [Cfg.key()]
defp fields(module) do
module
|> Module.get_attribute(:__struct__, %{})
|> Map.delete(:__struct__)
|> Map.keys()
end
defmacro inject_estructura(env) do
module = env.module
config = Module.get_attribute(module, :__estructura__)
fields = fields(module)
fields =
if config.access == :lazy do
if :__lazy_data__ in fields do
fields -- [:__lazy_data__]
else
raise CompileError,
description: "`:__lazy_data__` struct key must be defined for `access: :lazy` config"
end
else
fields
end
access_ast = access_ast(config.access, fields)
coercion_ast = coercion_ast(config.access && config.coercion, module, fields)
validation_ast = validation_ast(config.access && config.validation, module, fields)
field = config.collectable
if field && field not in fields, do: raise(KeyError, key: field, term: __MODULE__)
collectable_ast = collectable_ast(field)
types =
with {:module, _} <- Code.ensure_compiled(StreamData),
types when is_list(types) <- config.generator,
true <- Keyword.keyword?(types),
do: Macro.escape(types),
else: (_ -> false)
enumerable_ast = enumerable_ast(config.enumerable, fields)
generator_ast = generator_ast(types)
[access_ast, coercion_ast, validation_ast, enumerable_ast, collectable_ast, generator_ast]
|> Enum.map(&List.wrap/1)
|> Enum.reduce(&Kernel.++/2)
end
end
| 31.555556 | 97 | 0.536465 |
ff2760abd03d34b6f43d5e6a53a265be3ad7b222 | 243 | exs | Elixir | apps/ewallet_db/priv/repo/migrations/20171128175932_add_email_to_user_table.exs | vanmil/ewallet | 6c1aca95a83e0a9d93007670a40d8c45764a8122 | [
"Apache-2.0"
] | 2 | 2019-07-13T05:49:03.000Z | 2021-08-19T23:58:23.000Z | apps/ewallet_db/priv/repo/migrations/20171128175932_add_email_to_user_table.exs | vanmil/ewallet | 6c1aca95a83e0a9d93007670a40d8c45764a8122 | [
"Apache-2.0"
] | null | null | null | apps/ewallet_db/priv/repo/migrations/20171128175932_add_email_to_user_table.exs | vanmil/ewallet | 6c1aca95a83e0a9d93007670a40d8c45764a8122 | [
"Apache-2.0"
] | 3 | 2018-05-08T17:15:42.000Z | 2021-11-10T04:08:33.000Z | defmodule EWalletDB.Repo.Migrations.AddEmailToUserTable do
use Ecto.Migration
def change do
alter table(:user) do
add :email, :string
add :password_hash, :string
end
create unique_index(:user, [:email])
end
end
| 18.692308 | 58 | 0.691358 |
ff2784ea82d26a3c7f852d64147d3d067ab6b212 | 378 | ex | Elixir | apps/ewallet_api/lib/ewallet_api/v1/serializers/json/settings_serializer.ex | turbo-play/ewallet | b7fee3eed62ac716f46246132c2ead1045f2e4f3 | [
"Apache-2.0"
] | 2 | 2019-07-13T05:49:03.000Z | 2021-08-19T23:58:23.000Z | apps/ewallet_api/lib/ewallet_api/v1/serializers/json/settings_serializer.ex | turbo-play/ewallet | b7fee3eed62ac716f46246132c2ead1045f2e4f3 | [
"Apache-2.0"
] | null | null | null | apps/ewallet_api/lib/ewallet_api/v1/serializers/json/settings_serializer.ex | turbo-play/ewallet | b7fee3eed62ac716f46246132c2ead1045f2e4f3 | [
"Apache-2.0"
] | 3 | 2018-05-08T17:15:42.000Z | 2021-11-10T04:08:33.000Z | defmodule EWalletAPI.V1.JSON.SettingsSerializer do
@moduledoc """
Serializes provider settings data into V1 JSON response format.
"""
use EWalletAPI.V1
alias EWalletAPI.V1.JSON.MintedTokenSerializer
def serialize(%{minted_tokens: minted_tokens}) do
%{
object: "setting",
minted_tokens: MintedTokenSerializer.serialize(minted_tokens)
}
end
end
| 25.2 | 67 | 0.740741 |
ff27addbd3ed1f359bcdb315aa6f5479e6866448 | 812 | exs | Elixir | test/capture_io_test.exs | lanalabs/IElixir | c185ce83649c268b7766e707481a3a49c525485b | [
"Apache-2.0"
] | 363 | 2015-07-12T07:36:38.000Z | 2022-03-23T22:48:41.000Z | test/capture_io_test.exs | lanalabs/IElixir | c185ce83649c268b7766e707481a3a49c525485b | [
"Apache-2.0"
] | 51 | 2015-07-30T08:40:46.000Z | 2021-12-03T09:18:58.000Z | test/capture_io_test.exs | lanalabs/IElixir | c185ce83649c268b7766e707481a3a49c525485b | [
"Apache-2.0"
] | 50 | 2015-07-30T05:31:58.000Z | 2021-12-03T09:15:58.000Z | defmodule IElixir.CaptureIOTest do
use ExUnit.Case
doctest IElixir.CaptureIO
require IElixir.CaptureIO, as: CIO
test "correct value for function result is returned" do
{"wombat", _, _} = CIO.capture do: "wombat"
end
test "stdout is passed back" do
{_, "one\ntwo\n", _} = CIO.capture do
IO.puts("one");
IO.puts("two")
end
end
test "stderr is passed back" do
{_, _, "err1\nerr2\n"} = CIO.capture do
IO.puts(:stderr, "err1");
IO.puts(:stderr, "err2")
end
end
test "result, stdout, and stderr are returned" do
func = fn ->
IO.puts "one"
IO.puts :stderr, "err1"
IO.puts "two"
IO.puts :stderr, "err2"
"wombat" |> String.upcase
end
{"WOMBAT", "one\ntwo\n", "err1\nerr2\n"} = CIO.capture do: func.()
end
end
| 23.2 | 70 | 0.598522 |
ff27b0387c383eebb7c875dc8cb788e57c3f3a7c | 2,462 | ex | Elixir | lib/raxx/request.ex | cryic/raxx | a6e33f5dbd9b9344753b43c5d4eb4cbf838bdddf | [
"Apache-2.0"
] | null | null | null | lib/raxx/request.ex | cryic/raxx | a6e33f5dbd9b9344753b43c5d4eb4cbf838bdddf | [
"Apache-2.0"
] | null | null | null | lib/raxx/request.ex | cryic/raxx | a6e33f5dbd9b9344753b43c5d4eb4cbf838bdddf | [
"Apache-2.0"
] | null | null | null | defmodule Raxx.Request do
@moduledoc """
HTTP requests to a Raxx application are encapsulated in a `Raxx.Request` struct.
A request has all the properties of the url it was sent to.
In addition it has optional content, in the body.
As well as a variable number of headers that contain meta data.
Where appropriate URI properties are named from this definition.
> scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
from [wikipedia](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax)
The contents are itemised below:
| **scheme** | `http` or `https`, depending on the transport used. |
| **authority** | The location of the hosting server, as a binary. e.g. `www.example.com`. Plus an optional port number, separated from the hostname by a colon |
| **method** | The HTTP request method, such as “GET” or “POST”, as a binary. This cannot ever be an empty string, and is always uppercase. |
| **mount** | The segments of the request URL's “path”, that have already been matched. Same as rack path_info. This may be an empty array, if the requested URL targets the application root. |
| **path** | The remainder of the request URL's “path”, split into segments. It designates the virtual “location” of the request's target within the application. This may be an empty array, if the requested URL targets the application root. |
| **query** | The query parameters from the URL search string, formatted as a map of strings. |
| **headers** | The headers from the HTTP request as a map of strings. Note all headers will be downcased, e.g. `%{"content-type" => "text/plain"}` |
| **body** | The body content sent with the request |
"""
@typedoc """
Method to indicate the desired action to be performed on the identified resource.
"""
@type method :: atom
@typedoc """
Scheme describing protocol used.
"""
@type scheme :: :http | :https
@typedoc """
Elixir representation for an HTTP request.
"""
@type t :: %__MODULE__{
scheme: scheme,
authority: binary,
method: method,
mount: [binary],
path: [binary],
query: %{binary => binary} | nil,
headers: Raxx.headers(),
body: Raxx.body()
}
defstruct scheme: nil,
authority: nil,
method: nil,
mount: [],
path: [],
query: %{},
headers: [],
body: nil
end
| 40.360656 | 244 | 0.651097 |
ff27bcb06b4c041ab2cb19b1cf965b34b5f8a19b | 82,186 | ex | Elixir | clients/ad_sense/lib/google_api/ad_sense/v2/api/accounts.ex | renovate-bot/elixir-google-api | 1da34cd39b670c99f067011e05ab90af93fef1f6 | [
"Apache-2.0"
] | 1 | 2021-12-20T03:40:53.000Z | 2021-12-20T03:40:53.000Z | clients/ad_sense/lib/google_api/ad_sense/v2/api/accounts.ex | swansoffiee/elixir-google-api | 9ea6d39f273fb430634788c258b3189d3613dde0 | [
"Apache-2.0"
] | 1 | 2020-08-18T00:11:23.000Z | 2020-08-18T00:44:16.000Z | clients/ad_sense/lib/google_api/ad_sense/v2/api/accounts.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.AdSense.V2.Api.Accounts do
@moduledoc """
API calls for all endpoints tagged `Accounts`.
"""
alias GoogleApi.AdSense.V2.Connection
alias GoogleApi.Gax.{Request, Response}
@library_version Mix.Project.config() |> Keyword.get(:version, "")
@doc """
Gets information about the selected AdSense account.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Account to get information about. Format: accounts/{account}
* `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.AdSense.V2.Model.Account{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.AdSense.V2.Model.Account.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.Account{}])
end
@doc """
Lists all accounts available to this user.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.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").
* `:pageSize` (*type:* `integer()`) - The maximum number of accounts to include in the response, used for paging. If unspecified, at most 10000 accounts will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
* `:pageToken` (*type:* `String.t`) - A page token, received from a previous `ListAccounts` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAccounts` must match the call that provided the page token.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.ListAccountsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_list(Tesla.Env.client(), keyword(), keyword()) ::
{:ok, GoogleApi.AdSense.V2.Model.ListAccountsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_list(connection, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/accounts", %{})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.ListAccountsResponse{}])
end
@doc """
Lists all accounts directly managed by the given AdSense account.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The parent account, which owns the child accounts. Format: accounts/{account}
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - The maximum number of accounts to include in the response, used for paging. If unspecified, at most 10000 accounts will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
* `:pageToken` (*type:* `String.t`) - A page token, received from a previous `ListAccounts` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAccounts` must match the call that provided the page token.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.ListChildAccountsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_list_child_accounts(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.AdSense.V2.Model.ListChildAccountsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_list_child_accounts(connection, parent, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+parent}:listChildAccounts", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.ListChildAccountsResponse{}])
end
@doc """
Gets the AdSense code for a given ad client. This returns what was previously known as the 'auto ad code'. This is only supported for ad clients with a product_code of AFC. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634).
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the ad client for which to get the adcode. Format: accounts/{account}/adclients/{adclient}
* `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.AdSense.V2.Model.AdClientAdCode{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_adclients_get_adcode(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.AdSense.V2.Model.AdClientAdCode.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_adclients_get_adcode(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+name}/adcode", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.AdClientAdCode{}])
end
@doc """
Lists all the ad clients available in an account.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The account which owns the collection of ad clients. Format: accounts/{account}
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - The maximum number of ad clients to include in the response, used for paging. If unspecified, at most 10000 ad clients will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
* `:pageToken` (*type:* `String.t`) - A page token, received from a previous `ListAdClients` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAdClients` must match the call that provided the page token.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.ListAdClientsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_adclients_list(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.AdSense.V2.Model.ListAdClientsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_adclients_list(connection, parent, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+parent}/adclients", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.ListAdClientsResponse{}])
end
@doc """
Gets an ad unit from a specified account and ad client.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. AdUnit to get information about. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
* `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.AdSense.V2.Model.AdUnit{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_adclients_adunits_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.AdSense.V2.Model.AdUnit.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_adclients_adunits_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.AdUnit{}])
end
@doc """
Gets the AdSense code for a given ad unit.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the adunit for which to get the adcode. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
* `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.AdSense.V2.Model.AdUnitAdCode{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_adclients_adunits_get_adcode(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.AdSense.V2.Model.AdUnitAdCode.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_adclients_adunits_get_adcode(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+name}/adcode", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.AdUnitAdCode{}])
end
@doc """
Lists all ad units under a specified account and ad client.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The ad client which owns the collection of ad units. Format: accounts/{account}/adclients/{adclient}
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - The maximum number of ad units to include in the response, used for paging. If unspecified, at most 10000 ad units will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
* `:pageToken` (*type:* `String.t`) - A page token, received from a previous `ListAdUnits` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAdUnits` must match the call that provided the page token.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.ListAdUnitsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_adclients_adunits_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.AdSense.V2.Model.ListAdUnitsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_adclients_adunits_list(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+parent}/adunits", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.ListAdUnitsResponse{}])
end
@doc """
Lists all the custom channels available for an ad unit.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The ad unit which owns the collection of custom channels. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - The maximum number of custom channels to include in the response, used for paging. If unspecified, at most 10000 custom channels will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
* `:pageToken` (*type:* `String.t`) - A page token, received from a previous `ListLinkedCustomChannels` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListLinkedCustomChannels` must match the call that provided the page token.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.ListLinkedCustomChannelsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_adclients_adunits_list_linked_custom_channels(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.AdSense.V2.Model.ListLinkedCustomChannelsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_adclients_adunits_list_linked_custom_channels(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+parent}:listLinkedCustomChannels", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.AdSense.V2.Model.ListLinkedCustomChannelsResponse{}]
)
end
@doc """
Gets information about the selected custom channel.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the custom channel. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
* `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.AdSense.V2.Model.CustomChannel{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_adclients_customchannels_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.AdSense.V2.Model.CustomChannel.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_adclients_customchannels_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.CustomChannel{}])
end
@doc """
Lists all the custom channels available in an ad client.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The ad client which owns the collection of custom channels. Format: accounts/{account}/adclients/{adclient}
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - The maximum number of custom channels to include in the response, used for paging. If unspecified, at most 10000 custom channels will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
* `:pageToken` (*type:* `String.t`) - A page token, received from a previous `ListCustomChannels` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListCustomChannels` must match the call that provided the page token.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.ListCustomChannelsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_adclients_customchannels_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.AdSense.V2.Model.ListCustomChannelsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_adclients_customchannels_list(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+parent}/customchannels", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.ListCustomChannelsResponse{}])
end
@doc """
Lists all the ad units available for a custom channel.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The custom channel which owns the collection of ad units. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - The maximum number of ad units to include in the response, used for paging. If unspecified, at most 10000 ad units will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
* `:pageToken` (*type:* `String.t`) - A page token, received from a previous `ListLinkedAdUnits` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListLinkedAdUnits` must match the call that provided the page token.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.ListLinkedAdUnitsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_adclients_customchannels_list_linked_ad_units(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.AdSense.V2.Model.ListLinkedAdUnitsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_adclients_customchannels_list_linked_ad_units(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+parent}:listLinkedAdUnits", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.ListLinkedAdUnitsResponse{}])
end
@doc """
Lists active url channels.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The ad client which owns the collection of url channels. Format: accounts/{account}/adclients/{adclient}
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - The maximum number of url channels to include in the response, used for paging. If unspecified, at most 10000 url channels will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
* `:pageToken` (*type:* `String.t`) - A page token, received from a previous `ListUrlChannels` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListUrlChannels` must match the call that provided the page token.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.ListUrlChannelsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_adclients_urlchannels_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.AdSense.V2.Model.ListUrlChannelsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_adclients_urlchannels_list(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+parent}/urlchannels", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.ListUrlChannelsResponse{}])
end
@doc """
Lists all the alerts available in an account.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The account which owns the collection of alerts. Format: accounts/{account}
* `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").
* `:languageCode` (*type:* `String.t`) - The language to use for translating alert messages. If unspecified, this defaults to the user's display language. If the given language is not supported, alerts will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.ListAlertsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_alerts_list(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.AdSense.V2.Model.ListAlertsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_alerts_list(connection, parent, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:languageCode => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+parent}/alerts", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.ListAlertsResponse{}])
end
@doc """
Lists all the payments available for an account.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The account which owns the collection of payments. Format: accounts/{account}
* `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.AdSense.V2.Model.ListPaymentsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_payments_list(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.AdSense.V2.Model.ListPaymentsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_payments_list(connection, parent, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+parent}/payments", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.ListPaymentsResponse{}])
end
@doc """
Generates an ad hoc report.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `account` (*type:* `String.t`) - Required. The account which owns the collection of reports. Format: accounts/{account}
* `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").
* `:currencyCode` (*type:* `String.t`) - The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) to use when reporting on monetary metrics. Defaults to the account's currency if not set.
* `:dateRange` (*type:* `String.t`) - Date range of the report, if unset the range will be considered CUSTOM.
* `:dimensions` (*type:* `list(String.t)`) - Dimensions to base the report on.
* `:"endDate.day"` (*type:* `integer()`) - Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
* `:"endDate.month"` (*type:* `integer()`) - Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
* `:"endDate.year"` (*type:* `integer()`) - Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
* `:filters` (*type:* `list(String.t)`) - Filters to be run on the report.
* `:languageCode` (*type:* `String.t`) - The language to use for translating report output. If unspecified, this defaults to English ("en"). If the given language is not supported, report output will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
* `:limit` (*type:* `integer()`) - The maximum number of rows of report data to return. Reports producing more rows than the requested limit will be truncated. If unset, this defaults to 100,000 rows for `Reports.GenerateReport` and 1,000,000 rows for `Reports.GenerateCsvReport`, which are also the maximum values permitted here. Report truncation can be identified (for `Reports.GenerateReport` only) by comparing the number of rows returned to the value returned in `total_matched_rows`.
* `:metrics` (*type:* `list(String.t)`) - Required. Reporting metrics.
* `:orderBy` (*type:* `list(String.t)`) - The name of a dimension or metric to sort the resulting report on, can be prefixed with "+" to sort ascending or "-" to sort descending. If no prefix is specified, the column is sorted ascending.
* `:reportingTimeZone` (*type:* `String.t`) - Timezone in which to generate the report. If unspecified, this defaults to the account timezone. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
* `:"startDate.day"` (*type:* `integer()`) - Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
* `:"startDate.month"` (*type:* `integer()`) - Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
* `:"startDate.year"` (*type:* `integer()`) - Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.ReportResult{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_reports_generate(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.AdSense.V2.Model.ReportResult.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_reports_generate(connection, account, 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,
:currencyCode => :query,
:dateRange => :query,
:dimensions => :query,
:"endDate.day" => :query,
:"endDate.month" => :query,
:"endDate.year" => :query,
:filters => :query,
:languageCode => :query,
:limit => :query,
:metrics => :query,
:orderBy => :query,
:reportingTimeZone => :query,
:"startDate.day" => :query,
:"startDate.month" => :query,
:"startDate.year" => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+account}/reports:generate", %{
"account" => URI.encode(account, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.ReportResult{}])
end
@doc """
Generates a csv formatted ad hoc report.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `account` (*type:* `String.t`) - Required. The account which owns the collection of reports. Format: accounts/{account}
* `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").
* `:currencyCode` (*type:* `String.t`) - The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) to use when reporting on monetary metrics. Defaults to the account's currency if not set.
* `:dateRange` (*type:* `String.t`) - Date range of the report, if unset the range will be considered CUSTOM.
* `:dimensions` (*type:* `list(String.t)`) - Dimensions to base the report on.
* `:"endDate.day"` (*type:* `integer()`) - Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
* `:"endDate.month"` (*type:* `integer()`) - Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
* `:"endDate.year"` (*type:* `integer()`) - Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
* `:filters` (*type:* `list(String.t)`) - Filters to be run on the report.
* `:languageCode` (*type:* `String.t`) - The language to use for translating report output. If unspecified, this defaults to English ("en"). If the given language is not supported, report output will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
* `:limit` (*type:* `integer()`) - The maximum number of rows of report data to return. Reports producing more rows than the requested limit will be truncated. If unset, this defaults to 100,000 rows for `Reports.GenerateReport` and 1,000,000 rows for `Reports.GenerateCsvReport`, which are also the maximum values permitted here. Report truncation can be identified (for `Reports.GenerateReport` only) by comparing the number of rows returned to the value returned in `total_matched_rows`.
* `:metrics` (*type:* `list(String.t)`) - Required. Reporting metrics.
* `:orderBy` (*type:* `list(String.t)`) - The name of a dimension or metric to sort the resulting report on, can be prefixed with "+" to sort ascending or "-" to sort descending. If no prefix is specified, the column is sorted ascending.
* `:reportingTimeZone` (*type:* `String.t`) - Timezone in which to generate the report. If unspecified, this defaults to the account timezone. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
* `:"startDate.day"` (*type:* `integer()`) - Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
* `:"startDate.month"` (*type:* `integer()`) - Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
* `:"startDate.year"` (*type:* `integer()`) - Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.HttpBody{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_reports_generate_csv(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.AdSense.V2.Model.HttpBody.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_reports_generate_csv(
connection,
account,
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,
:currencyCode => :query,
:dateRange => :query,
:dimensions => :query,
:"endDate.day" => :query,
:"endDate.month" => :query,
:"endDate.year" => :query,
:filters => :query,
:languageCode => :query,
:limit => :query,
:metrics => :query,
:orderBy => :query,
:reportingTimeZone => :query,
:"startDate.day" => :query,
:"startDate.month" => :query,
:"startDate.year" => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+account}/reports:generateCsv", %{
"account" => URI.encode(account, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.HttpBody{}])
end
@doc """
Generates a saved report.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the saved report. Format: accounts/{account}/reports/{report}
* `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").
* `:currencyCode` (*type:* `String.t`) - The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) to use when reporting on monetary metrics. Defaults to the account's currency if not set.
* `:dateRange` (*type:* `String.t`) - Date range of the report, if unset the range will be considered CUSTOM.
* `:"endDate.day"` (*type:* `integer()`) - Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
* `:"endDate.month"` (*type:* `integer()`) - Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
* `:"endDate.year"` (*type:* `integer()`) - Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
* `:languageCode` (*type:* `String.t`) - The language to use for translating report output. If unspecified, this defaults to English ("en"). If the given language is not supported, report output will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
* `:reportingTimeZone` (*type:* `String.t`) - Timezone in which to generate the report. If unspecified, this defaults to the account timezone. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
* `:"startDate.day"` (*type:* `integer()`) - Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
* `:"startDate.month"` (*type:* `integer()`) - Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
* `:"startDate.year"` (*type:* `integer()`) - Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.ReportResult{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_reports_saved_generate(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.AdSense.V2.Model.ReportResult.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_reports_saved_generate(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:currencyCode => :query,
:dateRange => :query,
:"endDate.day" => :query,
:"endDate.month" => :query,
:"endDate.year" => :query,
:languageCode => :query,
:reportingTimeZone => :query,
:"startDate.day" => :query,
:"startDate.month" => :query,
:"startDate.year" => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+name}/saved:generate", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.ReportResult{}])
end
@doc """
Generates a csv formatted saved report.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the saved report. Format: accounts/{account}/reports/{report}
* `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").
* `:currencyCode` (*type:* `String.t`) - The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) to use when reporting on monetary metrics. Defaults to the account's currency if not set.
* `:dateRange` (*type:* `String.t`) - Date range of the report, if unset the range will be considered CUSTOM.
* `:"endDate.day"` (*type:* `integer()`) - Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
* `:"endDate.month"` (*type:* `integer()`) - Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
* `:"endDate.year"` (*type:* `integer()`) - Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
* `:languageCode` (*type:* `String.t`) - The language to use for translating report output. If unspecified, this defaults to English ("en"). If the given language is not supported, report output will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
* `:reportingTimeZone` (*type:* `String.t`) - Timezone in which to generate the report. If unspecified, this defaults to the account timezone. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
* `:"startDate.day"` (*type:* `integer()`) - Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
* `:"startDate.month"` (*type:* `integer()`) - Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
* `:"startDate.year"` (*type:* `integer()`) - Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.HttpBody{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_reports_saved_generate_csv(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.AdSense.V2.Model.HttpBody.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_reports_saved_generate_csv(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:currencyCode => :query,
:dateRange => :query,
:"endDate.day" => :query,
:"endDate.month" => :query,
:"endDate.year" => :query,
:languageCode => :query,
:reportingTimeZone => :query,
:"startDate.day" => :query,
:"startDate.month" => :query,
:"startDate.year" => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+name}/saved:generateCsv", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.HttpBody{}])
end
@doc """
Lists saved reports.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The account which owns the collection of reports. Format: accounts/{account}
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - The maximum number of reports to include in the response, used for paging. If unspecified, at most 10000 reports will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
* `:pageToken` (*type:* `String.t`) - A page token, received from a previous `ListPayments` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListPayments` must match the call that provided the page token.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.ListSavedReportsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_reports_saved_list(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.AdSense.V2.Model.ListSavedReportsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_reports_saved_list(connection, parent, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+parent}/reports/saved", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.ListSavedReportsResponse{}])
end
@doc """
Gets information about the selected site.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the site. Format: accounts/{account}/sites/{site}
* `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.AdSense.V2.Model.Site{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_sites_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.AdSense.V2.Model.Site.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_sites_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.Site{}])
end
@doc """
Lists all the sites available in an account.
## Parameters
* `connection` (*type:* `GoogleApi.AdSense.V2.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The account which owns the collection of sites. Format: accounts/{account}
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - The maximum number of sites to include in the response, used for paging. If unspecified, at most 10000 sites will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
* `:pageToken` (*type:* `String.t`) - A page token, received from a previous `ListSites` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListSites` must match the call that provided the page token.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.AdSense.V2.Model.ListSitesResponse{}}` on success
* `{:error, info}` on failure
"""
@spec adsense_accounts_sites_list(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.AdSense.V2.Model.ListSitesResponse.t()}
| {:ok, Tesla.Env.t()}
| {:ok, list()}
| {:error, any()}
def adsense_accounts_sites_list(connection, parent, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v2/{+parent}/sites", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.AdSense.V2.Model.ListSitesResponse{}])
end
end
| 51.559598 | 498 | 0.624498 |
ff27ca2522ffab2044bd683b219019d726fa625e | 3,547 | exs | Elixir | test/core/converter_test.exs | lizhaochao/Argx | d2fb6e346d824a2775603e2eb779bb588870636d | [
"MIT"
] | 2 | 2021-05-07T03:27:19.000Z | 2021-05-19T02:04:01.000Z | test/core/converter_test.exs | lizhaochao/Argx | d2fb6e346d824a2775603e2eb779bb588870636d | [
"MIT"
] | 1 | 2021-05-10T14:09:36.000Z | 2021-05-10T14:10:11.000Z | test/core/converter_test.exs | lizhaochao/Argx | d2fb6e346d824a2775603e2eb779bb588870636d | [
"MIT"
] | null | null | null | defmodule ConverterTest do
use ExUnit.Case
alias Argx.Converter, as: C
###
describe "convert - ok" do
test "integer" do
arg = {:total, "3"}
config = {
:total,
%Argx.Config{type: :integer, autoconvert: true, optional: false, empty: false}
}
assert {:total, 3} == C.convert(arg, config)
end
test "float" do
arg = {:weight, "3.21"}
config = {
:weight,
%Argx.Config{type: :float, autoconvert: true, optional: false, empty: false}
}
assert {:weight, 3.21} == C.convert(arg, config)
end
end
describe "convert - error" do
test "arg is empty" do
arg = {}
config = {
:total,
%Argx.Config{type: :integer, autoconvert: true, optional: false, empty: false}
}
assert_raise Argx.Error, fn ->
C.convert(arg, config)
end
end
test "config is empty" do
arg = {:total, "3"}
config = {:total, %{}}
assert_raise Argx.Error, fn ->
C.convert(arg, config)
end
end
end
###
describe "to_type - integer" do
test "integer to integer" do
assert -1 === C.to_type(-1, :integer)
assert 0 === C.to_type(0, :integer)
assert 1 === C.to_type(1, :integer)
end
test "string to integer" do
assert -1 === C.to_type("-1", :integer)
assert 0 === C.to_type("0", :integer)
assert 1 === C.to_type("1", :integer)
end
end
describe "to_type - float" do
test "float to float" do
assert -1.0 === C.to_type(-1.0, :float)
assert 0.0 === C.to_type(0.0, :float)
assert 1.0 === C.to_type(1.0, :float)
assert -1.1 === C.to_type(-1.1, :float)
assert 0.1 === C.to_type(0.1, :float)
assert 1.1 === C.to_type(1.1, :float)
end
test "integer to float" do
assert -1.0 === C.to_type(-1, :float)
assert 0.0 === C.to_type(0, :float)
assert 1.0 === C.to_type(1, :float)
end
test "string to float" do
assert -1.0 === C.to_type("-1", :float)
assert 0.0 === C.to_type("0", :float)
assert 1.0 === C.to_type("1", :float)
assert -1.0 === C.to_type("-1.0", :float)
assert 0.0 === C.to_type("0.0", :float)
assert 1.0 === C.to_type("1.0", :float)
assert -1.1 === C.to_type("-1.1", :float)
assert 0.1 === C.to_type("0.1", :float)
assert 1.1 === C.to_type("1.1", :float)
end
end
describe "to_type - boolean" do
test "boolean" do
assert true === C.to_type(true, :boolean)
assert false === C.to_type(false, :boolean)
assert true === C.to_type(1, :boolean)
assert false === C.to_type(0, :boolean)
assert true === C.to_type("1", :boolean)
assert false === C.to_type("0", :boolean)
end
end
describe "to_type - other type" do
test "string" do
assert "" === C.to_type("", :string)
assert "string" === C.to_type("string", :string)
assert "string" === C.to_type("string", :list)
end
test "list" do
assert [] === C.to_type([], :list)
assert [1, 2, 3] === C.to_type([1, 2, 3], :list)
assert [1, 2, 3] === C.to_type([1, 2, 3], :string)
end
test "map" do
assert %{} === C.to_type(%{}, :map)
assert %{a: 1, b: 2} === C.to_type(%{a: 1, b: 2}, :map)
assert %{"a" => 1, "b" => 2} === C.to_type(%{"a" => 1, "b" => 2}, :map)
assert %{a: 1, b: 2} === C.to_type(%{a: 1, b: 2}, :string)
assert %{"a" => 1, "b" => 2} === C.to_type(%{"a" => 1, "b" => 2}, :string)
end
end
end
| 26.080882 | 86 | 0.519594 |
ff27de0f9ea59607f8d321ca9dc098bd591b670f | 2,533 | ex | Elixir | clients/firestore/lib/google_api/firestore/v1beta1/model/batch_get_documents_response.ex | matehat/elixir-google-api | c1b2523c2c4cdc9e6ca4653ac078c94796b393c3 | [
"Apache-2.0"
] | 1 | 2018-12-03T23:43:10.000Z | 2018-12-03T23:43:10.000Z | clients/firestore/lib/google_api/firestore/v1beta1/model/batch_get_documents_response.ex | matehat/elixir-google-api | c1b2523c2c4cdc9e6ca4653ac078c94796b393c3 | [
"Apache-2.0"
] | null | null | null | clients/firestore/lib/google_api/firestore/v1beta1/model/batch_get_documents_response.ex | matehat/elixir-google-api | c1b2523c2c4cdc9e6ca4653ac078c94796b393c3 | [
"Apache-2.0"
] | null | null | null | # Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "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 class is auto generated by the elixir code generator program.
# Do not edit the class manually.
defmodule GoogleApi.Firestore.V1beta1.Model.BatchGetDocumentsResponse do
@moduledoc """
The streamed response for Firestore.BatchGetDocuments.
## Attributes
* `found` (*type:* `GoogleApi.Firestore.V1beta1.Model.Document.t`, *default:* `nil`) - A document that was requested.
* `missing` (*type:* `String.t`, *default:* `nil`) - A document name that was requested but does not exist. In the format:
`projects/{project_id}/databases/{database_id}/documents/{document_path}`.
* `readTime` (*type:* `DateTime.t`, *default:* `nil`) - The time at which the document was read.
This may be monotically increasing, in this case the previous documents in
the result stream are guaranteed not to have changed between their
read_time and this one.
* `transaction` (*type:* `String.t`, *default:* `nil`) - The transaction that was started as part of this request.
Will only be set in the first response, and only if
BatchGetDocumentsRequest.new_transaction was set in the request.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:found => GoogleApi.Firestore.V1beta1.Model.Document.t(),
:missing => String.t(),
:readTime => DateTime.t(),
:transaction => String.t()
}
field(:found, as: GoogleApi.Firestore.V1beta1.Model.Document)
field(:missing)
field(:readTime, as: DateTime)
field(:transaction)
end
defimpl Poison.Decoder, for: GoogleApi.Firestore.V1beta1.Model.BatchGetDocumentsResponse do
def decode(value, options) do
GoogleApi.Firestore.V1beta1.Model.BatchGetDocumentsResponse.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.Firestore.V1beta1.Model.BatchGetDocumentsResponse do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 40.854839 | 126 | 0.726017 |
ff27e43af3879a759068cc609b8954b5a2dd2ae2 | 434 | ex | Elixir | lib/appsignal/utils/push_api_key_validator.ex | MeterSoft/appsignal-elixir | 52e3505b9dc90bce0795c4753a758d40bdf41463 | [
"MIT"
] | 234 | 2016-08-18T20:43:15.000Z | 2022-02-27T11:31:48.000Z | lib/appsignal/utils/push_api_key_validator.ex | MeterSoft/appsignal-elixir | 52e3505b9dc90bce0795c4753a758d40bdf41463 | [
"MIT"
] | 563 | 2016-07-25T17:45:14.000Z | 2022-03-21T11:39:29.000Z | lib/appsignal/utils/push_api_key_validator.ex | MeterSoft/appsignal-elixir | 52e3505b9dc90bce0795c4753a758d40bdf41463 | [
"MIT"
] | 86 | 2016-09-13T22:53:46.000Z | 2022-02-16T11:03:51.000Z | defmodule Appsignal.Utils.PushApiKeyValidator do
@moduledoc false
alias Appsignal.Transmitter
def validate(config) do
url = "#{config[:endpoint]}/1/auth?api_key=#{config[:push_api_key]}"
case Transmitter.request(:get, url) do
{:ok, 200, _, _} -> :ok
{:ok, 401, _, _} -> {:error, :invalid}
{:ok, status_code, _, _} -> {:error, status_code}
{:error, reason} -> {:error, reason}
end
end
end
| 27.125 | 72 | 0.619816 |
ff280ac504a39e2f8ae38242430b9b5d3f80e7d3 | 441 | exs | Elixir | apps/storage/priv/repo/migrations/20190201121431_create_aritlce.exs | anyex-project/anyex | d04018337bcec621f2e2e8d17773fa2724e3c6e1 | [
"MIT"
] | 12 | 2019-02-21T21:29:08.000Z | 2019-05-14T11:41:10.000Z | apps/storage/priv/repo/migrations/20190201121431_create_aritlce.exs | Hentioe/anyex | d04018337bcec621f2e2e8d17773fa2724e3c6e1 | [
"MIT"
] | 18 | 2019-02-05T17:19:33.000Z | 2019-03-13T13:38:08.000Z | apps/storage/priv/repo/migrations/20190201121431_create_aritlce.exs | Hentioe/anyex | d04018337bcec621f2e2e8d17773fa2724e3c6e1 | [
"MIT"
] | null | null | null | defmodule Storage.Repo.Migrations.CreateAritlce do
use Storage.Migration
def change do
create table(:article) do
add :qtext, :string, null: false, comment: "查询文本"
add :title, :string, null: false, comment: "文章标题"
add :preface, :text, comment: "文章前言"
add :content, :text, comment: "文章内容"
top_field(:v001)
common_fields(:v001)
end
create unique_index :article, [:qtext, :title]
end
end
| 24.5 | 55 | 0.650794 |
ff281f73620ddb78ef2a7148bcc8aa6c86585205 | 513 | ex | Elixir | elixir/lib/homework/users/user.ex | MilioFrankie/transactions-app | 5299526824393d2de3c4d6435286d665829991c5 | [
"MIT"
] | null | null | null | elixir/lib/homework/users/user.ex | MilioFrankie/transactions-app | 5299526824393d2de3c4d6435286d665829991c5 | [
"MIT"
] | 3 | 2021-09-02T19:01:31.000Z | 2022-02-27T11:09:27.000Z | elixir/lib/homework/users/user.ex | MilioFrankie/transactions-app | 5299526824393d2de3c4d6435286d665829991c5 | [
"MIT"
] | null | null | null | defmodule Homework.Users.User do
use Ecto.Schema
import Ecto.Changeset
alias Homework.Transactions.Transaction
@fields [:first_name, :last_name, :dob]
@primary_key {:id, :binary_id, autogenerate: true}
schema "users" do
field(:dob, :string)
field(:first_name, :string)
field(:last_name, :string)
has_many(:transactions, Transaction)
timestamps()
end
@doc false
def changeset(user, attrs) do
user
|> cast(attrs, @fields)
|> validate_required(@fields)
end
end
| 21.375 | 52 | 0.688109 |
ff2821bc40ccc92a47677a1b1d821e1090f4bba3 | 146 | ex | Elixir | test/support/user.ex | milmazz/dataloader | a61f550a28820d2befcd94411f7b03163f30db30 | [
"MIT"
] | null | null | null | test/support/user.ex | milmazz/dataloader | a61f550a28820d2befcd94411f7b03163f30db30 | [
"MIT"
] | null | null | null | test/support/user.ex | milmazz/dataloader | a61f550a28820d2befcd94411f7b03163f30db30 | [
"MIT"
] | null | null | null | defmodule Dataloader.User do
use Ecto.Schema
schema "users" do
field(:username, :string)
has_many(:posts, Dataloader.Post)
end
end
| 16.222222 | 37 | 0.705479 |
ff282e0c2f7db2bd68716b2df2d170becae67301 | 2,287 | ex | Elixir | src/pollution_data_stream.ex | tomros766/pollution_server | 2f37fdf964ee60b41d57f8d1eeed35619801096a | [
"Apache-2.0"
] | null | null | null | src/pollution_data_stream.ex | tomros766/pollution_server | 2f37fdf964ee60b41d57f8d1eeed35619801096a | [
"Apache-2.0"
] | null | null | null | src/pollution_data_stream.ex | tomros766/pollution_server | 2f37fdf964ee60b41d57f8d1eeed35619801096a | [
"Apache-2.0"
] | null | null | null | defmodule PollutionDataStream do
@moduledoc false
def importLinesFromCSV(name \\ "pollution.csv") do
File.stream!(name)
end
def convertLine(line) do
[date, time, longitude, latitude, value] = line |> String.split(",")
parsedDate = date |> String.split("-") |> Enum.reverse() |> Enum.map( fn(x) -> elem(Integer.parse(x), 0) end) |> :erlang.list_to_tuple()
parsedTime = time |> String.split(":") |> Enum.map( fn(x) -> elem(Integer.parse(x), 0) end) |> :erlang.list_to_tuple()
{{x, _}, {y, _}} = {Float.parse(longitude), Float.parse(latitude)}
location = {x, y}
{numValue, _} = Float.parse(value)
%{:datetime => {parsedDate, parsedTime}, :location => location, :pollutionLevel => numValue}
end
def identifyStations(mappedLine) do
mappedLine |> Stream.uniq_by(fn(x) -> x[:location] end)
end
def loadStation(line) do
:pollution_gen_server.addStation("station_#{elem(line[:location], 0)}_#{elem(line[:location], 1)}", line[:location])
end
def loadMeasurement(line) do
:pollution_gen_server.addValue(line[:location], line[:datetime], "PM10", line[:pollutionLevel])
end
def test do
loadingStations = testStations()
loadingMeasurements = testMeasurements()
stationMean = fn -> :pollution_gen_server.getStationMean({20.06, 49.986}, "PM10") end |> :timer.tc |> elem(0)
dailyMean = fn -> :pollution_gen_server.getDailyMean({2017, 5, 3}, "PM10") end |> :timer.tc |> elem(0)
{"Stations: ", loadingStations, "Measurements: ", loadingMeasurements, "Station Mean: ", stationMean, "Daily Mean: ", dailyMean}
end
def testStations() do
fn -> (PollutionDataStream.importLinesFromCSV |>
Stream.map(fn(x) -> PollutionDataStream.convertLine(x) end) |>
PollutionDataStream.identifyStations |>
Stream.map(fn(x) -> PollutionDataStream.loadStation(x) end) |>
Enum.reduce(fn(_, _) -> nil end)) end |>
:timer.tc |> elem(0)
end
def testMeasurements() do
fn -> (PollutionDataStream.importLinesFromCSV |>
Stream.map(fn(x) -> PollutionDataStream.convertLine(x) end) |>
Stream.map(fn(x) -> PollutionDataStream.loadMeasurement(x) end) |>
Enum.reduce(fn(_, _) -> nil end)) end |>
:timer.tc |> elem(0)
end
end
| 42.351852 | 140 | 0.647136 |
ff28d6c91eb67a8bb6a6db00376b67e003401191 | 84 | exs | Elixir | test/tribevibe_web/views/page_view_test.exs | futurice/tribevibe-server | d51fa08528e6391ee50c98adf8696ca35af2c53d | [
"MIT"
] | null | null | null | test/tribevibe_web/views/page_view_test.exs | futurice/tribevibe-server | d51fa08528e6391ee50c98adf8696ca35af2c53d | [
"MIT"
] | null | null | null | test/tribevibe_web/views/page_view_test.exs | futurice/tribevibe-server | d51fa08528e6391ee50c98adf8696ca35af2c53d | [
"MIT"
] | null | null | null | defmodule TribevibeWeb.PageViewTest do
use TribevibeWeb.ConnCase, async: true
end
| 21 | 40 | 0.833333 |
ff28fbba92404f5343cb8e667b0acee1d0b7a554 | 1,864 | ex | Elixir | clients/big_query/lib/google_api/big_query/v2/model/query_parameter_type_struct_types.ex | pojiro/elixir-google-api | 928496a017d3875a1929c6809d9221d79404b910 | [
"Apache-2.0"
] | 1 | 2021-12-20T03:40:53.000Z | 2021-12-20T03:40:53.000Z | clients/big_query/lib/google_api/big_query/v2/model/query_parameter_type_struct_types.ex | pojiro/elixir-google-api | 928496a017d3875a1929c6809d9221d79404b910 | [
"Apache-2.0"
] | 1 | 2020-08-18T00:11:23.000Z | 2020-08-18T00:44:16.000Z | clients/big_query/lib/google_api/big_query/v2/model/query_parameter_type_struct_types.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.BigQuery.V2.Model.QueryParameterTypeStructTypes do
@moduledoc """
## Attributes
* `description` (*type:* `String.t`, *default:* `nil`) - [Optional] Human-oriented description of the field.
* `name` (*type:* `String.t`, *default:* `nil`) - [Optional] The name of this field.
* `type` (*type:* `GoogleApi.BigQuery.V2.Model.QueryParameterType.t`, *default:* `nil`) - [Required] The type of this field.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:description => String.t() | nil,
:name => String.t() | nil,
:type => GoogleApi.BigQuery.V2.Model.QueryParameterType.t() | nil
}
field(:description)
field(:name)
field(:type, as: GoogleApi.BigQuery.V2.Model.QueryParameterType)
end
defimpl Poison.Decoder, for: GoogleApi.BigQuery.V2.Model.QueryParameterTypeStructTypes do
def decode(value, options) do
GoogleApi.BigQuery.V2.Model.QueryParameterTypeStructTypes.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.BigQuery.V2.Model.QueryParameterTypeStructTypes do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 35.169811 | 128 | 0.721567 |
ff290c4dbfe68c38576dec5bca0fee538b1dfe5b | 1,518 | ex | Elixir | clients/content/lib/google_api/content/v21/model/weight.ex | MasashiYokota/elixir-google-api | 975dccbff395c16afcb62e7a8e411fbb58e9ab01 | [
"Apache-2.0"
] | null | null | null | clients/content/lib/google_api/content/v21/model/weight.ex | MasashiYokota/elixir-google-api | 975dccbff395c16afcb62e7a8e411fbb58e9ab01 | [
"Apache-2.0"
] | null | null | null | clients/content/lib/google_api/content/v21/model/weight.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.Content.V21.Model.Weight do
@moduledoc """
## Attributes
* `unit` (*type:* `String.t`, *default:* `nil`) - Required. The weight unit.
Acceptable values are:
- "`kg`"
- "`lb`"
* `value` (*type:* `String.t`, *default:* `nil`) - Required. The weight represented as a number.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:unit => String.t(),
:value => String.t()
}
field(:unit)
field(:value)
end
defimpl Poison.Decoder, for: GoogleApi.Content.V21.Model.Weight do
def decode(value, options) do
GoogleApi.Content.V21.Model.Weight.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.Content.V21.Model.Weight do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 28.111111 | 100 | 0.693017 |
ff292c45d6d21fcde0f1c2aefe4d4110c3d5dbff | 126 | exs | Elixir | test/cdn_test.exs | AviKav/CDN | 5af2317e801e817dfc8d84dc431635e68694e915 | [
"MIT"
] | null | null | null | test/cdn_test.exs | AviKav/CDN | 5af2317e801e817dfc8d84dc431635e68694e915 | [
"MIT"
] | null | null | null | test/cdn_test.exs | AviKav/CDN | 5af2317e801e817dfc8d84dc431635e68694e915 | [
"MIT"
] | null | null | null | defmodule CdnTest do
use ExUnit.Case
doctest Cdn
test "greets the world" do
assert Cdn.hello() == :world
end
end
| 14 | 32 | 0.68254 |
ff2937abc8c9e41a9dbe6de72ede9036612b232a | 4,425 | exs | Elixir | farmbot_core/test/asset_workers/farm_event_worker/regimen_event_test.exs | adamswsk/farmbot_os | d177d3b74888c1e7bcbf8f8595818708ee97f73b | [
"MIT"
] | null | null | null | farmbot_core/test/asset_workers/farm_event_worker/regimen_event_test.exs | adamswsk/farmbot_os | d177d3b74888c1e7bcbf8f8595818708ee97f73b | [
"MIT"
] | null | null | null | farmbot_core/test/asset_workers/farm_event_worker/regimen_event_test.exs | adamswsk/farmbot_os | d177d3b74888c1e7bcbf8f8595818708ee97f73b | [
"MIT"
] | null | null | null | defmodule FarmbotCore.FarmEventWorker.RegimenEventTest do
use ExUnit.Case, async: true
alias FarmbotCore.FarmEventWorker.RegimenEvent
alias Farmbot.TestSupport.AssetFixtures
import ExUnit.CaptureLog
require Logger
use Mimic
@two_days_in_seconds 60 * 60 * 24 * 2
describe "regimen event scheduler" do
test "ensures regimen instance exists" do
regimen = AssetFixtures.regimen(%{})
farm_event = AssetFixtures.regimen_event(regimen, %{})
args = %{}
RegimenEvent.init([farm_event, args])
state = %{event: farm_event}
log =
capture_log(fn ->
result =
RegimenEvent.handle_info({:checkup, DateTime.utc_now()}, state)
assert {:noreply, state} == result
end)
assert log =~ "[debug] Ensuring RegimenInstance exists for event"
# assert_receive :ensure_started
end
test "handles not started yet" do
regimen = AssetFixtures.regimen(%{})
farm_event = AssetFixtures.regimen_event(regimen, %{})
args = %{}
RegimenEvent.init([farm_event, args])
state = %{event: farm_event, args: %{}}
log =
capture_log(fn ->
result =
RegimenEvent.handle_info(
{:checkup,
DateTime.utc_now()
|> DateTime.add(-@two_days_in_seconds, :second)},
state
)
assert {:noreply, state} == result
end)
assert log =~ ""
# assert_receive :ensure_not_started
end
test "handles regimen instance exists" do
regimen = AssetFixtures.regimen(%{})
farm_event = AssetFixtures.regimen_event(regimen, %{})
args = %{}
RegimenEvent.init([farm_event, args])
state = %{event: farm_event}
regimen_instance =
AssetFixtures.regimen_instance(%{}, %{}, %{
started_at:
DateTime.utc_now() |> DateTime.add(-@two_days_in_seconds, :second)
})
stub(FarmbotCore.Asset, :get_regimen_instance, fn _fe ->
regimen_instance
end)
log =
capture_log(fn ->
result = RegimenEvent.handle_info({:ensure_started}, state)
assert {:noreply, state} == result
end)
assert log =~ ""
# assert_receive :ensure_unchanged
end
test "creates regimen instance" do
regimen = AssetFixtures.regimen(%{})
farm_event = AssetFixtures.regimen_event(regimen, %{})
args = %{}
RegimenEvent.init([farm_event, args])
state = %{event: farm_event}
log =
capture_log(fn ->
result = RegimenEvent.handle_info({:ensure_started}, state)
assert {:noreply, state, :hibernate} == result
end)
assert log =~ "[debug] Creating RegimenInstance for event"
end
test "removes regimen instance" do
regimen = AssetFixtures.regimen(%{})
farm_event = AssetFixtures.regimen_event(regimen, %{})
args = %{}
RegimenEvent.init([farm_event, args])
state = %{event: farm_event, args: %{}}
regimen_instance =
AssetFixtures.regimen_instance(%{}, %{}, %{
started_at:
DateTime.utc_now() |> DateTime.add(@two_days_in_seconds, :second)
})
stub(FarmbotCore.Asset, :get_regimen_instance, fn _fe ->
regimen_instance
end)
log =
capture_log(fn ->
result = RegimenEvent.handle_info({:ensure_not_started}, state)
assert {:noreply, state, :hibernate} == result
end)
assert log =~ "[debug] RegimenInstance shouldn't exist for event"
end
test "changes regimen instance" do
regimen = AssetFixtures.regimen(%{})
farm_event = AssetFixtures.regimen_event(regimen, %{})
args = %{}
RegimenEvent.init([farm_event, args])
state = %{event: farm_event}
regimen_instance =
AssetFixtures.regimen_instance(%{}, %{}, %{
started_at:
DateTime.utc_now()
|> DateTime.add(@two_days_in_seconds * 2, :second)
})
stub(FarmbotCore.Asset, :get_regimen_instance, fn _fe ->
regimen_instance
end)
log =
capture_log(fn ->
result = RegimenEvent.handle_info({:ensure_unchanged}, state)
assert {:noreply, state, :hibernate} == result
end)
assert log =~ "[debug] RegimenInstance start time changed for event"
end
end
end
| 26.339286 | 78 | 0.600452 |
ff293dc2560e1a4c696437c1639036d6da9bd086 | 1,844 | exs | Elixir | test/cased/publisher/http_test.exs | cased/cased-elixir | a19a4c5d6dec3374c1067a908b357db798cfb2c8 | [
"MIT"
] | 3 | 2021-02-06T01:41:33.000Z | 2021-07-09T21:19:06.000Z | test/cased/publisher/http_test.exs | cased/cased-elixir | a19a4c5d6dec3374c1067a908b357db798cfb2c8 | [
"MIT"
] | 1 | 2021-07-09T20:34:35.000Z | 2021-07-09T20:35:29.000Z | test/cased/publisher/http_test.exs | cased/cased-elixir | a19a4c5d6dec3374c1067a908b357db798cfb2c8 | [
"MIT"
] | 2 | 2021-03-05T22:52:16.000Z | 2021-03-18T13:18:30.000Z | defmodule Cased.Publisher.HTTPTest do
use ExUnit.Case, async: true
import ExUnit.CaptureLog
import Cased.TestHelper
@key "publish_test_abcd"
setup context do
bypass = Bypass.open()
publisher =
start_supervised!(
{Cased.Publisher.HTTP,
key: @key, url: "http://localhost:#{bypass.port}", silence: context[:silence] || false}
)
{:ok, publisher: publisher, bypass: bypass}
end
test "handles publish", %{publisher: publisher, bypass: bypass} do
# Get application version for user-agent header check
{:ok, vsn} = :application.get_key(:cased, :vsn)
Bypass.expect_once(bypass, fn conn ->
# Check headers
assert {"authorization", "Bearer " <> @key} in conn.req_headers
assert {"content-type", "application/json"} in conn.req_headers
assert {"user-agent", "cased-elixir/v#{List.to_string(vsn)}"} in conn.req_headers
# Stub response
Plug.Conn.resp(conn, 200, ~s({"id":"test-response"}))
end)
assert capture_log(fn ->
publish(publisher)
Process.sleep(500)
end) =~ "Received HTTP 200 response from Cased"
end
@tag silence: true
test "handles publish with silence", %{publisher: publisher} do
assert capture_log(fn ->
publish(publisher)
Process.sleep(500)
end) =~ "Silenced Cased publish"
end
describe "start_link/1" do
test "returns an error when misconfigured" do
assert {:error, %Cased.ConfigurationError{message: "invalid publisher configuration"}} =
Cased.Publisher.HTTP.start_link([])
end
end
defp publish(publisher) do
assert_publishes_cased_events(publisher, 1, fn ->
assert GenServer.call(publisher, {:publish, ~s({"data":"fake"})}) in [:ok, nil]
end)
:sys.get_state(publisher)
end
end
| 29.741935 | 96 | 0.643167 |
ff29409365a62e1dbcaf30183f944d8723bb7406 | 83 | exs | Elixir | test/r_list/support_test.exs | tashirosota/ex-rubenium | 0ddb30c31b678889a65dae7674ab7010e1dd7c5e | [
"Apache-2.0"
] | 24 | 2022-01-13T23:13:11.000Z | 2022-03-27T18:02:39.000Z | test/r_list/support_test.exs | tashirosota/ex-rubenium | 0ddb30c31b678889a65dae7674ab7010e1dd7c5e | [
"Apache-2.0"
] | 16 | 2022-01-16T09:18:17.000Z | 2022-02-08T01:10:09.000Z | test/r_list/support_test.exs | tashirosota/ex-rubenium | 0ddb30c31b678889a65dae7674ab7010e1dd7c5e | [
"Apache-2.0"
] | 6 | 2022-01-16T04:40:42.000Z | 2022-02-07T14:56:26.000Z | defmodule RList.RList.SupportTest do
use ExUnit.Case
doctest RList.Support
end
| 16.6 | 36 | 0.807229 |
ff295f06b1165816c84d4c927cbe62b01196cc64 | 2,843 | ex | Elixir | lib/ecto/query/builder/dynamic.ex | joerichsen/ecto | 13e22d1f2a18f5698d5b0db5112f3936cab86ae8 | [
"Apache-2.0"
] | 1 | 2022-01-24T07:32:34.000Z | 2022-01-24T07:32:34.000Z | lib/ecto/query/builder/dynamic.ex | joerichsen/ecto | 13e22d1f2a18f5698d5b0db5112f3936cab86ae8 | [
"Apache-2.0"
] | null | null | null | lib/ecto/query/builder/dynamic.ex | joerichsen/ecto | 13e22d1f2a18f5698d5b0db5112f3936cab86ae8 | [
"Apache-2.0"
] | null | null | null | import Kernel, except: [apply: 2]
defmodule Ecto.Query.Builder.Dynamic do
@moduledoc false
alias Ecto.Query.Builder
@doc """
Builds a dynamic expression.
"""
@spec build([Macro.t], Macro.t, Macro.Env.t) :: Macro.t
def build(binding, expr, env) do
{query, vars} = Builder.escape_binding(quote(do: query), binding, env)
{expr, {params, subqueries}} = Builder.escape(expr, :any, {[], []}, vars, env)
params = Builder.escape_params(params)
quote do
%Ecto.Query.DynamicExpr{fun: fn query ->
_ = unquote(query)
{unquote(expr), unquote(params), unquote(subqueries)}
end,
binding: unquote(Macro.escape(binding)),
file: unquote(env.file),
line: unquote(env.line)}
end
end
@doc """
Expands a dynamic expression for insertion into the given query.
"""
def fully_expand(query, %{file: file, line: line, binding: binding} = dynamic) do
{expr, {binding, params, subqueries, _count}} = expand(query, dynamic, {binding, [], [], 0})
{expr, binding, Enum.reverse(params), Enum.reverse(subqueries), file, line}
end
@doc """
Expands a dynamic expression as part of an existing expression.
Any dynamic expression parameter is prepended and the parameters
list is not reversed. This is useful when the dynamic expression
is given in the middle of an expression.
"""
def partially_expand(kind, query, %{binding: binding} = dynamic, params, count) do
{expr, {_binding, params, subqueries, count}} = expand(query, dynamic, {binding, params, [], count})
if subqueries != [] do
raise ArgumentError, "subqueries are not allowed in `#{kind}` expressions"
end
{expr, params, count}
end
defp expand(query, %{fun: fun}, {binding, params, subqueries, count}) do
{dynamic_expr, dynamic_params, dynamic_subqueries} = fun.(query)
Macro.postwalk(dynamic_expr, {binding, params, subqueries, count}, fn
{:^, meta, [ix]}, {binding, params, subqueries, count} ->
case Enum.fetch!(dynamic_params, ix) do
{%Ecto.Query.DynamicExpr{binding: new_binding} = dynamic, _} ->
binding = if length(new_binding) > length(binding), do: new_binding, else: binding
expand(query, dynamic, {binding, params, subqueries, count})
param ->
{{:^, meta, [count]}, {binding, [param | params], subqueries, count + 1}}
end
{:subquery, i}, {binding, params, subqueries, count} ->
subquery = Enum.fetch!(dynamic_subqueries, i)
ix = length(subqueries)
{{:subquery, ix}, {binding, [{:subquery, ix} | params], [subquery | subqueries], count}}
expr, acc ->
{expr, acc}
end)
end
end
| 37.407895 | 104 | 0.609919 |
ff298863d7de65e6dccb02c6abc072a44e2d0deb | 2,062 | ex | Elixir | clients/dfa_reporting/lib/google_api/dfa_reporting/v33/model/user_role_permission_groups_list_response.ex | matehat/elixir-google-api | c1b2523c2c4cdc9e6ca4653ac078c94796b393c3 | [
"Apache-2.0"
] | 1 | 2018-12-03T23:43:10.000Z | 2018-12-03T23:43:10.000Z | clients/dfa_reporting/lib/google_api/dfa_reporting/v33/model/user_role_permission_groups_list_response.ex | matehat/elixir-google-api | c1b2523c2c4cdc9e6ca4653ac078c94796b393c3 | [
"Apache-2.0"
] | null | null | null | clients/dfa_reporting/lib/google_api/dfa_reporting/v33/model/user_role_permission_groups_list_response.ex | matehat/elixir-google-api | c1b2523c2c4cdc9e6ca4653ac078c94796b393c3 | [
"Apache-2.0"
] | null | null | null | # Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "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 class is auto generated by the elixir code generator program.
# Do not edit the class manually.
defmodule GoogleApi.DFAReporting.V33.Model.UserRolePermissionGroupsListResponse do
@moduledoc """
User Role Permission Group List Response
## Attributes
* `kind` (*type:* `String.t`, *default:* `dfareporting#userRolePermissionGroupsListResponse`) - Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionGroupsListResponse".
* `userRolePermissionGroups` (*type:* `list(GoogleApi.DFAReporting.V33.Model.UserRolePermissionGroup.t)`, *default:* `nil`) - User role permission group collection.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:kind => String.t(),
:userRolePermissionGroups =>
list(GoogleApi.DFAReporting.V33.Model.UserRolePermissionGroup.t())
}
field(:kind)
field(
:userRolePermissionGroups,
as: GoogleApi.DFAReporting.V33.Model.UserRolePermissionGroup,
type: :list
)
end
defimpl Poison.Decoder, for: GoogleApi.DFAReporting.V33.Model.UserRolePermissionGroupsListResponse do
def decode(value, options) do
GoogleApi.DFAReporting.V33.Model.UserRolePermissionGroupsListResponse.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.DFAReporting.V33.Model.UserRolePermissionGroupsListResponse do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 36.821429 | 218 | 0.757032 |
ff29a1df3b7e694432c9fdcf4012f9a02070526b | 2,291 | exs | Elixir | apps/snitch_core/test/data/model/product_review_test.exs | saurabharch/avia | 74a82a95cf8bfe8143d1fce8136a3bb7ffc9467c | [
"MIT"
] | 1 | 2018-12-01T18:13:55.000Z | 2018-12-01T18:13:55.000Z | apps/snitch_core/test/data/model/product_review_test.exs | saurabharch/avia | 74a82a95cf8bfe8143d1fce8136a3bb7ffc9467c | [
"MIT"
] | null | null | null | apps/snitch_core/test/data/model/product_review_test.exs | saurabharch/avia | 74a82a95cf8bfe8143d1fce8136a3bb7ffc9467c | [
"MIT"
] | null | null | null | defmodule Snitch.Data.Model.ProductReviewTest do
use ExUnit.Case, async: true
use Snitch.DataCase
import Snitch.Factory
alias Snitch.Data.Model.ProductReview
setup do
product = insert(:product)
[product: product]
end
setup :rating_options
@tag rating_option_count: 1
test "create product review successfully", context do
%{product: product} = context
user = insert(:user)
%{rating_options: rating_options} = context
rating_option = List.first(rating_options)
review_params = product_review_params(product, user, rating_option)
assert {:ok, _} = ProductReview.add(review_params)
product = Repo.preload(product, :reviews)
assert length(product.reviews) != 0
end
@tag rating_option_count: 1
test "creation fails for invalid params", context do
%{product: product} = context
user = %{id: -1}
%{rating_options: rating_options} = context
rating_option = List.first(rating_options)
review_params = product_review_params(product, user, rating_option)
assert {:error, changeset} = ProductReview.add(review_params)
assert %{user_id: ["does not exist"]} = errors_on(changeset)
end
@tag rating_option_count: 2
test "get rating aggregate for a product", context do
%{product: product} = context
user1 = insert(:user)
user2 = insert(:user, role: %{name: "user"})
%{rating_options: rating_options} = context
[rating_option_1 | [rating_option_2 | _]] = rating_options
review_params = product_review_params(product, user1, rating_option_1)
assert {:ok, _} = ProductReview.add(review_params)
review_params = product_review_params(product, user2, rating_option_2)
assert {:ok, _} = ProductReview.add(review_params)
result = ProductReview.review_aggregate(product)
assert result.average_rating ==
Decimal.div(rating_option_1.value + rating_option_2.value, 2)
|> Decimal.round(1)
assert result.review_count == 2
end
defp product_review_params(product, user, rating_option) do
%{
attributes: %{
description: "awesomeness redefined",
user_id: user.id,
name: "stark"
},
rating_option_vote: %{
rating_option: rating_option
},
product_id: product.id
}
end
end
| 31.819444 | 74 | 0.695766 |
ff29cbeb1ee43ae5fa9dd31f0eca3058703e6df5 | 2,031 | exs | Elixir | test/commands/alias/create_test.exs | matusf/cog | 71708301c7dc570fb0d3498a50f47a70ef957788 | [
"Apache-2.0"
] | 1,003 | 2016-02-23T17:21:12.000Z | 2022-02-20T14:39:35.000Z | test/commands/alias/create_test.exs | matusf/cog | 71708301c7dc570fb0d3498a50f47a70ef957788 | [
"Apache-2.0"
] | 906 | 2016-02-22T22:54:19.000Z | 2022-03-11T15:19:43.000Z | test/commands/alias/create_test.exs | matusf/cog | 71708301c7dc570fb0d3498a50f47a70ef957788 | [
"Apache-2.0"
] | 95 | 2016-02-23T13:42:31.000Z | 2021-11-30T14:39:55.000Z | defmodule Cog.Test.Commands.Alias.CreateTest do
use Cog.CommandCase, command_module: Cog.Commands.Alias
alias Cog.Commands.Alias.Create
import Cog.Support.ModelUtilities, only: [with_alias: 3,
get_alias: 2,
user: 1]
setup :with_user
describe "alias creation" do
test "with standard args", %{user: user} do
{:ok, response} = new_req(user: %{"id" => user.id}, args: ["my-new-alias", "echo My New Alias"])
|> send_req(Create)
assert(%{name: "my-new-alias",
pipeline: "echo My New Alias",
visibility: "user"} = response)
created_alias = get_alias("my-new-alias", user.id)
assert(%{name: "my-new-alias",
pipeline: "echo My New Alias",
visibility: "user"} = created_alias)
end
test "with an existing name", %{user: user}=context do
with_user_alias(context)
{:error, error} = new_req(user: %{"id" => user.id}, args: ["my-new-alias", "echo My New Alias"])
|> send_req(Create)
assert(error == "name: The alias name is already in use.")
end
end
describe "alias args" do
test "passing too many", %{user: user} do
{:error, error} = new_req(user: %{"id" => user.id}, args: ["my-invalid-alias", "echo foo", "invalid-arg"])
|> send_req(Create)
assert(error == "Too many args. Arguments required: exactly 2.")
end
test "passing too few", %{user: user} do
{:error, error} = new_req(user: %{"id" => user.id}, args: ["my-invalid-alias"])
|> send_req(Create)
assert(error == "Not enough args. Arguments required: exactly 2.")
end
end
### Context Functions ###
defp with_user(),
do: user("alias_test_user")
defp with_user(_),
do: [user: with_user()]
# User aliases requires a user, so it must be called with context
defp with_user_alias(%{user: user}) do
with_alias(user, "my-new-alias", "echo My New Alias")
:ok
end
end
| 30.313433 | 112 | 0.585426 |
ff29d13d47f3c12717c4cbb08b9c3e8667cd6099 | 2,094 | ex | Elixir | clients/video_intelligence/lib/google_api/video_intelligence/v1/model/google_cloud_videointelligence_v1__speech_context.ex | matehat/elixir-google-api | c1b2523c2c4cdc9e6ca4653ac078c94796b393c3 | [
"Apache-2.0"
] | 1 | 2018-12-03T23:43:10.000Z | 2018-12-03T23:43:10.000Z | clients/video_intelligence/lib/google_api/video_intelligence/v1/model/google_cloud_videointelligence_v1__speech_context.ex | matehat/elixir-google-api | c1b2523c2c4cdc9e6ca4653ac078c94796b393c3 | [
"Apache-2.0"
] | null | null | null | clients/video_intelligence/lib/google_api/video_intelligence/v1/model/google_cloud_videointelligence_v1__speech_context.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 "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 class is auto generated by the elixir code generator program.
# Do not edit the class manually.
defmodule GoogleApi.VideoIntelligence.V1.Model.GoogleCloudVideointelligenceV1_SpeechContext do
@moduledoc """
Provides "hints" to the speech recognizer to favor specific words and phrases
in the results.
## Attributes
* `phrases` (*type:* `list(String.t)`, *default:* `nil`) - *Optional* A list of strings containing words and phrases "hints" so that
the speech recognition is more likely to recognize them. This can be used
to improve the accuracy for specific words and phrases, for example, if
specific commands are typically spoken by the user. This can also be used
to add additional words to the vocabulary of the recognizer. See
[usage limits](https://cloud.google.com/speech/limits#content).
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:phrases => list(String.t())
}
field(:phrases, type: :list)
end
defimpl Poison.Decoder,
for: GoogleApi.VideoIntelligence.V1.Model.GoogleCloudVideointelligenceV1_SpeechContext do
def decode(value, options) do
GoogleApi.VideoIntelligence.V1.Model.GoogleCloudVideointelligenceV1_SpeechContext.decode(
value,
options
)
end
end
defimpl Poison.Encoder,
for: GoogleApi.VideoIntelligence.V1.Model.GoogleCloudVideointelligenceV1_SpeechContext do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 36.103448 | 136 | 0.748329 |
ff29fe0e89530b91f7cd593df4ca45853cd81ef2 | 1,061 | exs | Elixir | mix.exs | knewter/ecto | faacfeef25e35c42b1e97323b03d5bed9ba51416 | [
"Apache-2.0"
] | null | null | null | mix.exs | knewter/ecto | faacfeef25e35c42b1e97323b03d5bed9ba51416 | [
"Apache-2.0"
] | null | null | null | mix.exs | knewter/ecto | faacfeef25e35c42b1e97323b03d5bed9ba51416 | [
"Apache-2.0"
] | null | null | null | defmodule Ecto.Mixfile do
use Mix.Project
def project do
[ app: :ecto,
version: "0.0.1",
deps: deps(Mix.env),
env: envs,
name: "Ecto",
elixir: "~> 0.11.0",
source_url: "https://github.com/elixir-lang/ecto",
docs: fn -> [
source_ref: System.cmd("git rev-parse --verify --quiet HEAD"),
main: "overview",
readme: true ]
end ]
end
def application do
[]
end
defp deps(:prod) do
[ { :poolboy, github: "devinus/poolboy" } ]
end
defp deps(_) do
deps(:prod) ++
[ { :ex_doc, github: "elixir-lang/ex_doc" },
{ :postgrex, github: "ericmj/postgrex" } ]
end
defp envs do
[ pg: [ test_paths: ["integration_test/pg"] ],
all: [ test_paths: ["test", "integration_test/pg"] ] ]
end
end
defmodule Mix.Tasks.Release_docs do
@shortdoc "Releases docs"
def run(_) do
Mix.Task.run "docs"
File.rm_rf "../elixir-lang.github.com/docs/ecto"
File.cp_r "docs/.", "../elixir-lang.github.com/docs/ecto/"
File.rm_rf "docs"
end
end
| 21.22 | 70 | 0.574929 |
ff2a04492acb54f6c3071751d965481678a1829e | 1,700 | exs | Elixir | config/config.exs | NorifumiKawamoto/ginjyo | 8e28438db4675bb55ba090614c6834190adb61b1 | [
"MIT"
] | null | null | null | config/config.exs | NorifumiKawamoto/ginjyo | 8e28438db4675bb55ba090614c6834190adb61b1 | [
"MIT"
] | null | null | null | config/config.exs | NorifumiKawamoto/ginjyo | 8e28438db4675bb55ba090614c6834190adb61b1 | [
"MIT"
] | null | null | null | # This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
use Mix.Config
# Configures the endpoint
config :ginjyo, Ginjyo.Endpoint,
url: [host: "localhost"],
root: Path.dirname(__DIR__),
secret_key_base:
"/8cMp2cpmyp97CvmeanlfnwuYUKz6nK4Ouc/M4s8FbSrZuK+vQki/u8mXQ/oU9lC",
render_errors: [accepts: ~w(html json)],
pubsub: [name: Ginjyo.PubSub,
adapter: Phoenix.PubSub.PG2]
config :ginjyo, Ginjyo.Gettext, default_locale: "ja"
# Configures Elixir's Logger
# config :logger, :console,
# format: "$time $metadata[$level] $message\n",
# metadata: [:request_id]
# SiteInfo
config :ginjyo,
site_title: "Ginjyo", # your site name
sub_title: "Blog system", # your site sub title
site_image: "/images/logo.png",
description: "It is blog site made by elixir.",
lang: "ja", # ja, en
static_path: "priv/static",
upload_path: "/images/upload/"
# SNS
config :ginjyo,
twitter: "", # your twitter @account
facebook: "", # your facebook account
github: "" # your github account
# Comment
config :ginjyo,
disqus: "" # your disqus
# Analytics
config :ginjyo,
google_analytics: "UA-" # Tracking-ID UA-XXXXXX
# Push notification
config :ginjyo,
google_push_code: ""
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env}.exs"
# Configure phoenix generators
config :phoenix, :generators,
migration: true,
binary_id: false
config :scrivener_html,
routes_helper: Ginjyo.Router.Helpers
| 26.153846 | 71 | 0.722941 |
ff2a0cb1adcc37a91097b645e842f770d70d09ce | 554 | ex | Elixir | lib/pipe_converter/cli.ex | marocchino/pipe_converter | a847df3a59ae8e396c862af32b844ecdb56e4e70 | [
"MIT"
] | 6 | 2016-11-08T08:33:56.000Z | 2021-02-02T05:44:36.000Z | lib/pipe_converter/cli.ex | marocchino/pipe_converter | a847df3a59ae8e396c862af32b844ecdb56e4e70 | [
"MIT"
] | null | null | null | lib/pipe_converter/cli.ex | marocchino/pipe_converter | a847df3a59ae8e396c862af32b844ecdb56e4e70 | [
"MIT"
] | 1 | 2021-02-02T05:44:44.000Z | 2021-02-02T05:44:44.000Z | defmodule PipeConverter.CLI do
@moduledoc """
Parse options and run script
"""
alias PipeConverter.Tree
def main(args \\ []) do
parse_args(args) |> response() |> IO.puts()
end
defp parse_args(args) do
{opts, [code | _], _} = OptionParser.parse(args, switches: [revert: :boolean])
{opts, code}
end
defp response({[revert: true], code}) do
PipeConverter.replace(code, &Tree.to_braces(Tree.from_code(&1)))
end
defp response({_, code}) do
PipeConverter.replace(code, &Tree.to_pipe(Tree.from_code(&1)))
end
end
| 23.083333 | 82 | 0.658845 |
ff2a452f2b6cd32fa1cc0e18cfca3acfefe7b502 | 5,351 | ex | Elixir | lib/changelog_web/meta/title.ex | akoutmos/changelog.com | 395459cf825764c002ad93794824986b76cf9b10 | [
"MIT"
] | null | null | null | lib/changelog_web/meta/title.ex | akoutmos/changelog.com | 395459cf825764c002ad93794824986b76cf9b10 | [
"MIT"
] | null | null | null | lib/changelog_web/meta/title.ex | akoutmos/changelog.com | 395459cf825764c002ad93794824986b76cf9b10 | [
"MIT"
] | null | null | null | defmodule ChangelogWeb.Meta.Title do
alias ChangelogWeb.{
AuthView,
EpisodeView,
EpisodeRequestView,
LiveView,
NewsItemView,
NewsSourceView,
PageView,
PersonView,
PodcastView,
PostView,
TopicView,
Helpers.SharedHelpers,
SearchView
}
@default "News and podcasts for developers"
def page_title(assigns) do
[get(assigns) || @default, "Changelog"]
|> Enum.reject(&is_nil/1)
|> Enum.join(" |> ")
end
# no need for the suffix on these
def share_title(assigns), do: get(assigns) || @default
# 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, podcast: podcast, episode: episode}),
do: "#{podcast.name} Live! #{episode.title}"
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 item - top
defp get(%{view_module: NewsItemView, view_template: "top.html", filter: filter}) do
suffix =
case filter do
"week" -> "this week"
"month" -> "this month"
"all" -> "of all time"
end
"Top developer news #{suffix}"
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
"#{topic.name} podcasts for developers"
end
defp get(%{view_module: TopicView, topic: topic}) do
"#{topic.name} news and podcasts for developers"
end
# Person show pages
defp get(%{view_module: PersonView, person: person, tab: "news"}) do
"News contributed by #{person.name}"
end
defp get(%{view_module: PersonView, person: person, tab: "podcasts"}) do
"#{person.name}'s podcast episodes On Changelog"
end
defp get(%{view_module: PersonView, person: person}) do
"#{person.name} on Changelog"
end
# Guest guide
defp get(%{view_module: PageView, view_template: "guest.html", podcast: podcast}) do
if podcast.slug == "podcast" do
"Changelog's guest guide"
else
"Changelog's guest guide for #{podcast.name}"
end
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"
"ten.html" ->
"Celebrating ten years of Changelog"
_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: "Podcasts for developers"
# Podcast homepages
defp get(%{view_module: PodcastView, podcast: podcast, tab: "popular"}) do
"Popular episodes of #{podcast.name}"
end
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.active_hosts) do
"#{podcast.name} Podcast with #{SharedHelpers.comma_separated_names(podcast.active_hosts)}"
else
podcast.name
end
end
# Episode page
defp get(%{
view_module: EpisodeView,
view_template: "show.html",
podcast: _podcast,
episode: episode
}) do
EpisodeView.title_with_guest_focused_subtitle_and_podcast_aside(episode)
end
# Episode request form
defp get(%{view_module: EpisodeRequestView, view_template: "new.html", podcast: podcast}) do
"Request an episode of #{podcast.name}"
end
defp get(%{view_module: EpisodeRequestView, view_template: "new.html"}) do
"Request an episode"
end
# Posts index (blog)
defp get(%{view_module: PostView, view_template: "index.html"}), do: "Solid takes from Changelog contributors"
# Post show page
defp get(%{view_module: PostView, post: post}), do: post.title
defp get(_), do: nil
end
| 27.025253 | 112 | 0.652588 |
ff2aaa79f796e8378df4eae353b729a46eb2fb50 | 1,661 | exs | Elixir | config/dev.exs | jennifertakagi/chewiepay | 15b5eca89f56e2933610f3edda7412889dc08137 | [
"MIT"
] | 4 | 2021-02-22T18:27:51.000Z | 2021-02-28T21:54:12.000Z | config/dev.exs | jennifertakagi/chewiepay | 15b5eca89f56e2933610f3edda7412889dc08137 | [
"MIT"
] | null | null | null | config/dev.exs | jennifertakagi/chewiepay | 15b5eca89f56e2933610f3edda7412889dc08137 | [
"MIT"
] | null | null | null | use Mix.Config
# Configure your database
config :chewiepay, Chewiepay.Repo,
username: "postgres",
password: "postgres",
database: "chewiepay_dev",
hostname: "localhost",
show_sensitive_data_on_connection_error: true,
pool_size: 10
# For development, we disable any cache and enable
# debugging and code reloading.
#
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with webpack to recompile .js and .css sources.
config :chewiepay, ChewiepayWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: []
# ## SSL Support
#
# In order to use HTTPS in development, a self-signed
# certificate can be generated by running the following
# Mix task:
#
# mix phx.gen.cert
#
# Note that this task requires Erlang/OTP 20 or later.
# Run `mix help phx.gen.cert` for more information.
#
# The `http:` config above can be replaced with:
#
# https: [
# port: 4001,
# cipher_suite: :strong,
# keyfile: "priv/cert/selfsigned_key.pem",
# certfile: "priv/cert/selfsigned.pem"
# ],
#
# If desired, both `http:` and `https:` keys can be
# configured to run both http and https servers on
# different ports.
# Do not include metadata nor timestamps in development logs
config :logger, :console, format: "[$level] $message\n"
# Set a higher stacktrace during development. Avoid configuring such
# in production as building large stacktraces may be expensive.
config :phoenix, :stacktrace_depth, 20
# Initialize plugs at runtime for faster development compilation
config :phoenix, :plug_init_mode, :runtime
| 28.637931 | 68 | 0.727875 |
ff2ab60df359c4f23971fe77ad417498e2581602 | 1,980 | exs | Elixir | src/server/config/prod.exs | bryceklinker/trader | 9fb06bf7638e2434802b0414ac9bea46cf4f94c9 | [
"MIT"
] | null | null | null | src/server/config/prod.exs | bryceklinker/trader | 9fb06bf7638e2434802b0414ac9bea46cf4f94c9 | [
"MIT"
] | null | null | null | src/server/config/prod.exs | bryceklinker/trader | 9fb06bf7638e2434802b0414ac9bea46cf4f94c9 | [
"MIT"
] | null | null | null | use Mix.Config
# For production, we configure the host to read the PORT
# from the system environment. Therefore, you will need
# to set PORT=80 before running your server.
#
# You should also configure the url host to something
# meaningful, we use this information when generating URLs.
#
# Finally, we also include the path to a manifest
# containing the digested version of static files. This
# manifest is generated by the mix phoenix.digest task
# which you typically run after static files are built.
config :server, Server.Endpoint,
http: [port: {:system, "PORT"}],
url: [host: "example.com", port: 80],
cache_static_manifest: "priv/static/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 :server, Server.Endpoint,
# ...
# url: [host: "example.com", port: 443],
# https: [port: 443,
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")]
#
# Where those two env variables return an absolute path to
# the key and cert in disk or a relative path inside priv,
# for example "priv/ssl/server.key".
#
# We also recommend setting `force_ssl`, ensuring no data is
# ever sent via http, always redirecting to https:
#
# config :server, Server.Endpoint,
# force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.
# ## Using releases
#
# If you are doing OTP releases, you need to instruct Phoenix
# to start the server for all endpoints:
#
# config :phoenix, :serve_endpoints, true
#
# Alternatively, you can configure exactly which server to
# start per endpoint:
#
# config :server, Server.Endpoint, server: true
#
# Finally import the config/prod.secret.exs
# which should be versioned separately.
import_config "prod.secret.exs"
| 31.935484 | 67 | 0.712121 |
ff2ac856a123d833f0e576f62e856b9d3c4c9f73 | 4,232 | ex | Elixir | deps/credo/lib/credo/execution.ex | BandanaPandey/nary_tree | fb1eeb69e38e43c9f9ffb54297cef52dff5c928d | [
"MIT"
] | 13 | 2018-09-19T21:03:29.000Z | 2022-01-27T04:06:32.000Z | deps/credo/lib/credo/execution.ex | BandanaPandey/nary_tree | fb1eeb69e38e43c9f9ffb54297cef52dff5c928d | [
"MIT"
] | 1 | 2020-05-26T04:16:57.000Z | 2020-05-26T04:16:57.000Z | deps/credo/lib/credo/execution.ex | BandanaPandey/nary_tree | fb1eeb69e38e43c9f9ffb54297cef52dff5c928d | [
"MIT"
] | 3 | 2020-05-21T04:32:08.000Z | 2021-07-28T05:14:01.000Z | defmodule Credo.Execution do
@doc """
Every run of Credo is configured via a `Execution` struct, which is created and
manipulated via the `Credo.Execution` module.
"""
defstruct argv: [],
cli_options: nil,
# config
files: nil,
color: true,
checks: nil,
requires: [],
strict: false,
check_for_updates: true, # checks if there is a new version of Credo
# options, set by the command line
min_priority: 0,
help: false,
version: false,
verbose: false,
all: false,
format: nil,
only_checks: nil,
ignore_checks: nil,
crash_on_error: true,
mute_exit_status: false,
read_from_stdin: false,
# state, which is accessed and changed over the course of Credo's execution
halted: false,
source_files_pid: nil,
issues_pid: nil,
skipped_checks: nil,
assigns: %{},
results: %{},
config_comment_map: %{},
lint_attribute_map: %{} # maps filenames to @lint attributes
@type t :: module
alias Credo.Execution.Issues
alias Credo.Execution.SourceFiles
@doc """
Returns the checks that should be run for a given `exec` struct.
Takes all checks from the `checks:` field of the exec, matches those against
any patterns to include or exclude certain checks given via the command line.
"""
def checks(%__MODULE__{checks: checks, only_checks: only_checks, ignore_checks: ignore_checks}) do
match_regexes =
only_checks
|> List.wrap
|> to_match_regexes
ignore_regexes =
ignore_checks
|> List.wrap
|> to_match_regexes
checks
|> Enum.filter(&match_regex(&1, match_regexes, true))
|> Enum.reject(&match_regex(&1, ignore_regexes, false))
end
defp match_regex(_tuple, [], default_for_empty), do: default_for_empty
defp match_regex(tuple, regexes, _default_for_empty) do
check_name =
tuple
|> Tuple.to_list
|> List.first
|> to_string
Enum.any?(regexes, &Regex.run(&1, check_name))
end
defp to_match_regexes(list) do
Enum.map(list, fn(match_check) ->
{:ok, match_pattern} = Regex.compile(match_check, "i")
match_pattern
end)
end
@doc """
Sets the exec values which `strict` implies (if applicable).
"""
def set_strict(%__MODULE__{strict: true} = exec) do
%__MODULE__{exec | all: true, min_priority: -99}
end
def set_strict(%__MODULE__{strict: false} = exec) do
%__MODULE__{exec | min_priority: 0}
end
def set_strict(exec), do: exec
@doc """
Returns the name of the command, which should be run by the given execution.
"""
def get_command_name(exec) do
exec.cli_options.command
end
def get_path(exec) do
exec.cli_options.path
end
# Assigns
def get_assign(exec, name, default \\ nil) do
Map.get(exec.assigns, name, default)
end
def put_assign(exec, name, value) do
%__MODULE__{exec | assigns: Map.put(exec.assigns, name, value)}
end
# Source Files
def get_source_files(exec) do
Credo.Execution.SourceFiles.get(exec)
end
def put_source_files(exec, source_files) do
SourceFiles.put(exec, source_files)
exec
end
# Issues
def get_issues(exec) do
exec
|> Issues.to_map
|> Map.values
|> List.flatten
end
def get_issues(exec, filename) do
exec
|> Issues.to_map
|> Map.get(filename, [])
end
# Results
def get_result(exec, name, default \\ nil) do
Map.get(exec.results, name, default)
end
def put_result(exec, name, value) do
%__MODULE__{exec | results: Map.put(exec.results, name, value)}
end
# Halt
def halt(exec) do
%__MODULE__{exec | halted: true}
end
def start_servers(%__MODULE__{} = exec) do
exec
|> SourceFiles.start_server
|> Issues.start_server
end
end
| 25.04142 | 100 | 0.592864 |
ff2ae01655a55ad6d5ba3199921e0f6c45521f19 | 3,365 | exs | Elixir | test/elixir_google_scraper_web/controllers/user_confirmation_controller_test.exs | junan/elixir_google_scraper | d032f3a9d5a30e354f1e6d607434670334936630 | [
"MIT"
] | null | null | null | test/elixir_google_scraper_web/controllers/user_confirmation_controller_test.exs | junan/elixir_google_scraper | d032f3a9d5a30e354f1e6d607434670334936630 | [
"MIT"
] | 25 | 2021-05-21T02:23:37.000Z | 2021-07-09T09:22:32.000Z | test/elixir_google_scraper_web/controllers/user_confirmation_controller_test.exs | junan/elixir_google_scraper | d032f3a9d5a30e354f1e6d607434670334936630 | [
"MIT"
] | null | null | null | defmodule ElixirGoogleScraperWeb.UserConfirmationControllerTest do
use ElixirGoogleScraperWeb.ConnCase, async: true
import ElixirGoogleScraper.AccountsFixtures
alias ElixirGoogleScraper.Account.Users
alias ElixirGoogleScraper.Account.Schemas.{User, UserToken}
alias ElixirGoogleScraper.Repo
setup do
%{user: user_fixture()}
end
describe "GET /users/confirm" do
test "renders the confirmation page", %{conn: conn} do
conn = get(conn, Routes.user_confirmation_path(conn, :new))
response = html_response(conn, 200)
assert response =~ "<h1>Resend confirmation instructions</h1>"
end
end
describe "POST /users/confirm" do
@tag :capture_log
test "sends a new confirmation token", %{conn: conn, user: user} do
conn =
post(conn, Routes.user_confirmation_path(conn, :create), %{
"user" => %{"email" => user.email}
})
assert redirected_to(conn) == "/"
assert get_flash(conn, :info) =~ "If your email is in our system"
assert Repo.get_by!(UserToken, user_id: user.id).context == "confirm"
end
test "does not send confirmation token if User is confirmed", %{conn: conn, user: user} do
Repo.update!(User.confirm_changeset(user))
conn =
post(conn, Routes.user_confirmation_path(conn, :create), %{
"user" => %{"email" => user.email}
})
assert redirected_to(conn) == "/"
assert get_flash(conn, :info) =~ "If your email is in our system"
refute Repo.get_by(UserToken, user_id: user.id)
end
test "does not send confirmation token if email is invalid", %{conn: conn} do
conn =
post(conn, Routes.user_confirmation_path(conn, :create), %{
"user" => %{"email" => "unknown@example.com"}
})
assert redirected_to(conn) == "/"
assert get_flash(conn, :info) =~ "If your email is in our system"
assert Repo.all(UserToken) == []
end
end
describe "GET /users/confirm/:token" do
test "confirms the given token once", %{conn: conn, user: user} do
token =
extract_user_token(fn url ->
Users.deliver_user_confirmation_instructions(user, url)
end)
conn = get(conn, Routes.user_confirmation_path(conn, :confirm, token))
assert redirected_to(conn) == "/"
assert get_flash(conn, :info) =~ "User confirmed successfully"
assert Users.get_user!(user.id).confirmed_at
refute get_session(conn, :user_token)
assert Repo.all(UserToken) == []
# When not logged in
conn = get(conn, Routes.user_confirmation_path(conn, :confirm, token))
assert redirected_to(conn) == "/"
assert get_flash(conn, :error) =~ "User confirmation link is invalid or it has expired"
# When logged in
conn =
build_conn()
|> log_in_user(user)
|> get(Routes.user_confirmation_path(conn, :confirm, token))
assert redirected_to(conn) == "/"
refute get_flash(conn, :error)
end
test "does not confirm email with invalid token", %{conn: conn, user: user} do
conn = get(conn, Routes.user_confirmation_path(conn, :confirm, "oops"))
assert redirected_to(conn) == "/"
assert get_flash(conn, :error) =~ "User confirmation link is invalid or it has expired"
refute Users.get_user!(user.id).confirmed_at
end
end
end
| 35.052083 | 94 | 0.651709 |
ff2b7e7e986af135569a3231cf97f6cc014688d7 | 83 | ex | Elixir | examples/uniswap_v2/events/sync.ex | AwaitFuture/slurp | f1d0fe5feb21f3135727c1516908e89130ea5801 | [
"MIT"
] | 20 | 2021-01-02T07:45:04.000Z | 2022-03-29T07:34:42.000Z | examples/uniswap_v2/events/sync.ex | AwaitFuture/slurp | f1d0fe5feb21f3135727c1516908e89130ea5801 | [
"MIT"
] | 11 | 2021-01-25T13:10:34.000Z | 2021-09-23T05:34:08.000Z | examples/uniswap_v2/events/sync.ex | AwaitFuture/slurp | f1d0fe5feb21f3135727c1516908e89130ea5801 | [
"MIT"
] | 1 | 2021-03-12T07:27:05.000Z | 2021-03-12T07:27:05.000Z | defmodule Examples.UniswapV2.Events.Sync do
defstruct ~w[reserve0 reserve1]a
end
| 20.75 | 43 | 0.819277 |
ff2b818dbeaae963302d918e2e2b9ecc09312809 | 584 | exs | Elixir | mix.exs | sorentwo/euler | 76244a0ef3dcfa17d6b9571daa5d0b46f09057f4 | [
"MIT"
] | 8 | 2015-11-04T05:03:05.000Z | 2022-01-25T19:34:46.000Z | mix.exs | sorentwo/euler | 76244a0ef3dcfa17d6b9571daa5d0b46f09057f4 | [
"MIT"
] | null | null | null | mix.exs | sorentwo/euler | 76244a0ef3dcfa17d6b9571daa5d0b46f09057f4 | [
"MIT"
] | null | null | null | defmodule Euler.Mixfile do
use Mix.Project
def project do
[app: :euler,
version: "0.0.1",
elixir: "~> 1.0",
deps: deps]
end
# Configuration for the OTP application
#
# Type `mix help compile.app` for more information
def application do
[applications: [: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
[]
end
end
| 18.83871 | 77 | 0.604452 |
ff2b95c3c114edaa08224b6934cec216f6fcad7b | 453 | ex | Elixir | lib/mix/tasks/phx_up.gen.p.ex | adolfont/phoenix_up | 97b9ba4c0a0696d9197a0466adfd71433353cc1f | [
"MIT"
] | 27 | 2020-02-22T21:15:33.000Z | 2021-12-25T07:31:14.000Z | lib/mix/tasks/phx_up.gen.p.ex | adolfont/phoenix_up | 97b9ba4c0a0696d9197a0466adfd71433353cc1f | [
"MIT"
] | 1 | 2020-03-07T12:14:12.000Z | 2020-03-07T12:14:12.000Z | lib/mix/tasks/phx_up.gen.p.ex | adolfont/phoenix_up | 97b9ba4c0a0696d9197a0466adfd71433353cc1f | [
"MIT"
] | 2 | 2020-03-03T13:09:08.000Z | 2020-07-24T05:07:45.000Z | defmodule Mix.Tasks.PhxUp.Gen.P do
@shortdoc false
@moduledoc false
use Mix.Task
@doc false
def run(io_puts \\ true, args) do
if io_puts == true do
IO.puts("""
_ __ __ _____
___| |_ _ _ | | | _ |
| . | |_'_| | | | __|
| _|_|_|_,_|_____|_____|__|
|_| |_____| .gen.plug
""")
end
Mix.Tasks.PhxUp.Gen.Plug.run(false, args)
end
end
| 20.590909 | 46 | 0.461369 |
ff2b9f0c19d23e90cdd5f925fc318ec351eaafb1 | 1,001 | exs | Elixir | lib/perspective/event_chain/current_page/tests/current_page_test.exs | backmath/perspective | a0a577d0ffb06805b64e4dcb171a093e051884b0 | [
"MIT"
] | 2 | 2020-04-24T19:43:06.000Z | 2020-04-24T19:52:27.000Z | lib/perspective/event_chain/current_page/tests/current_page_test.exs | backmath/perspective | a0a577d0ffb06805b64e4dcb171a093e051884b0 | [
"MIT"
] | null | null | null | lib/perspective/event_chain/current_page/tests/current_page_test.exs | backmath/perspective | a0a577d0ffb06805b64e4dcb171a093e051884b0 | [
"MIT"
] | null | null | null | defmodule Perspective.EventChain.CurrentPage.Test do
use ExUnit.Case, async: true
use Perspective.BootAppPerTest
test "initial load returns a empty events" do
assert %Perspective.EventChain.CurrentPage.State{events: events} = Perspective.EventChain.CurrentPage.get()
assert events == []
end
test "writing an event" do
setup_basic_state()
Perspective.EventChain.CurrentPage.call(:name)
|> GenServer.whereis()
|> Process.exit(:early_quit)
events =
Perspective.TestSupport.call_repeatedly(fn ->
case Perspective.EventChain.CurrentPage.get() do
%{events: []} -> raise "miss"
%{events: events} -> events
end
end)
assert events == %{"some" => "event"}
end
defp setup_basic_state do
path =
Perspective.EventChain.PageManifest.current_page()
|> Perspective.StorageConfig.path()
%{some: :event}
|> Perspective.Serialize.to_json()
|> Perspective.SaveLocalFile.save(path)
end
end
| 25.666667 | 111 | 0.674326 |
ff2bcbbaf0021051bb38fe17bd5ac6cf84821886 | 1,417 | exs | Elixir | apps/etv_web/config/dev.exs | sheharyarn/etv | 65b96e436d5fe6fa11bfb293fa676f0bbf2d5121 | [
"MIT"
] | 2 | 2020-01-13T09:34:04.000Z | 2021-05-19T07:51:07.000Z | apps/etv_web/config/dev.exs | sheharyarn/etv | 65b96e436d5fe6fa11bfb293fa676f0bbf2d5121 | [
"MIT"
] | null | null | null | apps/etv_web/config/dev.exs | sheharyarn/etv | 65b96e436d5fe6fa11bfb293fa676f0bbf2d5121 | [
"MIT"
] | 2 | 2018-09-01T20:58:11.000Z | 2021-05-19T07:51:11.000Z | use Mix.Config
# For development, we disable any cache and enable
# debugging and code reloading.
#
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with brunch.io to recompile .js and .css sources.
config :etv_web, ETV.Web.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin",
cd: Path.expand("../assets", __DIR__)]]
# ## SSL Support
#
# In order to use HTTPS in development, a self-signed
# certificate can be generated by running the following
# command from your terminal:
#
# openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout priv/server.key -out priv/server.pem
#
# The `http:` config above can be replaced with:
#
# https: [port: 4000, keyfile: "priv/server.key", certfile: "priv/server.pem"],
#
# If desired, both `http:` and `https:` keys can be
# configured to run both http and https servers on
# different ports.
# Watch static and templates for browser reloading.
config :etv_web, ETV.Web.Endpoint,
live_reload: [
patterns: [
~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
~r{priv/gettext/.*(po)$},
~r{lib/etv_web/views/.*(ex)$},
~r{lib/etv_web/templates/.*(eex)$}
]
]
| 31.488889 | 170 | 0.678193 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.