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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ff82da4b2168f715956eb2984f50d86946000917 | 2,309 | ex | Elixir | lib/xema/utils.ex | hrzndhrn/xema | c53ec35f2554a5d465171cf9fab0906fd14c4789 | [
"MIT"
] | 49 | 2018-06-05T09:42:19.000Z | 2022-02-15T12:50:51.000Z | lib/xema/utils.ex | hrzndhrn/xema | c53ec35f2554a5d465171cf9fab0906fd14c4789 | [
"MIT"
] | 152 | 2017-06-11T13:43:06.000Z | 2022-01-09T17:13:45.000Z | lib/xema/utils.ex | hrzndhrn/xema | c53ec35f2554a5d465171cf9fab0906fd14c4789 | [
"MIT"
] | 6 | 2019-05-31T05:41:47.000Z | 2021-12-14T08:09:36.000Z | defmodule Xema.Utils do
@moduledoc """
Some utilities for Xema.
"""
@doc """
Converts the given `string` to an existing atom. Returns `nil` if the
atom does not exist.
## Examples
iex> import Xema.Utils
iex> to_existing_atom(:my_atom)
:my_atom
iex> to_existing_atom("my_atom")
:my_atom
iex> to_existing_atom("not_existing_atom")
nil
"""
@spec to_existing_atom(String.t() | atom) :: atom | nil
def to_existing_atom(atom) when is_atom(atom), do: atom
def to_existing_atom(string) when is_binary(string) do
String.to_existing_atom(string)
rescue
_ -> nil
end
@doc """
Returns whether the given `key` exists in the given `value`.
Returns true if
* `value` is a map and contains `key` as a key.
* `value` is a keyword and contains `key` as a key.
* `value` is a list of tuples with `key`as the first element.
## Example
iex> alias Xema.Utils
iex> Utils.has_key?(%{foo: 5}, :foo)
true
iex> Utils.has_key?([foo: 5], :foo)
true
iex> Utils.has_key?([{"foo", 5}], "foo")
true
iex> Utils.has_key?([{"foo", 5}], "bar")
false
iex> Utils.has_key?([], "bar")
false
"""
@spec has_key?(map | keyword | [{String.t(), any}], any) :: boolean
def has_key?([], _), do: false
def has_key?(value, key) when is_map(value), do: Map.has_key?(value, key)
def has_key?(value, key) when is_list(value) do
case Keyword.keyword?(value) do
true -> Keyword.has_key?(value, key)
false -> Enum.any?(value, fn {k, _} -> k == key end)
end
end
@doc """
Returns `nil` if `uri_1` and `uri_2` are `nil`.
Parses a URI when the other URI is `nil`.
Merges URIs if both are not nil.
"""
@spec update_uri(URI.t() | String.t() | nil, URI.t() | String.t() | nil) ::
URI.t() | nil
def update_uri(nil, nil), do: nil
def update_uri(uri_1, nil), do: URI.parse(uri_1)
def update_uri(nil, uri_2), do: URI.parse(uri_2)
def update_uri(uri_1, uri_2), do: URI.merge(uri_1, uri_2)
@doc """
Returns the size of a `list` or `tuple`.
"""
@spec size(list | tuple) :: integer
def size(list) when is_list(list), do: length(list)
def size(tuple) when is_tuple(tuple), do: tuple_size(tuple)
end
| 26.848837 | 77 | 0.605024 |
ff82fa99396c30489a4c655297db85cdc2034950 | 351 | ex | Elixir | lib/firestorm_web/web/session.ex | IsaacRoss/dripforum | 2b943df8e3b1b75d9e297a4fad865db4d9e8e230 | [
"MIT"
] | null | null | null | lib/firestorm_web/web/session.ex | IsaacRoss/dripforum | 2b943df8e3b1b75d9e297a4fad865db4d9e8e230 | [
"MIT"
] | null | null | null | lib/firestorm_web/web/session.ex | IsaacRoss/dripforum | 2b943df8e3b1b75d9e297a4fad865db4d9e8e230 | [
"MIT"
] | null | null | null | defmodule FirestormWeb.Web.Session do
@moduledoc """
Some helpers for session-related things
"""
alias FirestormWeb.Forums
def current_user(conn) do
case Plug.Conn.get_session(conn, :current_user) do
nil ->
nil
id ->
Forums.get_user!(id)
end
end
def logged_in?(conn), do: !!current_user(conn)
end
| 17.55 | 54 | 0.649573 |
ff8309a59d936c7358ce024095d2c077f20f37ce | 5,995 | exs | Elixir | test/payload_test.exs | rstawarz/kronky | 23d869868386576b688c144b3773e6145a8d276f | [
"MIT"
] | null | null | null | test/payload_test.exs | rstawarz/kronky | 23d869868386576b688c144b3773e6145a8d276f | [
"MIT"
] | null | null | null | test/payload_test.exs | rstawarz/kronky | 23d869868386576b688c144b3773e6145a8d276f | [
"MIT"
] | null | null | null | defmodule Kronky.PayloadTest do
@moduledoc """
Test conversion of changeset errors to ValidationMessage structs
"""
use ExUnit.Case
import Ecto.Changeset
alias Kronky.ValidationMessage
alias Kronky.Payload
alias Absinthe.Resolution
import Kronky.Payload
def resolution(value) do
%Resolution{
value: value,
adapter: "", context: "", root_value: "", schema: "", source: ""
}
end
defp resolution_error(error) do
%Resolution{
errors: error,
adapter: "", context: "", root_value: "", schema: "", source: ""
}
end
def payload(successful, messages \\ [], result \\ nil) do
%Payload{
successful: successful,
messages: messages,
result: result
}
end
def assert_error_payload(messages, result) do
assert %{value: value} = result
expected = payload(false, messages)
assert expected.successful == value.successful
assert expected.result == value.result
for message <- messages do
message = convert_field_name(message)
assert Enum.find_value(value.messages, &(message == &1)),
"Expected to find \n#{inspect(message)}\n in \n#{inspect(value.messages)}"
end
end
describe "build_payload/2" do
test "validation message tuple" do
message = %ValidationMessage{code: :required}
resolution = resolution(message)
result = build_payload(resolution, nil)
assert_error_payload([message], result)
end
test "error, validation message tuple" do
message = %ValidationMessage{code: :required}
resolution = resolution({:error, message})
result = build_payload(resolution, nil)
assert_error_payload([message], result)
end
test "error, string message tuple" do
resolution = resolution({:error, "an error"})
result = build_payload(resolution, nil)
message = %ValidationMessage{code: :unknown, message: "an error", template: "an error"}
assert_error_payload([message], result)
end
test "error list" do
messages = [%ValidationMessage{code: :required}, %ValidationMessage{code: :max}]
resolution = resolution({:error, messages})
result = build_payload(resolution, nil)
assert %{value: value} = result
expected = payload(false, messages)
assert expected == value
end
test "invalid changeset" do
changeset = {%{}, %{title: :string, title_lang: :string}}
|> Ecto.Changeset.cast(%{}, [:title, :title_lang])
|> add_error(:title, "error 1")
|> add_error(:title, "error 2")
|> add_error(:title_lang, "error 3")
resolution = resolution(changeset)
result = build_payload(resolution, nil)
messages = [
%ValidationMessage{code: :unknown, message: "error 1", template: "error 1", field: :title, key: :title},
%ValidationMessage{code: :unknown, message: "error 2", template: "error 2", field: :title, key: :title},
%ValidationMessage{code: :unknown, message: "error 3", template: "error 3", field: :titleLang, key: :titleLang},
]
assert_error_payload(messages, result)
end
test "error, invalid changeset" do
changeset = {%{}, %{title: :string, title_lang: :string}}
|> Ecto.Changeset.cast(%{}, [:title, :title_lang])
|> add_error(:title, "error 1")
|> add_error(:title, "error 2")
|> add_error(:title_lang, "error 3")
resolution = resolution_error(changeset)
result = build_payload(resolution, nil)
messages = [
%ValidationMessage{code: :unknown, message: "error 1", template: "error 1", field: :title, key: :title},
%ValidationMessage{code: :unknown, message: "error 2", template: "error 2", field: :title, key: :title},
%ValidationMessage{code: :unknown, message: "error 3", template: "error 3", field: :titleLang, key: :titleLang},
]
assert_error_payload(messages, result)
end
test "valid changeset" do
changeset = {%{}, %{title: :string, body: :string}}
|> Ecto.Changeset.cast(%{}, [:title, :body])
resolution = resolution(changeset)
result = build_payload(resolution, nil)
assert %{value: value} = result
assert value.successful == true
assert value.messages == []
assert value.result == changeset
end
test "map" do
map = %{something: "something"}
resolution = resolution(map)
result = build_payload(resolution, nil)
assert %{value: value} = result
assert value.successful == true
assert value.messages == []
assert value.result == map
end
test "error from resolution, validation message" do
message = %ValidationMessage{code: :required}
resolution = resolution_error([message])
result = build_payload(resolution, nil)
assert_error_payload([message], result)
end
test "error from resolution, string message" do
resolution = resolution_error(["an error"])
result = build_payload(resolution, nil)
message = %ValidationMessage{code: :unknown, message: "an error", template: "an error"}
assert_error_payload([message], result)
end
test "error from resolution, string message list" do
resolution = resolution_error(["an error", "another error"])
result = build_payload(resolution, nil)
messages = [
%ValidationMessage{code: :unknown, message: "an error", template: "an error"},
%ValidationMessage{code: :unknown, message: "another error", template: "another error"}
]
assert_error_payload(messages, result)
end
test "error from resolution, error list" do
messages = [%ValidationMessage{code: :required}, %ValidationMessage{code: :max}]
resolution = resolution_error(messages)
result = build_payload(resolution, nil)
assert result
assert result.value
assert_error_payload(messages, result)
end
end
end
| 30.902062 | 120 | 0.640867 |
ff83121c40ca796f353df91e4fe3da4e7bab9c52 | 1,143 | exs | Elixir | config/config.exs | muziyoshiz/admiral_stats_parser_ex | 89b1cf470b4ba823ed8902e415e798180023c156 | [
"MIT"
] | null | null | null | config/config.exs | muziyoshiz/admiral_stats_parser_ex | 89b1cf470b4ba823ed8902e415e798180023c156 | [
"MIT"
] | null | null | null | config/config.exs | muziyoshiz/admiral_stats_parser_ex | 89b1cf470b4ba823ed8902e415e798180023c156 | [
"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 :admiral_stats_parser, key: :value
#
# And access this configuration in your application as:
#
# Application.get_env(:admiral_stats_parser, :key)
#
# Or configure a 3rd-party app:
#
# config :logger, level: :info
#
# It is also possible to import configuration files, relative to this
# directory. For example, you can emulate configuration per environment
# by uncommenting the line below and defining dev.exs, test.exs and such.
# Configuration from the imported file will override the ones defined
# here (which is why it is important to import them last).
#
# import_config "#{Mix.env}.exs"
| 36.870968 | 73 | 0.75678 |
ff832c106c63c0a17644f58437a0ff09d58d63a4 | 243 | exs | Elixir | test/repo/user_test.exs | elpassion/sprint-poker | 5c9b34bb264c7a30ff48f0aeac40821b67310ff8 | [
"MIT"
] | 199 | 2015-10-22T16:20:09.000Z | 2021-11-08T11:20:45.000Z | test/repo/user_test.exs | elpassion/sprint-poker | 5c9b34bb264c7a30ff48f0aeac40821b67310ff8 | [
"MIT"
] | 4 | 2015-10-24T20:43:29.000Z | 2016-03-03T21:09:06.000Z | test/repo/user_test.exs | elpassion/sprint-poker | 5c9b34bb264c7a30ff48f0aeac40821b67310ff8 | [
"MIT"
] | 34 | 2015-10-23T06:38:43.000Z | 2019-08-13T23:49:24.000Z | defmodule SprintPoker.UserTest do
use SprintPoker.DataCase
alias SprintPoker.Repo
alias SprintPoker.Repo.User
test "creating empty user generate auth_token" do
user = %User{} |> Repo.insert!
assert user.auth_token
end
end
| 18.692308 | 51 | 0.744856 |
ff83529b163ae0b92768344de7ef3e851011ed69 | 2,030 | ex | Elixir | lib/excoveralls/circle.ex | brauliobz/excoveralls | 8108405bda1c6ef27253edc294415f02d78760f4 | [
"MIT"
] | null | null | null | lib/excoveralls/circle.ex | brauliobz/excoveralls | 8108405bda1c6ef27253edc294415f02d78760f4 | [
"MIT"
] | null | null | null | lib/excoveralls/circle.ex | brauliobz/excoveralls | 8108405bda1c6ef27253edc294415f02d78760f4 | [
"MIT"
] | 2 | 2019-03-15T08:12:53.000Z | 2019-06-11T11:34:04.000Z | defmodule ExCoveralls.Circle do
@moduledoc """
Handles circle-ci integration with coveralls.
"""
alias ExCoveralls.Poster
def execute(stats, options) do
json = generate_json(stats, Enum.into(options, %{}))
if options[:verbose] do
IO.puts json
end
Poster.execute(json)
end
def generate_json(stats, options \\ %{})
def generate_json(stats, options) do
Jason.encode!(%{
repo_token: get_repo_token(),
service_name: "circle-ci",
service_number: get_number(),
service_job_id: get_job_id(),
service_pull_request: get_pull_request(),
source_files: stats,
git: generate_git_info(),
parallel: options[:parallel]
})
end
defp generate_git_info do
%{head: %{
committer_name: get_committer(),
message: get_message!(),
id: get_sha()
},
branch: get_branch()
}
end
defp get_pull_request do
case Regex.run(~r/(\d+)$/, System.get_env("CI_PULL_REQUEST") || "") do
[_, id] -> id
_ -> nil
end
end
defp get_message! do
case System.cmd("git", ["log", "-1", "--pretty=format:%s"]) do
{message, _} -> message
_ -> "[no commit message]"
end
end
defp get_committer do
System.get_env("CIRCLE_USERNAME")
end
defp get_sha do
System.get_env("CIRCLE_SHA1")
end
defp get_branch do
System.get_env("CIRCLE_BRANCH")
end
defp get_job_id do
# When using workflows, each job has a separate `CIRCLE_BUILD_NUM`, so this needs to be used as the Job ID and not
# the Job Number.
System.get_env("CIRCLE_BUILD_NUM")
end
defp get_number do
# `CIRCLE_WORKFLOW_WORKSPACE_ID` is the same when "Rerun failed job" is done while `CIRCLE_WORKFLOW_ID` changes, so
# use `CIRCLE_WORKFLOW_WORKSPACE_ID` so that the results from the original and rerun are combined
System.get_env("CIRCLE_WORKFLOW_WORKSPACE_ID") || System.get_env("CIRCLE_BUILD_NUM")
end
defp get_repo_token do
System.get_env("COVERALLS_REPO_TOKEN")
end
end
| 25.061728 | 119 | 0.662562 |
ff835e6a6a60e1b37ecab3f419d5b8b2f0ab9b22 | 5,864 | exs | Elixir | test/elixir/test/reader_acl_test.exs | frapa/couchdb | 6c28960f0fe2eec06aca7d58fd73f3c7cdbe1112 | [
"Apache-2.0"
] | 1 | 2022-01-14T20:52:55.000Z | 2022-01-14T20:52:55.000Z | test/elixir/test/reader_acl_test.exs | frapa/couchdb | 6c28960f0fe2eec06aca7d58fd73f3c7cdbe1112 | [
"Apache-2.0"
] | null | null | null | test/elixir/test/reader_acl_test.exs | frapa/couchdb | 6c28960f0fe2eec06aca7d58fd73f3c7cdbe1112 | [
"Apache-2.0"
] | null | null | null | defmodule ReaderACLTest do
use CouchTestCase
@moduletag :authentication
@moduletag kind: :single_node
@users_db_name "custom-users"
@password "funnybone"
@moduletag config: [
{
"chttpd_auth",
"authentication_db",
@users_db_name
},
{
"couch_httpd_auth",
"authentication_db",
@users_db_name
}
]
setup do
# Create db if not exists
Couch.put("/#{@users_db_name}")
# create a user with top-secret-clearance
user_doc =
prepare_user_doc([
{:name, "bond@apache.org"},
{:password, @password},
{:roles, ["top-secret"]}
])
{:ok, _} = create_doc(@users_db_name, user_doc)
# create a user with top-secret-clearance
user_doc =
prepare_user_doc([
{:name, "juanjo@apache.org"},
{:password, @password}
])
{:ok, _} = create_doc(@users_db_name, user_doc)
on_exit(&tear_down/0)
:ok
end
defp tear_down do
delete_db(@users_db_name)
end
defp login(user, password) do
sess = Couch.login(user, password)
assert sess.cookie, "Login correct is expected"
sess
end
defp logout(session) do
assert Couch.Session.logout(session).body["ok"]
end
defp open_as(db_name, doc_id, options) do
use_session = Keyword.get(options, :use_session)
user = Keyword.get(options, :user)
expect_response = Keyword.get(options, :expect_response, 200)
expect_message = Keyword.get(options, :error_message)
session = use_session || login(user, @password)
resp =
Couch.Session.get(
session,
"/#{db_name}/#{URI.encode(doc_id)}"
)
if use_session == nil do
logout(session)
end
assert resp.status_code == expect_response
if expect_message != nil do
assert resp.body["error"] == expect_message
end
resp.body
end
defp set_security(db_name, security, expect_response \\ 200) do
resp = Couch.put("/#{db_name}/_security", body: security)
assert resp.status_code == expect_response
end
@tag :pending # Timeout
@tag :with_db
test "unrestricted db can be read", context do
db_name = context[:db_name]
doc = %{_id: "baz", foo: "bar"}
{:ok, _} = create_doc(db_name, doc)
# any user can read unrestricted db
open_as(db_name, "baz", user: "juanjo@apache.org")
open_as(db_name, "baz", user: "bond@apache.org")
end
@tag :pending # HTTP 404 in on_exit
@tag :with_db
test "restricted db can be read by authorized users", context do
db_name = context[:db_name]
doc = %{_id: "baz", foo: "bar"}
{:ok, _} = create_doc(db_name, doc)
security = %{
members: %{
roles: ["super-secret-club"],
names: ["joe", "barb"]
}
}
set_security(db_name, security)
# can't read it as bond is missing the needed role
open_as(db_name, "baz", user: "bond@apache.org", expect_response: 403)
# make anyone with the top-secret role an admin
# db admins are automatically members
security = %{
admins: %{
roles: ["top-secret"],
names: []
},
members: %{
roles: ["super-secret-club"],
names: ["joe", "barb"]
}
}
set_security(db_name, security)
# db admin can read
open_as(db_name, "baz", user: "bond@apache.org")
# admin now adds the top-secret role to the db's members
# and removes db-admins
security = %{
admins: %{
roles: [],
names: []
},
members: %{
roles: ["super-secret-club", "top-secret"],
names: ["joe", "barb"]
}
}
set_security(db_name, security)
# server _admin can always read
resp = Couch.get("/#{db_name}/baz")
assert resp.status_code == 200
open_as(db_name, "baz", user: "bond@apache.org")
end
@tag :pending # Timeout
@tag :with_db
test "works with readers (backwards compat with 1.0)", context do
db_name = context[:db_name]
doc = %{_id: "baz", foo: "bar"}
{:ok, _} = create_doc(db_name, doc)
security = %{
admins: %{
roles: [],
names: []
},
readers: %{
roles: ["super-secret-club", "top-secret"],
names: ["joe", "barb"]
}
}
set_security(db_name, security)
open_as(db_name, "baz", user: "bond@apache.org")
end
@tag :pending # Timeout
@tag :with_db
test "can't set non string reader names or roles", context do
db_name = context[:db_name]
security = %{
members: %{
roles: ["super-secret-club", %{"top-secret": "awesome"}],
names: ["joe", "barb"]
}
}
set_security(db_name, security, 500)
security = %{
members: %{
roles: ["super-secret-club", "top-secret"],
names: ["joe", 22]
}
}
set_security(db_name, security, 500)
security = %{
members: %{
roles: ["super-secret-club", "top-secret"],
names: "joe"
}
}
set_security(db_name, security, 500)
end
@tag :pending # Timeout
@tag :with_db
test "members can query views", context do
db_name = context[:db_name]
doc = %{_id: "baz", foo: "bar"}
{:ok, _} = create_doc(db_name, doc)
security = %{
admins: %{
roles: [],
names: []
},
members: %{
roles: ["super-secret-club", "top-secret"],
names: ["joe", "barb"]
}
}
set_security(db_name, security)
view = %{
_id: "_design/foo",
views: %{
bar: %{
map: "function(doc){emit(null, null)}"
}
}
}
{:ok, _} = create_doc(db_name, view)
# members can query views
open_as(db_name, "_design/foo/_view/bar", user: "bond@apache.org")
end
end
| 22.467433 | 74 | 0.564632 |
ff8379ce02f91900ee348ce339b68d11ce13978f | 100 | ex | Elixir | lib/gatekeeper/response.ex | samfrench/gatekeeper | 6286ed16360e0d538e7f4c802a866b2cd83d5514 | [
"MIT"
] | null | null | null | lib/gatekeeper/response.ex | samfrench/gatekeeper | 6286ed16360e0d538e7f4c802a866b2cd83d5514 | [
"MIT"
] | null | null | null | lib/gatekeeper/response.ex | samfrench/gatekeeper | 6286ed16360e0d538e7f4c802a866b2cd83d5514 | [
"MIT"
] | null | null | null | defmodule Gatekeeper.Response do
defstruct [
:status_code,
:body,
headers: []
]
end
| 12.5 | 32 | 0.63 |
ff838194da546b901bb256470580c45a62b58086 | 798 | ex | Elixir | apps/buzzcms/test/support/factory.ex | buzzcms/buzzcms | 8ca8e6dea381350f94cc4a666448b5dba6676520 | [
"Apache-2.0"
] | null | null | null | apps/buzzcms/test/support/factory.ex | buzzcms/buzzcms | 8ca8e6dea381350f94cc4a666448b5dba6676520 | [
"Apache-2.0"
] | 41 | 2020-02-12T07:53:14.000Z | 2020-03-30T02:18:14.000Z | apps/buzzcms/test/support/factory.ex | buzzcms/buzzcms | 8ca8e6dea381350f94cc4a666448b5dba6676520 | [
"Apache-2.0"
] | null | null | null | defmodule Buzzcms.Factory do
use ExMachina.Ecto, repo: Buzzcms.Repo
use Buzzcms.UserFactory
alias Buzzcms.Schema.{
Entry,
EntryType,
Taxon,
Taxonomy
}
def entry_factory do
title = sequence(:title, &"Title #{&1}")
slug = sequence(:slug, &"title-#{&1}")
%Entry{
title: title,
slug: slug
}
end
def entry_type_factory do
%EntryType{}
end
def taxonomy_factory do
%Taxonomy{code: "category", display_name: "Category"}
end
def taxon_factory do
title = sequence(:title, &"Taxon #{&1}")
slug = sequence(:slug, &"taxon-#{&1}")
%Taxon{
title: title,
slug: slug
}
end
def email_sender_factory do
%Buzzcms.Schema.EmailSender{
name: "Sender",
email: "hi@buzzcms.co"
}
end
end
| 16.978723 | 57 | 0.60401 |
ff83be1fd06a21eade357e59176d99eb8a19ade9 | 2,598 | ex | Elixir | clients/storage/lib/google_api/storage/v1/model/test_iam_permissions_response.ex | medikent/elixir-google-api | 98a83d4f7bfaeac15b67b04548711bb7e49f9490 | [
"Apache-2.0"
] | null | null | null | clients/storage/lib/google_api/storage/v1/model/test_iam_permissions_response.ex | medikent/elixir-google-api | 98a83d4f7bfaeac15b67b04548711bb7e49f9490 | [
"Apache-2.0"
] | 1 | 2020-12-18T09:25:12.000Z | 2020-12-18T09:25:12.000Z | clients/storage/lib/google_api/storage/v1/model/test_iam_permissions_response.ex | medikent/elixir-google-api | 98a83d4f7bfaeac15b67b04548711bb7e49f9490 | [
"Apache-2.0"
] | 1 | 2020-10-04T10:12:44.000Z | 2020-10-04T10:12:44.000Z | # Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.
defmodule GoogleApi.Storage.V1.Model.TestIamPermissionsResponse do
@moduledoc """
A storage.(buckets|objects).testIamPermissions response.
## Attributes
* `kind` (*type:* `String.t`, *default:* `storage#testIamPermissionsResponse`) - The kind of item this is.
* `permissions` (*type:* `list(String.t)`, *default:* `nil`) - The permissions held by the caller. Permissions are always of the format storage.resource.capability, where resource is one of buckets or objects. The supported permissions are as follows:
- storage.buckets.delete — Delete bucket.
- storage.buckets.get — Read bucket metadata.
- storage.buckets.getIamPolicy — Read bucket IAM policy.
- storage.buckets.create — Create bucket.
- storage.buckets.list — List buckets.
- storage.buckets.setIamPolicy — Update bucket IAM policy.
- storage.buckets.update — Update bucket metadata.
- storage.objects.delete — Delete object.
- storage.objects.get — Read object data and metadata.
- storage.objects.getIamPolicy — Read object IAM policy.
- storage.objects.create — Create object.
- storage.objects.list — List objects.
- storage.objects.setIamPolicy — Update object IAM policy.
- storage.objects.update — Update object metadata.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:kind => String.t(),
:permissions => list(String.t())
}
field(:kind)
field(:permissions, type: :list)
end
defimpl Poison.Decoder, for: GoogleApi.Storage.V1.Model.TestIamPermissionsResponse do
def decode(value, options) do
GoogleApi.Storage.V1.Model.TestIamPermissionsResponse.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.Storage.V1.Model.TestIamPermissionsResponse do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 40.59375 | 257 | 0.71632 |
ff8407917e60b2c60932ff4aebdf46d89279292c | 1,886 | ex | Elixir | clients/blogger/lib/google_api/blogger/v3/model/page_author.ex | pojiro/elixir-google-api | 928496a017d3875a1929c6809d9221d79404b910 | [
"Apache-2.0"
] | 1 | 2021-12-20T03:40:53.000Z | 2021-12-20T03:40:53.000Z | clients/blogger/lib/google_api/blogger/v3/model/page_author.ex | pojiro/elixir-google-api | 928496a017d3875a1929c6809d9221d79404b910 | [
"Apache-2.0"
] | 1 | 2020-08-18T00:11:23.000Z | 2020-08-18T00:44:16.000Z | clients/blogger/lib/google_api/blogger/v3/model/page_author.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.Blogger.V3.Model.PageAuthor do
@moduledoc """
The author of this Page.
## Attributes
* `displayName` (*type:* `String.t`, *default:* `nil`) - The display name.
* `id` (*type:* `String.t`, *default:* `nil`) - The identifier of the creator.
* `image` (*type:* `GoogleApi.Blogger.V3.Model.PageAuthorImage.t`, *default:* `nil`) - The creator's avatar.
* `url` (*type:* `String.t`, *default:* `nil`) - The URL of the creator's Profile page.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:displayName => String.t() | nil,
:id => String.t() | nil,
:image => GoogleApi.Blogger.V3.Model.PageAuthorImage.t() | nil,
:url => String.t() | nil
}
field(:displayName)
field(:id)
field(:image, as: GoogleApi.Blogger.V3.Model.PageAuthorImage)
field(:url)
end
defimpl Poison.Decoder, for: GoogleApi.Blogger.V3.Model.PageAuthor do
def decode(value, options) do
GoogleApi.Blogger.V3.Model.PageAuthor.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.Blogger.V3.Model.PageAuthor do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 33.678571 | 112 | 0.692471 |
ff840ca3ffe8b6cda30fea6df133e5aa81055d20 | 661,101 | ex | Elixir | clients/apigee/lib/google_api/apigee/v1/api/organizations.ex | mcrumm/elixir-google-api | 544f22797cec52b3a23dfb6e39117f0018448610 | [
"Apache-2.0"
] | null | null | null | clients/apigee/lib/google_api/apigee/v1/api/organizations.ex | mcrumm/elixir-google-api | 544f22797cec52b3a23dfb6e39117f0018448610 | [
"Apache-2.0"
] | null | null | null | clients/apigee/lib/google_api/apigee/v1/api/organizations.ex | mcrumm/elixir-google-api | 544f22797cec52b3a23dfb6e39117f0018448610 | [
"Apache-2.0"
] | null | null | null | # Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.
defmodule GoogleApi.Apigee.V1.Api.Organizations do
@moduledoc """
API calls for all endpoints tagged `Organizations`.
"""
alias GoogleApi.Apigee.V1.Connection
alias GoogleApi.Gax.{Request, Response}
@library_version Mix.Project.config() |> Keyword.get(:version, "")
@doc """
Creates an Apigee organization. See [Create an Apigee organization](https://cloud.google.com/apigee/docs/api-platform/get-started/create-org).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.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").
* `:parent` (*type:* `String.t`) - Required. Name of the GCP project in which to associate the Apigee organization. Pass the information as a query parameter using the following structure in your request: `projects/`
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Organization.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_create(Tesla.Env.client(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_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,
:parent => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/organizations", %{})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Delete an Apigee organization. Only supported for SubscriptionType TRIAL.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the organization. Use the following structure in your request: `organizations/{org}`
* `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.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_delete(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_delete(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Gets the profile for an Apigee organization. See [Understanding organizations](https://cloud.google.com/apigee/docs/api-platform/fundamentals/organization-structure).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Apigee organization name in the following format: `organizations/{org}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Organization{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Organization.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Organization{}]
)
end
@doc """
Gets the deployed ingress configuration for an organization.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the deployed configuration for the organization in the following format: 'organizations/{org}/deployedIngressConfig'.
* `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`) - When set to FULL, additional details about the specific deployments receiving traffic will be included in the IngressConfig response's RoutingRules.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1IngressConfig{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_get_deployed_ingress_config(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1IngressConfig.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_get_deployed_ingress_config(
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,
:view => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1IngressConfig{}]
)
end
@doc """
Lists the service accounts with the permissions required to allow the Synchronizer to download environment data from the control plane. An ETag is returned in the response to `getSyncAuthorization`. Pass that ETag when calling [setSyncAuthorization](setSyncAuthorization) to ensure that you are updating the correct version. If you don't pass the ETag in the call to `setSyncAuthorization`, then the existing authorization is overwritten indiscriminately. For more information, see [Configure the Synchronizer](https://cloud.google.com/apigee/docs/hybrid/latest/synchronizer-access). **Note**: Available to Apigee hybrid only.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the Apigee organization. Use the following structure in your request: `organizations/{org}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1GetSyncAuthorizationRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SyncAuthorization{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_get_sync_authorization(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SyncAuthorization.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_get_sync_authorization(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}:getSyncAuthorization", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1SyncAuthorization{}]
)
end
@doc """
Lists the Apigee organizations and associated GCP projects that you have permission to access. See [Understanding organizations](https://cloud.google.com/apigee/docs/api-platform/fundamentals/organization-structure).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Use the following structure in your request: `organizations`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ListOrganizationsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_list(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListOrganizationsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_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("/v1/{+parent}", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListOrganizationsResponse{}]
)
end
@doc """
Sets the permissions required to allow the Synchronizer to download environment data from the control plane. You must call this API to enable proper functioning of hybrid. Pass the ETag when calling `setSyncAuthorization` to ensure that you are updating the correct version. To get an ETag, call [getSyncAuthorization](getSyncAuthorization). If you don't pass the ETag in the call to `setSyncAuthorization`, then the existing authorization is overwritten indiscriminately. For more information, see [Configure the Synchronizer](https://cloud.google.com/apigee/docs/hybrid/latest/synchronizer-access). **Note**: Available to Apigee hybrid only.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the Apigee organization. Use the following structure in your request: `organizations/{org}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1SyncAuthorization.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SyncAuthorization{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_set_sync_authorization(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SyncAuthorization.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_set_sync_authorization(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}:setSyncAuthorization", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1SyncAuthorization{}]
)
end
@doc """
Updates the properties for an Apigee organization. No other fields in the organization profile will be updated.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Apigee organization name in the following format: `organizations/{org}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Organization.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Organization{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_update(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Organization.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_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/{+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.Apigee.V1.Model.GoogleCloudApigeeV1Organization{}]
)
end
@doc """
Create a Datastore for an org
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The parent organization name. Must be of the form `organizations/{org}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Datastore.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Datastore{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_analytics_datastores_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Datastore.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_analytics_datastores_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/analytics/datastores", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Datastore{}]
)
end
@doc """
Delete a Datastore from an org.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Resource name of the Datastore to be deleted. Must be of the form `organizations/{org}/analytics/datastores/{datastoreId}`
* `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.Apigee.V1.Model.GoogleProtobufEmpty{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_analytics_datastores_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_analytics_datastores_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty{}])
end
@doc """
Get a Datastore
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Resource name of the Datastore to be get. Must be of the form `organizations/{org}/analytics/datastores/{datastoreId}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Datastore{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_analytics_datastores_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Datastore.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_analytics_datastores_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Datastore{}]
)
end
@doc """
List Datastores
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The parent organization name. Must be of the form `organizations/{org}`.
* `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").
* `:targetType` (*type:* `String.t`) - Optional. TargetType is used to fetch all Datastores that match the type
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDatastoresResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_analytics_datastores_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDatastoresResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_analytics_datastores_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,
:targetType => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/analytics/datastores", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListDatastoresResponse{}]
)
end
@doc """
Test if Datastore configuration is correct. This includes checking if credentials provided by customer have required permissions in target destination storage
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The parent organization name Must be of the form `organizations/{org}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Datastore.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1TestDatastoreResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_analytics_datastores_test(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1TestDatastoreResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_analytics_datastores_test(
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,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/analytics/datastores:test", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1TestDatastoreResponse{}]
)
end
@doc """
Update a Datastore
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The resource name of datastore to be updated. Must be of the form `organizations/{org}/analytics/datastores/{datastoreId}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Datastore.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Datastore{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_analytics_datastores_update(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Datastore.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_analytics_datastores_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/{+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.Apigee.V1.Model.GoogleCloudApigeeV1Datastore{}]
)
end
@doc """
Updates or creates API product attributes. This API **replaces** the current list of attributes with the attributes specified in the request body. In this way, you can update existing attributes, add new attributes, or delete existing attributes by omitting them from the request body. **Note**: OAuth access tokens and Key Management Service (KMS) entities (apps, developers, and API products) are cached for 180 seconds (current default). Any custom attributes associated with entities also get cached for at least 180 seconds after entity is accessed during runtime. In this case, the `ExpiresIn` element on the OAuthV2 policy won't be able to expire an access token in less than 180 seconds.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the API product. Use the following structure in your request: `organizations/{org}/apiproducts/{apiproduct}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attributes.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attributes{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apiproducts_attributes(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attributes.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apiproducts_attributes(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}/attributes", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Attributes{}]
)
end
@doc """
Creates an API product in an organization. You create API products after you have proxied backend services using API proxies. An API product is a collection of API resources combined with quota settings and metadata that you can use to deliver customized and productized API bundles to your developer community. This metadata can include: - Scope - Environments - API proxies - Extensible profile API products enable you repackage APIs on-the-fly, without having to do any additional coding or configuration. Apigee recommends that you start with a simple API product including only required elements. You then provision credentials to apps to enable them to start testing your APIs. After you have authentication and authorization working against a simple API product, you can iterate to create finer grained API products, defining different sets of API resources for each API product. **WARNING:** - If you don't specify an API proxy in the request body, *any* app associated with the product can make calls to *any* API in your entire organization. - If you don't specify an environment in the request body, the product allows access to all environments. For more information, see What is an API product?
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization in which the API product will be created. Use the following structure in your request: `organizations/{org}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apiproducts_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apiproducts_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/apiproducts", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct{}]
)
end
@doc """
Deletes an API product from an organization. Deleting an API product causes app requests to the resource URIs defined in the API product to fail. Ensure that you create a new API product to serve existing apps, unless your intention is to disable access to the resources defined in the API product. The API product name required in the request URL is the internal name of the product, not the display name. While they may be the same, it depends on whether the API product was created via the UI or the API. View the list of API products to verify the internal name.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the API product. Use the following structure in your request: `organizations/{org}/apiproducts/{apiproduct}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apiproducts_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apiproducts_delete(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct{}]
)
end
@doc """
Gets configuration details for an API product. The API product name required in the request URL is the internal name of the product, not the display name. While they may be the same, it depends on whether the API product was created via the UI or the API. View the list of API products to verify the internal name.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the API product. Use the following structure in your request: `organizations/{org}/apiproducts/{apiproduct}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apiproducts_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apiproducts_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct{}]
)
end
@doc """
Lists all API product names for an organization. Filter the list by passing an `attributename` and `attibutevalue`. The limit on the number of API products returned by the API is 1000. You can paginate the list of API products returned using the `startKey` and `count` query parameters.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization. Use the following structure in your request: `organizations/{org}`
* `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").
* `:attributename` (*type:* `String.t`) - Name of the attribute used to filter the search.
* `:attributevalue` (*type:* `String.t`) - Value of the attribute used to filter the search.
* `:count` (*type:* `String.t`) - Enter the number of API products you want returned in the API call. The limit is 1000.
* `:expand` (*type:* `boolean()`) - Flag that specifies whether to expand the results. Set to `true` to get expanded details about each API.
* `:startKey` (*type:* `String.t`) - Gets a list of API products starting with a specific API product in the list. For example, if you're returning 50 API products at a time (using the `count` query parameter), you can view products 50-99 by entering the name of the 50th API product in the first API (without using `startKey`). Product name is case sensitive.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListApiProductsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apiproducts_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListApiProductsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apiproducts_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,
:attributename => :query,
:attributevalue => :query,
:count => :query,
:expand => :query,
:startKey => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/apiproducts", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListApiProductsResponse{}]
)
end
@doc """
Updates an existing API product. You must include all required values, whether or not you are updating them, as well as any optional values that you are updating. The API product name required in the request URL is the internal name of the product, not the Display Name. While they may be the same, it depends on whether the API product was created via UI or API. View the list of API products to identify their internal names.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the API product. Use the following structure in your request: `organizations/{org}/apiproducts/{apiproduct}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apiproducts_update(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apiproducts_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/{+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.Apigee.V1.Model.GoogleCloudApigeeV1ApiProduct{}]
)
end
@doc """
Deletes an API product attribute.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the API product attribute. Use the following structure in your request: `organizations/{org}/apiproducts/{apiproduct}/attributes/{attribute}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apiproducts_attributes_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apiproducts_attributes_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}]
)
end
@doc """
Gets the value of an API product attribute.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the API product attribute. Use the following structure in your request: `organizations/{org}/apiproducts/{apiproduct}/attributes/{attribute}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apiproducts_attributes_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apiproducts_attributes_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}]
)
end
@doc """
Lists all API product attributes.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the API product. Use the following structure in your request: `organizations/{org}/apiproducts/{apiproduct}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attributes{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apiproducts_attributes_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attributes.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apiproducts_attributes_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("/v1/{+parent}/attributes", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Attributes{}]
)
end
@doc """
Updates the value of an API product attribute. **Note**: OAuth access tokens and Key Management Service (KMS) entities (apps, developers, and API products) are cached for 180 seconds (current default). Any custom attributes associated with entities also get cached for at least 180 seconds after entity is accessed during runtime. In this case, the `ExpiresIn` element on the OAuthV2 policy won't be able to expire an access token in less than 180 seconds.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the API product. Use the following structure in your request: `organizations/{org}/apiproducts/{apiproduct}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attribute.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apiproducts_attributes_update_api_product_attribute(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apiproducts_attributes_update_api_product_attribute(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}]
)
end
@doc """
Creates an API proxy. The API proxy created will not be accessible at runtime until it is deployed to an environment. Create a new API proxy by setting the `name` query parameter to the name of the API proxy. Import an API proxy configuration bundle stored in zip format on your local machine to your organization by doing the following: * Set the `name` query parameter to the name of the API proxy. * Set the `action` query parameter to `import`. * Set the `Content-Type` header to `multipart/form-data`. * Pass as a file the name of API proxy configuration bundle stored in zip format on your local machine using the `file` form field. **Note**: To validate the API proxy configuration bundle only without importing it, set the `action` query parameter to `validate`. When importing an API proxy configuration bundle, if the API proxy does not exist, it will be created. If the API proxy exists, then a new revision is created. Invalid API proxy configurations are rejected, and a list of validation errors is returned to the client.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization in the following format: `organizations/{org}`
* `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").
* `:action` (*type:* `String.t`) - Action to perform when importing an API proxy configuration bundle. Set this parameter to one of the following values: * `import` to import the API proxy configuration bundle. * `validate` to validate the API proxy configuration bundle without importing it.
* `:name` (*type:* `String.t`) - Name of the API proxy. Restrict the characters used to: A-Za-z0-9._-
* `:validate` (*type:* `boolean()`) - Ignored. All uploads are validated regardless of the value of this field. Maintained for compatibility with Apigee Edge API.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxyRevision{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apis_create(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxyRevision.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apis_create(connection, parent, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:action => :query,
:name => :query,
:validate => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/apis", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxyRevision{}]
)
end
@doc """
Deletes an API proxy and all associated endpoints, policies, resources, and revisions. The API proxy must be undeployed before you can delete it.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the API proxy in the following format: `organizations/{org}/apis/{api}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxy{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apis_delete(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxy.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apis_delete(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxy{}])
end
@doc """
Gets an API proxy including a list of existing revisions.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the API proxy in the following format: `organizations/{org}/apis/{api}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxy{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apis_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxy.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apis_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxy{}])
end
@doc """
Lists the names of all API proxies in an organization. The names returned correspond to the names defined in the configuration files for each API proxy.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization in the following format: `organizations/{org}`
* `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").
* `:includeMetaData` (*type:* `boolean()`) - Flag that specifies whether to include API proxy metadata in the response.
* `:includeRevisions` (*type:* `boolean()`) - Flag that specifies whether to include a list of revisions in the response.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListApiProxiesResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apis_list(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListApiProxiesResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apis_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,
:includeMetaData => :query,
:includeRevisions => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/apis", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListApiProxiesResponse{}]
)
end
@doc """
Lists all deployments of an API proxy.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the API proxy for which to return deployment information in the following format: `organizations/{org}/apis/{api}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apis_deployments_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apis_deployments_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("/v1/{+parent}/deployments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}]
)
end
@doc """
Creates a key value map in an api proxy.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The name of the environment in which to create the key value map. Must be of the form `organizations/{organization}/apis/{api}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apis_keyvaluemaps_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apis_keyvaluemaps_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/keyvaluemaps", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap{}]
)
end
@doc """
Delete a key value map in an api proxy.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the key value map. Must be of the form `organizations/{organization}/apis/{api}/keyvaluemaps/{keyvaluemap}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apis_keyvaluemaps_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apis_keyvaluemaps_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap{}]
)
end
@doc """
Deletes an API proxy revision and all policies, resources, endpoints, and revisions associated with it. The API proxy revision must be undeployed before you can delete it.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. API proxy revision in the following format: `organizations/{org}/apis/{api}/revisions/{rev}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxyRevision{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apis_revisions_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxyRevision.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apis_revisions_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxyRevision{}]
)
end
@doc """
Gets an API proxy revision. To download the API proxy configuration bundle for the specified revision as a zip file, do the following: * Set the `format` query parameter to `bundle`. * Set the `Accept` header to `application/zip`. If you are using curl, specify `-o filename.zip` to save the output to a file; otherwise, it displays to `stdout`. Then, develop the API proxy configuration locally and upload the updated API proxy configuration revision, as described in [updateApiProxyRevision](updateApiProxyRevision).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. API proxy revision in the following format: `organizations/{org}/apis/{api}/revisions/{rev}`
* `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").
* `:format` (*type:* `String.t`) - Format used when downloading the API proxy configuration revision. Set to `bundle` to download the API proxy configuration revision as a zip file.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleApiHttpBody{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apis_revisions_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apis_revisions_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,
:format => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleApiHttpBody{}])
end
@doc """
Updates an existing API proxy revision by uploading the API proxy configuration bundle as a zip file from your local machine. You can update only API proxy revisions that have never been deployed. After deployment, an API proxy revision becomes immutable, even if it is undeployed. Set the `Content-Type` header to either `multipart/form-data` or `application/octet-stream`.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. API proxy revision to update in the following format: `organizations/{org}/apis/{api}/revisions/{rev}`
* `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").
* `:validate` (*type:* `boolean()`) - Ignored. All uploads are validated regardless of the value of this field. Maintained for compatibility with Apigee Edge API.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxyRevision{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apis_revisions_update_api_proxy_revision(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxyRevision.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apis_revisions_update_api_proxy_revision(
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,
:validate => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiProxyRevision{}]
)
end
@doc """
Lists all deployments of an API proxy revision.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the API proxy revision for which to return deployment information in the following format: `organizations/{org}/apis/{api}/revisions/{rev}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apis_revisions_deployments_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apis_revisions_deployments_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("/v1/{+parent}/deployments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}]
)
end
@doc """
Gets the app profile for the specified app ID.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. App ID in the following format: `organizations/{org}/apps/{app}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1App{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apps_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1App.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apps_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1App{}])
end
@doc """
Lists IDs of apps within an organization that have the specified app status (approved or revoked) or are of the specified app type (developer or company).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Resource path of the parent in the following format: `organizations/{org}`
* `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").
* `:apiProduct` (*type:* `String.t`) - API product.
* `:apptype` (*type:* `String.t`) - Optional. Filter by the type of the app. Valid values are `company` or `developer`. Defaults to `developer`.
* `:expand` (*type:* `boolean()`) - Optional. Flag that specifies whether to return an expanded list of apps for the organization. Defaults to `false`.
* `:ids` (*type:* `String.t`) - Optional. Comma-separated list of app IDs on which to filter.
* `:includeCred` (*type:* `boolean()`) - Optional. Flag that specifies whether to include credentials in the response.
* `:keyStatus` (*type:* `String.t`) - Optional. Key status of the app. Valid values include `approved` or `revoked`. Defaults to `approved`.
* `:rows` (*type:* `String.t`) - Optional. Maximum number of app IDs to return. Defaults to 10000.
* `:startKey` (*type:* `String.t`) - Returns the list of apps starting from the specified app ID.
* `:status` (*type:* `String.t`) - Optional. Filter by the status of the app. Valid values are `approved` or `revoked`. Defaults to `approved`.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListAppsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_apps_list(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListAppsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_apps_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,
:apiProduct => :query,
:apptype => :query,
:expand => :query,
:ids => :query,
:includeCred => :query,
:keyStatus => :query,
:rows => :query,
:startKey => :query,
:status => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/apps", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListAppsResponse{}]
)
end
@doc """
Creates a new data collector.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization in which to create the data collector in the following format: `organizations/{org}`.
* `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").
* `:dataCollectorId` (*type:* `String.t`) - ID of the data collector. Overrides any ID in the data collector resource. Must begin with `dc_`.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DataCollector.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DataCollector{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_datacollectors_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DataCollector.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_datacollectors_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:dataCollectorId => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/datacollectors", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1DataCollector{}]
)
end
@doc """
Deletes a data collector.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the data collector in the following format: `organizations/{org}/datacollectors/{data_collector_id}`.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_datacollectors_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_datacollectors_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty{}])
end
@doc """
Gets a data collector.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the data collector in the following format: `organizations/{org}/datacollectors/{data_collector_id}`.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DataCollector{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_datacollectors_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DataCollector.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_datacollectors_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DataCollector{}]
)
end
@doc """
Lists all data collectors.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization for which to list data collectors in the following format: `organizations/{org}`.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - Maximum number of data collectors to return. The page size defaults to 25.
* `:pageToken` (*type:* `String.t`) - Page token, returned from a previous ListDataCollectors call, that you can use to retrieve the next page.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDataCollectorsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_datacollectors_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDataCollectorsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_datacollectors_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("/v1/{+parent}/datacollectors", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListDataCollectorsResponse{}]
)
end
@doc """
Updates a data collector.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the data collector in the following format: `organizations/{org}/datacollectors/{data_collector_id}`.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:updateMask` (*type:* `String.t`) - List of fields to be updated.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DataCollector.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DataCollector{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_datacollectors_patch(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DataCollector.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_datacollectors_patch(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:updateMask => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:patch)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DataCollector{}]
)
end
@doc """
Lists all deployments of API proxies or shared flows.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization for which to return deployment information in the following format: `organizations/{org}`
* `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").
* `:sharedFlows` (*type:* `boolean()`) - Optional. Flag that specifies whether to return shared flow or API proxy deployments. Set to `true` to return shared flow deployments; set to `false` to return API proxy deployments. Defaults to `false`.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_deployments_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_deployments_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,
:sharedFlows => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/deployments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}]
)
end
@doc """
Updates developer attributes. This API replaces the existing attributes with those specified in the request. Add new attributes, and include or exclude any existing attributes that you want to retain or remove, respectively. The custom attribute limit is 18. **Note**: OAuth access tokens and Key Management Service (KMS) entities (apps, developers, and API products) are cached for 180 seconds (default). Any custom attributes associated with these entities are cached for at least 180 seconds after the entity is accessed at runtime. Therefore, an `ExpiresIn` element on the OAuthV2 policy won't be able to expire an access token in less than 180 seconds.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Email address of the developer for which attributes are being updated in the following format: `organizations/{org}/developers/{developer_email}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attributes.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attributes{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_attributes(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attributes.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_attributes(
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,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/attributes", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Attributes{}]
)
end
@doc """
Creates a developer. Once created, the developer can register an app and obtain an API key. At creation time, a developer is set as `active`. To change the developer status, use the SetDeveloperStatus API.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the Apigee organization in which the developer is created. Use the following structure in your request: `organizations/{org}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Developer.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Developer{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Developer.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/developers", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Developer{}]
)
end
@doc """
Deletes a developer. All apps and API keys associated with the developer are also removed. **Warning**: This API will permanently delete the developer and related artifacts. To avoid permanently deleting developers and their artifacts, set the developer status to `inactive` using the SetDeveloperStatus API. **Note**: The delete operation is asynchronous. The developer app is deleted immediately, but its associated resources, such as apps and API keys, may take anywhere from a few seconds to a few minutes to be deleted.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Email address of the developer. Use the following structure in your request: `organizations/{org}/developers/{developer_email}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Developer{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Developer.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_delete(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Developer{}]
)
end
@doc """
Returns the developer details, including the developer's name, email address, apps, and other information. **Note**: The response includes only the first 100 developer apps.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Email address of the developer. Use the following structure in your request: `organizations/{org}/developers/{developer_email}`
* `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").
* `:action` (*type:* `String.t`) - Status of the developer. Valid values are `active` or `inactive`.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Developer{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Developer.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_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,
:action => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Developer{}]
)
end
@doc """
Lists all developers in an organization by email address. By default, the response does not include company developers. Set the `includeCompany` query parameter to `true` to include company developers. **Note**: A maximum of 1000 developers are returned in the response. You paginate the list of developers returned using the `startKey` and `count` query parameters.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the Apigee organization. Use the following structure in your request: `organizations/{org}`.
* `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").
* `:app` (*type:* `String.t`) - Optional. List only Developers that are associated with the app. Note that start_key, count are not applicable for this filter criteria.
* `:count` (*type:* `String.t`) - Optional. Number of developers to return in the API call. Use with the `startKey` parameter to provide more targeted filtering. The limit is 1000.
* `:expand` (*type:* `boolean()`) - Specifies whether to expand the results. Set to `true` to expand the results. This query parameter is not valid if you use the `count` or `startKey` query parameters.
* `:ids` (*type:* `String.t`) - Optional. List of IDs to include, separated by commas.
* `:includeCompany` (*type:* `boolean()`) - Flag that specifies whether to include company details in the response.
* `:startKey` (*type:* `String.t`) - **Note**: Must be used in conjunction with the `count` parameter. Email address of the developer from which to start displaying the list of developers. For example, if the an unfiltered list returns: ``` westley@example.com fezzik@example.com buttercup@example.com ``` and your `startKey` is `fezzik@example.com`, the list returned will be ``` fezzik@example.com buttercup@example.com ```
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListOfDevelopersResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_list(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListOfDevelopersResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_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,
:app => :query,
:count => :query,
:expand => :query,
:ids => :query,
:includeCompany => :query,
:startKey => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/developers", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListOfDevelopersResponse{}]
)
end
@doc """
Sets the status of a developer. Valid values are `active` or `inactive`. A developer is `active` by default. If you set a developer's status to `inactive`, the API keys assigned to the developer apps are no longer valid even though the API keys are set to `approved`. Inactive developers can still sign in to the developer portal and create apps; however, any new API keys generated during app creation won't work. If successful, the API call returns the following HTTP status code: `204 No Content`
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Email address of the developer. Use the following structure in your request: `organizations/{org}/developers/{developer_email}`
* `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").
* `:action` (*type:* `String.t`) - Status of the developer. Valid values are `active` and `inactive`.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_set_developer_status(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_set_developer_status(
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,
:action => :query
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty{}])
end
@doc """
Updates a developer. This API replaces the existing developer details with those specified in the request. Include or exclude any existing details that you want to retain or delete, respectively. The custom attribute limit is 18. **Note**: OAuth access tokens and Key Management Service (KMS) entities (apps, developers, and API products) are cached for 180 seconds (current default). Any custom attributes associated with these entities are cached for at least 180 seconds after the entity is accessed at runtime. Therefore, an `ExpiresIn` element on the OAuthV2 policy won't be able to expire an access token in less than 180 seconds.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Email address of the developer. Use the following structure in your request: `organizations/{org}/developers/{developer_email}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Developer.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Developer{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_update(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Developer.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_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/{+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.Apigee.V1.Model.GoogleCloudApigeeV1Developer{}]
)
end
@doc """
Updates attributes for a developer app. This API replaces the current attributes with those specified in the request.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the developer app. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps/{app}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attributes.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attributes{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_attributes(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attributes.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_attributes(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}/attributes", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Attributes{}]
)
end
@doc """
Creates an app associated with a developer. This API associates the developer app with the specified API product and auto-generates an API key for the app to use in calls to API proxies inside that API product. The `name` is the unique ID of the app that you can use in API calls. The `DisplayName` (set as an attribute) appears in the UI. If you don't set the `DisplayName` attribute, the `name` appears in the UI.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the developer. Use the following structure in your request: `organizations/{org}/developers/{developer_email}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/apps", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp{}]
)
end
@doc """
Deletes a developer app. **Note**: The delete operation is asynchronous. The developer app is deleted immediately, but its associated resources, such as app keys or access tokens, may take anywhere from a few seconds to a few minutes to be deleted.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the developer app. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps/{app}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp{}]
)
end
@doc """
Manages access to a developer app by enabling you to: * Approve or revoke a developer app * Generate a new consumer key and secret for a developer app To approve or revoke a developer app, set the `action` query parameter to `approved` or `revoked`, respectively, and the `Content-Type` header to `application/octet-stream`. If a developer app is revoked, none of its API keys are valid for API calls even though the keys are still `approved`. If successful, the API call returns the following HTTP status code: `204 No Content` To generate a new consumer key and secret for a developer app, pass the new key/secret details. Rather than replace an existing key, this API generates a new key. In this case, multiple key pairs may be associated with a single developer app. Each key pair has an independent status (`approved` or `revoked`) and expiration time. Any approved, non-expired key can be used in an API call. For example, if you're using API key rotation, you can generate new keys with expiration times that overlap keys that are going to expire. You might also generate a new consumer key/secret if the security of the original key/secret is compromised. The `keyExpiresIn` property defines the expiration time for the API key in milliseconds. If you don't set this property or set it to `-1`, the API key never expires. **Notes**: * When generating a new key/secret, this API replaces the existing attributes, notes, and callback URLs with those specified in the request. Include or exclude any existing information that you want to retain or delete, respectively. * To migrate existing consumer keys and secrets to hybrid from another system, see the CreateDeveloperAppKey API.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the developer app. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps/{app}`
* `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").
* `:action` (*type:* `String.t`) - Action. Valid values are `approve` or `revoke`.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_generate_key_pair_or_update_developer_app_status(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_generate_key_pair_or_update_developer_app_status(
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,
:action => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp{}]
)
end
@doc """
Returns the details for a developer app.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the developer app. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps/{app}`
* `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").
* `:entity` (*type:* `String.t`) - **Note**: Must be used in conjunction with the `query` parameter. Set to `apiresources` to return the number of API resources that have been approved for access by a developer app in the specified Apigee organization.
* `:query` (*type:* `String.t`) - **Note**: Must be used in conjunction with the `entity` parameter. Set to `count` to return the number of API resources that have been approved for access by a developer app in the specified Apigee organization.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_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,
:entity => :query,
:query => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp{}]
)
end
@doc """
Lists all apps created by a developer in an Apigee organization. Optionally, you can request an expanded view of the developer apps. A maximum of 100 developer apps are returned per API call. You can paginate the list of deveoper apps returned using the `startKey` and `count` query parameters.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the developer. Use the following structure in your request: `organizations/{org}/developers/{developer_email}`
* `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").
* `:count` (*type:* `String.t`) - Number of developer apps to return in the API call. Use with the `startKey` parameter to provide more targeted filtering. The limit is 1000.
* `:expand` (*type:* `boolean()`) - Optional. Specifies whether to expand the results. Set to `true` to expand the results. This query parameter is not valid if you use the `count` or `startKey` query parameters.
* `:shallowExpand` (*type:* `boolean()`) - Optional. Specifies whether to expand the results in shallow mode. Set to `true` to expand the results in shallow mode.
* `:startKey` (*type:* `String.t`) - **Note**: Must be used in conjunction with the `count` parameter. Name of the developer app from which to start displaying the list of developer apps. For example, if you're returning 50 developer apps at a time (using the `count` query parameter), you can view developer apps 50-99 by entering the name of the 50th developer app. The developer app name is case sensitive.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDeveloperAppsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDeveloperAppsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_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,
:count => :query,
:expand => :query,
:shallowExpand => :query,
:startKey => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/apps", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeveloperAppsResponse{}]
)
end
@doc """
Updates the details for a developer app. In addition, you can add an API product to a developer app and automatically generate an API key for the app to use when calling APIs in the API product. If you want to use an existing API key for the API product, add the API product to the API key using the UpdateDeveloperAppKey API. Using this API, you cannot update the following: * App name as it is the primary key used to identify the app and cannot be changed. * Scopes associated with the app. Instead, use the ReplaceDeveloperAppKey API. This API replaces the existing attributes with those specified in the request. Include or exclude any existing attributes that you want to retain or delete, respectively.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the developer app. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps/{app}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_update(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_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/{+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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperApp{}]
)
end
@doc """
Deletes a developer app attribute.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the developer app attribute. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps/{app}/attributes/{attribute}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_attributes_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_attributes_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}]
)
end
@doc """
Returns a developer app attribute.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the developer app attribute. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps/{app}/attributes/{attribute}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_attributes_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_attributes_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}]
)
end
@doc """
Returns a list of all developer app attributes.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the developer app. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps/{app}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attributes{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_attributes_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attributes.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_attributes_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("/v1/{+parent}/attributes", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Attributes{}]
)
end
@doc """
Updates a developer app attribute. **Note**: OAuth access tokens and Key Management Service (KMS) entities (apps, developers, and API products) are cached for 180 seconds (current default). Any custom attributes associated with these entities are cached for at least 180 seconds after the entity is accessed at runtime. Therefore, an `ExpiresIn` element on the OAuthV2 policy won't be able to expire an access token in less than 180 seconds.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the developer app attribute. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps/{app}/attributes/{attribute}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attribute.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_attributes_update_developer_app_attribute(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_attributes_update_developer_app_attribute(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}]
)
end
@doc """
Creates a custom consumer key and secret for a developer app. This is particularly useful if you want to migrate existing consumer keys and secrets to Apigee hybrid from another system. Consumer keys and secrets can contain letters, numbers, underscores, and hyphens. No other special characters are allowed. To avoid service disruptions, a consumer key and secret should not exceed 2 KBs each. **Note**: When creating the consumer key and secret, an association to API products will not be made. Therefore, you should not specify the associated API products in your request. Instead, use the UpdateDeveloperAppKey API to make the association after the consumer key and secret are created. If a consumer key and secret already exist, you can keep them or delete them using the DeleteDeveloperAppKey API.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Parent of the developer app key. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_keys_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_keys_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/keys", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}]
)
end
@doc """
Deletes an app's consumer key and removes all API products associated with the app. After the consumer key is deleted, it cannot be used to access any APIs. **Note**: After you delete a consumer key, you may want to: 1. Create a new consumer key and secret for the developer app using the CreateDeveloperAppKey API, and subsequently add an API product to the key using the UpdateDeveloperAppKey API. 2. Delete the developer app, if it is no longer required.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the developer app key. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps/{app}/keys/{key}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_keys_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_keys_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}]
)
end
@doc """
Returns details for a consumer key for a developer app, including the key and secret value, associated API products, and other information.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the developer app key. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps/{app}/keys/{key}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_keys_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_keys_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}]
)
end
@doc """
Updates the scope of an app. This API replaces the existing scopes with those specified in the request. Include or exclude any existing scopes that you want to retain or delete, respectively. The specified scopes must already be defined for the API products associated with the app. This API sets the `scopes` element under the `apiProducts` element in the attributes of the app.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the developer app key. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps/{app}/keys/{key}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_keys_replace_developer_app_key(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_keys_replace_developer_app_key(
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/{+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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}]
)
end
@doc """
Adds an API product to a developer app key, enabling the app that holds the key to access the API resources bundled in the API product. In addition, you can add attributes to a developer app key. This API replaces the existing attributes with those specified in the request. Include or exclude any existing attributes that you want to retain or delete, respectively. You can use the same key to access all API products associated with the app.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the developer app key. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps/{app}/keys/{key}`
* `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").
* `:action` (*type:* `String.t`) - Approve or revoke the consumer key by setting this value to `approve` or `revoke`, respectively.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_keys_update_developer_app_key(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_keys_update_developer_app_key(
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,
:action => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}]
)
end
@doc """
Removes an API product from an app's consumer key. After the API product is removed, the app cannot access the API resources defined in that API product. **Note**: The consumer key is not removed, only its association with the API product.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the API product in the developer app key in the following format: `organizations/{org}/developers/{developer_email}/apps/{app}/keys/{key}/apiproducts/{apiproduct}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_keys_apiproducts_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_keys_apiproducts_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}]
)
end
@doc """
Approve or revoke an app's consumer key. After a consumer key is approved, the app can use it to access APIs. A consumer key that is revoked or pending cannot be used to access an API. Any access tokens associated with a revoked consumer key will remain active. However, Apigee hybrid checks the status of the consumer key and if set to `revoked` will not allow access to the API.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the API product in the developer app key in the following format: `organizations/{org}/developers/{developer_email}/apps/{app}/keys/{key}/apiproducts/{apiproduct}`
* `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").
* `:action` (*type:* `String.t`) - Approve or revoke the consumer key by setting this value to `approve` or `revoke`, respectively.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_keys_apiproducts_update_developer_app_key_api_product(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_keys_apiproducts_update_developer_app_key_api_product(
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,
:action => :query
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty{}])
end
@doc """
Creates a custom consumer key and secret for a developer app. This is particularly useful if you want to migrate existing consumer keys and secrets to Apigee hybrid from another system. Consumer keys and secrets can contain letters, numbers, underscores, and hyphens. No other special characters are allowed. To avoid service disruptions, a consumer key and secret should not exceed 2 KBs each. **Note**: When creating the consumer key and secret, an association to API products will not be made. Therefore, you should not specify the associated API products in your request. Instead, use the UpdateDeveloperAppKey API to make the association after the consumer key and secret are created. If a consumer key and secret already exist, you can keep them or delete them using the DeleteDeveloperAppKey API.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Parent of the developer app key. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/apps`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_apps_keys_create_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_apps_keys_create_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/keys/create", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1DeveloperAppKey{}]
)
end
@doc """
Deletes a developer attribute.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the developer attribute. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/attributes/{attribute}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_attributes_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_attributes_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}]
)
end
@doc """
Returns the value of the specified developer attribute.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the developer attribute. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/attributes/{attribute}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_attributes_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_attributes_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}]
)
end
@doc """
Returns a list of all developer attributes.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Email address of the developer for which attributes are being listed in the following format: `organizations/{org}/developers/{developer_email}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attributes{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_attributes_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attributes.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_attributes_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("/v1/{+parent}/attributes", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Attributes{}]
)
end
@doc """
Updates a developer attribute. **Note**: OAuth access tokens and Key Management Service (KMS) entities (apps, developers, and API products) are cached for 180 seconds (default). Any custom attributes associated with these entities are cached for at least 180 seconds after the entity is accessed at runtime. Therefore, an `ExpiresIn` element on the OAuthV2 policy won't be able to expire an access token in less than 180 seconds.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the developer attribute. Use the following structure in your request: `organizations/{org}/developers/{developer_email}/attributes/{attribute}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Attribute.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_developers_attributes_update_developer_attribute(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Attribute.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_developers_attributes_update_developer_attribute(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Attribute{}]
)
end
@doc """
Creates a new environment group.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization in which to create the environment group in the following format: `organizations/{org}`.
* `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").
* `:name` (*type:* `String.t`) - ID of the environment group. Overrides any ID in the environment_group resource.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1EnvironmentGroup.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_envgroups_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_envgroups_create(connection, parent, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:name => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/envgroups", %{
"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.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Deletes an environment group.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the environment group in the following format: `organizations/{org}/envgroups/{envgroup}`.
* `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.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_envgroups_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_envgroups_delete(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Gets an environment group.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the environment group in the following format: `organizations/{org}/envgroups/{envgroup}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1EnvironmentGroup{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_envgroups_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1EnvironmentGroup.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_envgroups_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1EnvironmentGroup{}]
)
end
@doc """
Lists all environment groups.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization for which to list environment groups in the following format: `organizations/{org}`.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - Maximum number of environment groups to return. The page size defaults to 25.
* `:pageToken` (*type:* `String.t`) - Page token, returned from a previous ListEnvironmentGroups call, that you can use to retrieve the next page.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListEnvironmentGroupsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_envgroups_list(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListEnvironmentGroupsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_envgroups_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("/v1/{+parent}/envgroups", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListEnvironmentGroupsResponse{}]
)
end
@doc """
Updates an environment group.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the environment group to update in the format: `organizations/{org}/envgroups/{envgroup}.
* `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`) - List of fields to be updated.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1EnvironmentGroup.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_envgroups_patch(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_envgroups_patch(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:updateMask => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:patch)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Creates a new attachment of an environment to an environment group.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. EnvironmentGroup under which to create the attachment in the following format: `organizations/{org}/envgroups/{envgroup}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1EnvironmentGroupAttachment.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_envgroups_attachments_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_envgroups_attachments_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/attachments", %{
"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.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Deletes an environment group attachment.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the environment group attachment to delete in the following format: `organizations/{org}/envgroups/{envgroup}/attachments/{attachment}`.
* `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.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_envgroups_attachments_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_envgroups_attachments_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Gets an environment group attachment.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the environment group attachment in the following format: `organizations/{org}/envgroups/{envgroup}/attachments/{attachment}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1EnvironmentGroupAttachment{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_envgroups_attachments_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1EnvironmentGroupAttachment.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_envgroups_attachments_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1EnvironmentGroupAttachment{}]
)
end
@doc """
Lists all attachments of an environment group.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the environment group in the following format: `organizations/{org}/envgroups/{envgroup}`.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - Maximum number of environment group attachments to return. The page size defaults to 25.
* `:pageToken` (*type:* `String.t`) - Page token, returned by a previous ListEnvironmentGroupAttachments call, that you can use to retrieve the next page.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListEnvironmentGroupAttachmentsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_envgroups_attachments_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok,
GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListEnvironmentGroupAttachmentsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_envgroups_attachments_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("/v1/{+parent}/attachments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListEnvironmentGroupAttachmentsResponse{}
]
)
end
@doc """
Creates an environment in an organization.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization in which the environment will be created. Use the following structure in your request: `organizations/{org}`
* `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").
* `:name` (*type:* `String.t`) - Optional. Name of the environment. Alternatively, the name may be specified in the request body in the name field.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Environment.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:name => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/environments", %{
"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.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Deletes an environment from an organization.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the environment. Use the following structure in your request: `organizations/{org}/environments/{env}`
* `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.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Gets environment details.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the environment. Use the following structure in your request: `organizations/{org}/environments/{env}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Environment{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Environment.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Environment{}]
)
end
@doc """
Gets the debug mask singleton resource for an environment.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the debug mask. Use the following structure in your request: `organizations/{org}/environments/{env}/debugmask`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1DebugMask{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_get_debugmask(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DebugMask.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_get_debugmask(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DebugMask{}]
)
end
@doc """
Gets the deployed configuration for an environment.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the environment deployed configuration resource. Use the following structure in your request: `organizations/{org}/environments/{env}/deployedConfig`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1EnvironmentConfig{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_get_deployed_config(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1EnvironmentConfig.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_get_deployed_config(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1EnvironmentConfig{}]
)
end
@doc """
Gets the IAM policy on an environment. For more information, see [Manage users, roles, and permissions using the API](https://cloud.google.com/apigee/docs/api-platform/system-administration/manage-users-roles). You must have the `apigee.environments.getIamPolicy` permission to call this API.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `resource` (*type:* `String.t`) - REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:"options.requestedPolicyVersion"` (*type:* `integer()`) - Optional. The policy format version to be returned. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional bindings must specify version 3. Policies without any conditional bindings may specify any valid value or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleIamV1Policy{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_get_iam_policy(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleIamV1Policy.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_get_iam_policy(
connection,
resource,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:"options.requestedPolicyVersion" => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+resource}:getIamPolicy", %{
"resource" => URI.encode(resource, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleIamV1Policy{}])
end
@doc """
Sets the IAM policy on an environment, if the policy already exists it will be replaced. For more information, see [Manage users, roles, and permissions using the API](https://cloud.google.com/apigee/docs/api-platform/system-administration/manage-users-roles). You must have the `apigee.environments.setIamPolicy` permission to call this API.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.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.Apigee.V1.Model.GoogleIamV1SetIamPolicyRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleIamV1Policy{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_set_iam_policy(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleIamV1Policy.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_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.Apigee.V1.Model.GoogleIamV1Policy{}])
end
@doc """
Creates a subscription for the environment's Pub/Sub topic. The server will assign a random name for this subscription. The "name" and "push_config" must *not* be specified.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the environment. Use the following structure in your request: `organizations/{org}/environments/{env}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Subscription{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_subscribe(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Subscription.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_subscribe(
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(:post)
|> Request.url("/v1/{+parent}:subscribe", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Subscription{}]
)
end
@doc """
Tests the permissions of a user on an environment, and returns a subset of permissions that the user has on the environment. If the environment does not exist, an empty permission set is returned (a NOT_FOUND error is not returned).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.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.Apigee.V1.Model.GoogleIamV1TestIamPermissionsRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleIamV1TestIamPermissionsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_test_iam_permissions(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleIamV1TestIamPermissionsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_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.Apigee.V1.Model.GoogleIamV1TestIamPermissionsResponse{}]
)
end
@doc """
Deletes a subscription for the environment's Pub/Sub topic.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the environment. Use the following structure in your request: `organizations/{org}/environments/{env}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Subscription.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_unsubscribe(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_unsubscribe(
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,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}:unsubscribe", %{
"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.Apigee.V1.Model.GoogleProtobufEmpty{}])
end
@doc """
Updates an existing environment. When updating properties, you must pass all existing properties to the API, even if they are not being changed. If you omit properties from the payload, the properties are removed. To get the current list of properties for the environment, use the [Get Environment API](get).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the environment. Use the following structure in your request: `organizations/{org}/environments/{env}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Environment.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Environment{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_update(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Environment.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_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/{+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.Apigee.V1.Model.GoogleCloudApigeeV1Environment{}]
)
end
@doc """
Updates the debug mask singleton resource for an environment.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the debug mask.
* `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").
* `:replaceRepeatedFields` (*type:* `boolean()`) - Boolean flag that specifies whether to replace existing values in the debug mask when doing an update. Set to true to replace existing values. The default behavior is to append the values (false).
* `:updateMask` (*type:* `String.t`) - Field debug mask to support partial updates.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DebugMask.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DebugMask{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_update_debugmask(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DebugMask.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_update_debugmask(
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,
:replaceRepeatedFields => :query,
:updateMask => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:patch)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DebugMask{}]
)
end
@doc """
Updates an existing environment. When updating properties, you must pass all existing properties to the API, even if they are not being changed. If you omit properties from the payload, the properties are removed. To get the current list of properties for the environment, use the [Get Environment API](get).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the environment. Use the following structure in your request: `organizations/{org}/environments/{env}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Environment.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Environment{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_update_environment(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Environment.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_update_environment(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Environment{}]
)
end
@doc """
Get a list of metrics and dimensions which can be used for creating analytics queries and reports. Each schema element contains the name of the field with its associated type and if it is either custom field or standard field.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The parent organization and environment names. Must be of the form `organizations/{org}/environments/{env}/analytics/admin/schemav2`.
* `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").
* `:type` (*type:* `String.t`) - Required. Type refers to the dataset name whose schema needs to be retrieved E.g. type=fact or type=agg_cus1
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Schema{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_analytics_admin_get_schemav2(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Schema.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_analytics_admin_get_schemav2(
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,
:type => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Schema{}])
end
@doc """
Submit a data export job to be processed in the background. If the request is successful, the API returns a 201 status, a URI that can be used to retrieve the status of the export job, and the `state` value of "enqueued".
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Names of the parent organization and environment. Must be of the form `organizations/{org}/environments/{env}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ExportRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Export{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_analytics_exports_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Export.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_analytics_exports_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/analytics/exports", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Export{}])
end
@doc """
Gets the details and status of an analytics export job. If the export job is still in progress, its `state` is set to "running". After the export job has completed successfully, its `state` is set to "completed". If the export job fails, its `state` is set to `failed`.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Resource name of the export to get.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Export{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_analytics_exports_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Export.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_analytics_exports_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Export{}])
end
@doc """
Lists the details and status of all analytics export jobs belonging to the parent organization and environment.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Names of the parent organization and environment. Must be of the form `organizations/{org}/environments/{env}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ListExportsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_analytics_exports_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListExportsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_analytics_exports_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("/v1/{+parent}/analytics/exports", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListExportsResponse{}]
)
end
@doc """
Lists all deployments of an API proxy in an environment.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name representing an API proxy in an environment in the following format: `organizations/{org}/environments/{env}/apis/{api}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_apis_deployments_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_apis_deployments_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("/v1/{+parent}/deployments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}]
)
end
@doc """
Deploys a revision of an API proxy. If another revision of the same API proxy revision is currently deployed, set the `override` parameter to `true` to have this revision replace the currently deployed revision. You cannot invoke an API proxy until it has been deployed to an environment. After you deploy an API proxy revision, you cannot edit it. To edit the API proxy, you must create and deploy a new revision. For a request path `organizations/{org}/environments/{env}/apis/{api}/revisions/{rev}/deployments`, two permissions are required: * `apigee.deployments.create` on the resource `organizations/{org}/environments/{env}` * `apigee.proxyrevisions.deploy` on the resource `organizations/{org}/apis/{api}/revisions/{rev}`
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the API proxy revision deployment in the following format: `organizations/{org}/environments/{env}/apis/{api}/revisions/{rev}`
* `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").
* `:override` (*type:* `boolean()`) - Flag that specifies whether the new deployment replaces other deployed revisions of the API proxy in the environment. Set `override` to `true` to replace other deployed revisions. By default, `override` is `false` and the deployment is rejected if other revisions of the API proxy are deployed in the environment.
* `:sequencedRollout` (*type:* `boolean()`) - Flag that specifies whether to enable sequenced rollout. If set to `true`, a best-effort attempt will be made to roll out the routing rules corresponding to this deployment and the environment changes to add this deployment in a safe order. This reduces the risk of downtime that could be caused by changing the environment group's routing before the new destination for the affected traffic is ready to receive it. This should only be necessary if the new deployment will be capturing traffic from another environment under a shared environment group or if traffic will be rerouted to a different environment due to a base path removal. The [GenerateDeployChangeReport API](GenerateDeployChangeReport) may be used to examine routing changes before issuing the deployment request, and its response will indicate if a sequenced rollout is recommended for the deployment.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Deployment{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_apis_revisions_deploy(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Deployment.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_apis_revisions_deploy(
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,
:override => :query,
:sequencedRollout => :query
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}/deployments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Deployment{}]
)
end
@doc """
Gets the deployment of an API proxy revision and actual state reported by runtime pods.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name representing an API proxy revision in an environment in the following format: `organizations/{org}/environments/{env}/apis/{api}/revisions/{rev}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Deployment{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_apis_revisions_get_deployments(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Deployment.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_apis_revisions_get_deployments(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}/deployments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Deployment{}]
)
end
@doc """
Undeploys an API proxy revision from an environment. For a request path `organizations/{org}/environments/{env}/apis/{api}/revisions/{rev}/deployments`, two permissions are required: * `apigee.deployments.delete` on the resource `organizations/{org}/environments/{env}` * `apigee.proxyrevisions.undeploy` on the resource `organizations/{org}/apis/{api}/revisions/{rev}`
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the API proxy revision deployment in the following format: `organizations/{org}/environments/{env}/apis/{api}/revisions/{rev}`
* `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").
* `:sequencedRollout` (*type:* `boolean()`) - Flag that specifies whether to enable sequenced rollout. If set to `true`, a best-effort attempt will be made to remove the environment group routing rules corresponding to this deployment before removing the deployment from the runtime. This is likely to be a rare use case; it is only needed when the intended effect of undeploying this proxy is to cause the traffic it currently handles to be rerouted to some other existing proxy in the environment group. The [GenerateUndeployChangeReport API](GenerateUndeployChangeReport) may be used to examine routing changes before issuing the undeployment request, and its response will indicate if a sequenced rollout is recommended for the undeployment.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_apis_revisions_undeploy(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_apis_revisions_undeploy(
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,
:sequencedRollout => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}/deployments", %{
"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.Apigee.V1.Model.GoogleProtobufEmpty{}])
end
@doc """
Creates a debug session for a deployed API Proxy revision.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The resource name of the API Proxy revision deployment for which to create the DebugSession. Must be of the form `organizations/{organization}/environments/{environment}/apis/{api}/revisions/{revision}`.
* `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").
* `:timeout` (*type:* `String.t`) - Optional. The time in seconds after which this DebugSession should end. A timeout specified in DebugSession will overwrite this value.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DebugSession.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DebugSession{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_apis_revisions_debugsessions_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DebugSession.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_apis_revisions_debugsessions_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:timeout => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/debugsessions", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1DebugSession{}]
)
end
@doc """
Deletes the data from a debug session. This does not cancel the debug session or prevent further data from being collected if the session is still active in runtime pods.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the debug session to delete. Must be of the form: `organizations/{organization}/environments/{environment}/apis/{api}/revisions/{revision}/debugsessions/{debugsession}`.
* `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.Apigee.V1.Model.GoogleProtobufEmpty{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_apis_revisions_debugsessions_delete_data(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_apis_revisions_debugsessions_delete_data(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}/data", %{
"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.Apigee.V1.Model.GoogleProtobufEmpty{}])
end
@doc """
Retrieves a debug session.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the debug session to retrieve. Must be of the form: `organizations/{organization}/environments/{environment}/apis/{api}/revisions/{revision}/debugsessions/{session}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1DebugSession{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_apis_revisions_debugsessions_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DebugSession.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_apis_revisions_debugsessions_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DebugSession{}]
)
end
@doc """
Lists debug sessions that are currently active in the given API Proxy revision.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The name of the API Proxy revision deployment for which to list debug sessions. Must be of the form: `organizations/{organization}/environments/{environment}/apis/{api}/revisions/{revision}`.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - Maximum number of debug sessions to return. The page size defaults to 25.
* `:pageToken` (*type:* `String.t`) - Page token, returned from a previous ListDebugSessions call, that you can use to retrieve the next page.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDebugSessionsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_apis_revisions_debugsessions_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDebugSessionsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_apis_revisions_debugsessions_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("/v1/{+parent}/debugsessions", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListDebugSessionsResponse{}]
)
end
@doc """
Gets the debug data from a transaction.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the debug session transaction. Must be of the form: `organizations/{organization}/environments/{environment}/apis/{api}/revisions/{revision}/debugsessions/{session}/data/{transaction}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1DebugSessionTransaction{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_apis_revisions_debugsessions_data_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DebugSessionTransaction.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_apis_revisions_debugsessions_data_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DebugSessionTransaction{}]
)
end
@doc """
Generates a report for a dry run analysis of a DeployApiProxy request without committing the deployment. In addition to the standard validations performed when adding deployments, additional analysis will be done to detect possible traffic routing changes that would result from this deployment being created. Any potential routing conflicts or unsafe changes will be reported in the response. This routing analysis is not performed for a non-dry-run DeployApiProxy request. For a request path `organizations/{org}/environments/{env}/apis/{api}/revisions/{rev}/deployments:generateDeployChangeReport`, two permissions are required: * `apigee.deployments.create` on the resource `organizations/{org}/environments/{env}` * `apigee.proxyrevisions.deploy` on the resource `organizations/{org}/apis/{api}/revisions/{rev}`
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the API proxy revision deployment in the following format: `organizations/{org}/environments/{env}/apis/{api}/revisions/{rev}`
* `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").
* `:override` (*type:* `boolean()`) - Flag that specifies whether to force the deployment of the new revision over the currently deployed revision by overriding conflict checks.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReport{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_apis_revisions_deployments_generate_deploy_change_report(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReport.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_apis_revisions_deployments_generate_deploy_change_report(
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,
:override => :query
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}/deployments:generateDeployChangeReport", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReport{}]
)
end
@doc """
Generates a report for a dry run analysis of an UndeployApiProxy request without committing the undeploy. In addition to the standard validations performed when removing deployments, additional analysis will be done to detect possible traffic routing changes that would result from this deployment being removed. Any potential routing conflicts or unsafe changes will be reported in the response. This routing analysis is not performed for a non-dry-run UndeployApiProxy request. For a request path `organizations/{org}/environments/{env}/apis/{api}/revisions/{rev}/deployments:generateUndeployChangeReport`, two permissions are required: * `apigee.deployments.delete` on the resource `organizations/{org}/environments/{env}` * `apigee.proxyrevisions.undeploy` on the resource `organizations/{org}/apis/{api}/revisions/{rev}`
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Name of the API proxy revision deployment in the following format: `organizations/{org}/environments/{env}/apis/{api}/revisions/{rev}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReport{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_apis_revisions_deployments_generate_undeploy_change_report(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReport.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_apis_revisions_deployments_generate_undeploy_change_report(
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(:post)
|> Request.url("/v1/{+name}/deployments:generateUndeployChangeReport", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReport{}]
)
end
@doc """
Deletes a cache.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Cache resource name of the form: `organizations/{organization_id}/environments/{environment_id}/caches/{cache_id}`
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_caches_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_caches_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty{}])
end
@doc """
Lists all deployments of API proxies or shared flows in an environment.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the environment for which to return deployment information in the following format: `organizations/{org}/environments/{env}`
* `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").
* `:sharedFlows` (*type:* `boolean()`) - Optional. Flag that specifies whether to return shared flow or API proxy deployments. Set to `true` to return shared flow deployments; set to `false` to return API proxy deployments. Defaults to `false`.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_deployments_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_deployments_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,
:sharedFlows => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/deployments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}]
)
end
@doc """
Attaches a shared flow to a flow hook.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the flow hook to which the shared flow should be attached in the following format: `organizations/{org}/environments/{env}/flowhooks/{flowhook}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1FlowHook.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1FlowHook{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_flowhooks_attach_shared_flow_to_flow_hook(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1FlowHook.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_flowhooks_attach_shared_flow_to_flow_hook(
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/{+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.Apigee.V1.Model.GoogleCloudApigeeV1FlowHook{}])
end
@doc """
Detaches a shared flow from a flow hook.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the flow hook to detach in the following format: `organizations/{org}/environments/{env}/flowhooks/{flowhook}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1FlowHook{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_flowhooks_detach_shared_flow_from_flow_hook(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1FlowHook.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_flowhooks_detach_shared_flow_from_flow_hook(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1FlowHook{}])
end
@doc """
Returns the name of the shared flow attached to the specified flow hook. If there's no shared flow attached to the flow hook, the API does not return an error; it simply does not return a name in the response.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the flow hook in the following format: `organizations/{org}/environments/{env}/flowhooks/{flowhook}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1FlowHook{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_flowhooks_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1FlowHook.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_flowhooks_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1FlowHook{}])
end
@doc """
Creates a keystore or truststore. - Keystore: Contains certificates and their associated keys. - Truststore: Contains trusted certificates used to validate a server's certificate. These certificates are typically self-signed certificates or certificates that are not signed by a trusted CA.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the environment in which to create the keystore. Use the following format in your request: `organizations/{org}/environments/{env}`
* `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").
* `:name` (*type:* `String.t`) - Optional. Name of the keystore. Overrides the value in Keystore.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Keystore.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Keystore{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_keystores_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Keystore.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_keystores_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:name => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/keystores", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Keystore{}])
end
@doc """
Deletes a keystore or truststore.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the keystore. Use the following format in your request: `organizations/{org}/environments/{env}/keystores/{keystore}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Keystore{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_keystores_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Keystore.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_keystores_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Keystore{}])
end
@doc """
Gets a keystore or truststore.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the keystore. Use the following format in your request: `organizations/{org}/environments/{env}/keystores/{keystore}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Keystore{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_keystores_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Keystore.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_keystores_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Keystore{}])
end
@doc """
Creates an alias from a key/certificate pair. The structure of the request is controlled by the `format` query parameter: - `keycertfile` - Separate PEM-encoded key and certificate files are uploaded. Set `Content-Type: multipart/form-data` and include the `keyFile`, `certFile`, and `password` (if keys are encrypted) fields in the request body. If uploading to a truststore, omit `keyFile`. - `pkcs12` - A PKCS12 file is uploaded. Set `Content-Type: multipart/form-data`, provide the file in the `file` field, and include the `password` field if the file is encrypted in the request body. - `selfsignedcert` - A new private key and certificate are generated. Set `Content-Type: application/json` and include CertificateGenerationSpec in the request body.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the keystore. Use the following format in your request: `organizations/{org}/environments/{env}/keystores/{keystore}`.
* `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").
* `:_password` (*type:* `String.t`) - DEPRECATED: For improved security, specify the password in the request body instead of using the query parameter. To specify the password in the request body, set `Content-type: multipart/form-data` part with name `password`. Password for the private key file, if required.
* `:alias` (*type:* `String.t`) - Alias for the key/certificate pair. Values must match the regular expression `[\\w\\s-.]{1,255}`. This must be provided for all formats except `selfsignedcert`; self-signed certs may specify the alias in either this parameter or the JSON body.
* `:format` (*type:* `String.t`) - Required. Format of the data. Valid values include: `selfsignedcert`, `keycertfile`, or `pkcs12`
* `:ignoreExpiryValidation` (*type:* `boolean()`) - Flag that specifies whether to ignore expiry validation. If set to `true`, no expiry validation will be performed.
* `:ignoreNewlineValidation` (*type:* `boolean()`) - Flag that specifies whether to ignore newline validation. If set to `true`, no error is thrown when the file contains a certificate chain with no newline between each certificate. Defaults to `false`.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Alias{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_keystores_aliases_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Alias.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_keystores_aliases_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:_password => :query,
:alias => :query,
:format => :query,
:ignoreExpiryValidation => :query,
:ignoreNewlineValidation => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/aliases", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Alias{}])
end
@doc """
Generates a PKCS #10 Certificate Signing Request for the private key in an alias.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the alias. Use the following format in your request: `organizations/{org}/environments/{env}/keystores/{keystore}/aliases/{alias}`.
* `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.Apigee.V1.Model.GoogleApiHttpBody{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_keystores_aliases_csr(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_keystores_aliases_csr(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}/csr", %{
"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.Apigee.V1.Model.GoogleApiHttpBody{}])
end
@doc """
Deletes an alias.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the alias. Use the following format in your request: `organizations/{org}/environments/{env}/keystores/{keystore}/aliases/{alias}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Alias{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_keystores_aliases_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Alias.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_keystores_aliases_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Alias{}])
end
@doc """
Gets an alias.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the alias. Use the following format in your request: `organizations/{org}/environments/{env}/keystores/{keystore}/aliases/{alias}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Alias{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_keystores_aliases_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Alias.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_keystores_aliases_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Alias{}])
end
@doc """
Gets the certificate from an alias in PEM-encoded form.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the alias. Use the following format in your request: `organizations/{org}/environments/{env}/keystores/{keystore}/aliases/{alias}`.
* `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.Apigee.V1.Model.GoogleApiHttpBody{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_keystores_aliases_get_certificate(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_keystores_aliases_get_certificate(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}/certificate", %{
"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.Apigee.V1.Model.GoogleApiHttpBody{}])
end
@doc """
Updates the certificate in an alias.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the alias. Use the following format in your request: `organizations/{org}/environments/{env}/keystores/{keystore}/aliases/{alias}`
* `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").
* `:ignoreExpiryValidation` (*type:* `boolean()`) - Required. Flag that specifies whether to ignore expiry validation. If set to `true`, no expiry validation will be performed.
* `:ignoreNewlineValidation` (*type:* `boolean()`) - Flag that specifies whether to ignore newline validation. If set to `true`, no error is thrown when the file contains a certificate chain with no newline between each certificate. Defaults to `false`.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Alias{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_keystores_aliases_update(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Alias.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_keystores_aliases_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,
:ignoreExpiryValidation => :query,
:ignoreNewlineValidation => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:put)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Alias{}])
end
@doc """
Creates a key value map in an environment.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The name of the environment in which to create the key value map. Must be of the form `organizations/{organization}/environments/{environment}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_keyvaluemaps_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_keyvaluemaps_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/keyvaluemaps", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap{}]
)
end
@doc """
Delete a key value map in an environment.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the key value map. Must be of the form `organizations/{organization}/environments/{environment}/keyvaluemaps/{keyvaluemap}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_keyvaluemaps_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_keyvaluemaps_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap{}]
)
end
@doc """
This api is similar to GetStats except that the response is less verbose. In the current scheme, a query parameter _optimized instructs Edge Analytics to change the response but since this behavior is not possible with protocol buffer and since this parameter is predominantly used by Edge UI, we are introducing a separate api.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The resource name for which the interactive query will be executed. Must be of the form `organizations/{organization_id}/environments/{environment_id/optimizedStats/{dimensions}` Dimensions let you view metrics in meaningful groupings. E.g. apiproxy, target_host. The value of dimensions should be comma separated list as shown below `organizations/{org}/environments/{env}/optimizedStats/apiproxy,request_verb`
* `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").
* `:accuracy` (*type:* `String.t`) - Legacy field: not used anymore.
* `:aggTable` (*type:* `String.t`) - If customers want to query custom aggregate tables, then this parameter can be used to specify the table name. If this parameter is skipped, then Edge Query will try to retrieve the data from fact tables which will be expensive.
* `:filter` (*type:* `String.t`) - Enables drill-down on specific dimension values.
* `:limit` (*type:* `String.t`) - This parameter is used to limit the number of result items. Default and the max value is 14400.
* `:offset` (*type:* `String.t`) - Use offset with limit to enable pagination of results. For example, to display results 11-20, set limit to '10' and offset to '10'.
* `:realtime` (*type:* `boolean()`) - Legacy field: not used anymore.
* `:select` (*type:* `String.t`) - Required. The select parameter contains a comma separated list of metrics. E.g. sum(message_count),sum(error_count)
* `:sonar` (*type:* `boolean()`) - This parameter routes the query to api monitoring service for last hour.
* `:sort` (*type:* `String.t`) - This parameter specifies if the sort order should be ascending or descending Supported values are DESC and ASC.
* `:sortby` (*type:* `String.t`) - Comma separated list of columns to sort the final result.
* `:timeRange` (*type:* `String.t`) - Required. Time interval for the interactive query. Time range is specified as start~end E.g. 04/15/2017 00:00~05/15/2017 23:59
* `:timeUnit` (*type:* `String.t`) - A value of second, minute, hour, day, week, month. Time Unit specifies the granularity of metrics returned.
* `:topk` (*type:* `String.t`) - Take 'top k' results from results, for example, to return the top 5 results 'topk=5'.
* `:tsAscending` (*type:* `boolean()`) - Lists timestamps in ascending order if set to true. Recommend setting this value to true if you are using sortby with sort=DESC.
* `:tzo` (*type:* `String.t`) - This parameters contains the timezone offset value.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1OptimizedStats{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_optimized_stats_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1OptimizedStats.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_optimized_stats_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,
:accuracy => :query,
:aggTable => :query,
:filter => :query,
:limit => :query,
:offset => :query,
:realtime => :query,
:select => :query,
:sonar => :query,
:sort => :query,
:sortby => :query,
:timeRange => :query,
:timeUnit => :query,
:topk => :query,
:tsAscending => :query,
:tzo => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1OptimizedStats{}]
)
end
@doc """
Submit a query to be processed in the background. If the submission of the query succeeds, the API returns a 201 status and an ID that refer to the query. In addition to the HTTP status 201, the `state` of "enqueued" means that the request succeeded.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The parent resource name. Must be of the form `organizations/{org}/environments/{env}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Query.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQuery{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_queries_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQuery.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_queries_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/queries", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQuery{}]
)
end
@doc """
Get query status If the query is still in progress, the `state` is set to "running" After the query has completed successfully, `state` is set to "completed"
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the asynchronous query to get. Must be of the form `organizations/{org}/environments/{env}/queries/{queryId}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQuery{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_queries_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQuery.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_queries_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQuery{}]
)
end
@doc """
After the query is completed, use this API to retrieve the results. If the request succeeds, and there is a non-zero result set, the result is downloaded to the client as a zipped JSON file. The name of the downloaded file will be: OfflineQueryResult-.zip Example: `OfflineQueryResult-9cfc0d85-0f30-46d6-ae6f-318d0cb961bd.zip`
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the asynchronous query result to get. Must be of the form `organizations/{org}/environments/{env}/queries/{queryId}/result`.
* `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.Apigee.V1.Model.GoogleApiHttpBody{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_queries_get_result(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_queries_get_result(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleApiHttpBody{}])
end
@doc """
Return a list of Asynchronous Queries
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The parent resource name. Must be of the form `organizations/{org}/environments/{env}`.
* `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").
* `:dataset` (*type:* `String.t`) - Filter response list by dataset. Example: `api`, `mint`
* `:from` (*type:* `String.t`) - Filter response list by returning asynchronous queries that created after this date time. Time must be in ISO date-time format like '2011-12-03T10:15:30Z'.
* `:inclQueriesWithoutReport` (*type:* `String.t`) - Flag to include asynchronous queries that don't have a report denifition.
* `:status` (*type:* `String.t`) - Filter response list by asynchronous query status.
* `:submittedBy` (*type:* `String.t`) - Filter response list by user who submitted queries.
* `:to` (*type:* `String.t`) - Filter response list by returning asynchronous queries that created before this date time. Time must be in ISO date-time format like '2011-12-03T10:16:30Z'.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListAsyncQueriesResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_queries_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListAsyncQueriesResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_queries_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,
:dataset => :query,
:from => :query,
:inclQueriesWithoutReport => :query,
:status => :query,
:submittedBy => :query,
:to => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/queries", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListAsyncQueriesResponse{}]
)
end
@doc """
Creates a Reference in the specified environment.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The parent environment name under which the Reference will be created. Must be of the form `organizations/{org}/environments/{env}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Reference.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Reference{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_references_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Reference.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_references_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/references", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Reference{}]
)
end
@doc """
Deletes a Reference from an environment. Returns the deleted Reference resource.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the Reference to delete. Must be of the form `organizations/{org}/environments/{env}/references/{ref}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Reference{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_references_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Reference.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_references_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Reference{}]
)
end
@doc """
Gets a Reference resource.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the Reference to get. Must be of the form `organizations/{org}/environments/{env}/references/{ref}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Reference{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_references_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Reference.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_references_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Reference{}]
)
end
@doc """
Updates an existing Reference. Note that this operation has PUT semantics; it will replace the entirety of the existing Reference with the resource in the request body.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the Reference to update. Must be of the form `organizations/{org}/environments/{env}/references/{ref}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Reference.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Reference{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_references_update(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Reference.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_references_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/{+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.Apigee.V1.Model.GoogleCloudApigeeV1Reference{}]
)
end
@doc """
Creates a resource file. Specify the `Content-Type` as `application/octet-stream` or `multipart/form-data`. For more information about resource files, see [Resource files](https://cloud.google.com/apigee/docs/api-platform/develop/resource-files).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the environment in which to create the resource file in the following format: `organizations/{org}/environments/{env}`.
* `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").
* `:name` (*type:* `String.t`) - Required. Name of the resource file. Must match the regular expression: [a-zA-Z0-9:/\\\\!@#$%^&{}\\[\\]()+\\-=,.~'` ]{1,255}
* `:type` (*type:* `String.t`) - Required. Resource file type. {{ resource_file_type }}
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ResourceFile{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_resourcefiles_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ResourceFile.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_resourcefiles_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:name => :query,
:type => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/resourcefiles", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ResourceFile{}]
)
end
@doc """
Deletes a resource file. For more information about resource files, see [Resource files](https://cloud.google.com/apigee/docs/api-platform/develop/resource-files).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the environment in the following format: `organizations/{org}/environments/{env}`.
* `type` (*type:* `String.t`) - Required. Resource file type. {{ resource_file_type }}
* `name` (*type:* `String.t`) - Required. ID of the resource file to delete. Must match the regular expression: [a-zA-Z0-9:/\\\\!@#$%^&{}\\[\\]()+\\-=,.~'` ]{1,255}
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ResourceFile{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_resourcefiles_delete(
Tesla.Env.client(),
String.t(),
String.t(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ResourceFile.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_resourcefiles_delete(
connection,
parent,
type,
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/{+parent}/resourcefiles/{type}/{name}", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1),
"type" => URI.encode(type, &URI.char_unreserved?/1),
"name" => URI.encode(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.Apigee.V1.Model.GoogleCloudApigeeV1ResourceFile{}]
)
end
@doc """
Gets the contents of a resource file. For more information about resource files, see [Resource files](https://cloud.google.com/apigee/docs/api-platform/develop/resource-files).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the environment in the following format: `organizations/{org}/environments/{env}`.
* `type` (*type:* `String.t`) - Required. Resource file type. {{ resource_file_type }}
* `name` (*type:* `String.t`) - Required. ID of the resource file. Must match the regular expression: [a-zA-Z0-9:/\\\\!@#$%^&{}\\[\\]()+\\-=,.~'` ]{1,255}
* `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.Apigee.V1.Model.GoogleApiHttpBody{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_resourcefiles_get(
Tesla.Env.client(),
String.t(),
String.t(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_resourcefiles_get(
connection,
parent,
type,
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/{+parent}/resourcefiles/{type}/{name}", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1),
"type" => URI.encode(type, &URI.char_unreserved?/1),
"name" => URI.encode(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.Apigee.V1.Model.GoogleApiHttpBody{}])
end
@doc """
Lists all resource files, optionally filtering by type. For more information about resource files, see [Resource files](https://cloud.google.com/apigee/docs/api-platform/develop/resource-files).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the environment in which to list resource files in the following format: `organizations/{org}/environments/{env}`.
* `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").
* `:type` (*type:* `String.t`) - Optional. Type of resource files to list. {{ resource_file_type }}
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListEnvironmentResourcesResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_resourcefiles_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListEnvironmentResourcesResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_resourcefiles_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,
:type => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/resourcefiles", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListEnvironmentResourcesResponse{}]
)
end
@doc """
Lists all resource files, optionally filtering by type. For more information about resource files, see [Resource files](https://cloud.google.com/apigee/docs/api-platform/develop/resource-files).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the environment in which to list resource files in the following format: `organizations/{org}/environments/{env}`.
* `type` (*type:* `String.t`) - Optional. Type of resource files to list. {{ resource_file_type }}
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ListEnvironmentResourcesResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_resourcefiles_list_environment_resources(
Tesla.Env.client(),
String.t(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListEnvironmentResourcesResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_resourcefiles_list_environment_resources(
connection,
parent,
type,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/resourcefiles/{type}", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1),
"type" => URI.encode(type, &(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.Apigee.V1.Model.GoogleCloudApigeeV1ListEnvironmentResourcesResponse{}]
)
end
@doc """
Updates a resource file. Specify the `Content-Type` as `application/octet-stream` or `multipart/form-data`. For more information about resource files, see [Resource files](https://cloud.google.com/apigee/docs/api-platform/develop/resource-files).
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the environment in the following format: `organizations/{org}/environments/{env}`.
* `type` (*type:* `String.t`) - Required. Resource file type. {{ resource_file_type }}
* `name` (*type:* `String.t`) - Required. ID of the resource file to update. Must match the regular expression: [a-zA-Z0-9:/\\\\!@#$%^&{}\\[\\]()+\\-=,.~'` ]{1,255}
* `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.Apigee.V1.Model.GoogleApiHttpBody.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ResourceFile{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_resourcefiles_update(
Tesla.Env.client(),
String.t(),
String.t(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ResourceFile.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_resourcefiles_update(
connection,
parent,
type,
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/{+parent}/resourcefiles/{type}/{name}", %{
"parent" => URI.encode(parent, &URI.char_unreserved?/1),
"type" => URI.encode(type, &URI.char_unreserved?/1),
"name" => URI.encode(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.Apigee.V1.Model.GoogleCloudApigeeV1ResourceFile{}]
)
end
@doc """
Lists all deployments of a shared flow in an environment.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name representing a shared flow in an environment in the following format: `organizations/{org}/environments/{env}/sharedflows/{sharedflow}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_sharedflows_deployments_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_sharedflows_deployments_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("/v1/{+parent}/deployments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}]
)
end
@doc """
Deploys a revision of a shared flow. If another revision of the same shared flow is currently deployed, set the `override` parameter to `true` to have this revision replace the currently deployed revision. You cannot use a shared flow until it has been deployed to an environment. For a request path `organizations/{org}/environments/{env}/sharedflows/{sf}/revisions/{rev}/deployments`, two permissions are required: * `apigee.deployments.create` on the resource `organizations/{org}/environments/{env}` * `apigee.sharedflowrevisions.deploy` on the resource `organizations/{org}/sharedflows/{sf}/revisions/{rev}`
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the shared flow revision to deploy in the following format: `organizations/{org}/environments/{env}/sharedflows/{sharedflow}/revisions/{rev}`
* `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").
* `:override` (*type:* `boolean()`) - Flag that specifies whether the new deployment replaces other deployed revisions of the shared flow in the environment. Set `override` to `true` to replace other deployed revisions. By default, `override` is `false` and the deployment is rejected if other revisions of the shared flow are deployed in the environment.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Deployment{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_sharedflows_revisions_deploy(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Deployment.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_sharedflows_revisions_deploy(
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,
:override => :query
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}/deployments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Deployment{}]
)
end
@doc """
Gets the deployment of a shared flow revision and actual state reported by runtime pods.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name representing a shared flow in an environment in the following format: `organizations/{org}/environments/{env}/sharedflows/{sharedflow}/revisions/{rev}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Deployment{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_sharedflows_revisions_get_deployments(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Deployment.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_sharedflows_revisions_get_deployments(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}/deployments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1Deployment{}]
)
end
@doc """
Undeploys a shared flow revision from an environment. For a request path `organizations/{org}/environments/{env}/sharedflows/{sf}/revisions/{rev}/deployments`, two permissions are required: * `apigee.deployments.delete` on the resource `organizations/{org}/environments/{env}` * `apigee.sharedflowrevisions.undeploy` on the resource `organizations/{org}/sharedflows/{sf}/revisions/{rev}`
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the shared flow revision to undeploy in the following format: `organizations/{org}/environments/{env}/sharedflows/{sharedflow}/revisions/{rev}`
* `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.Apigee.V1.Model.GoogleProtobufEmpty{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_sharedflows_revisions_undeploy(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleProtobufEmpty.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_sharedflows_revisions_undeploy(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}/deployments", %{
"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.Apigee.V1.Model.GoogleProtobufEmpty{}])
end
@doc """
Retrieve metrics grouped by dimensions. The types of metrics you can retrieve include traffic, message counts, API call latency, response size, and cache hits and counts. Dimensions let you view metrics in meaningful groups. The stats api does accept dimensions as path params. The dimensions are optional in which case the metrics are computed on the entire data for the given timerange.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The resource name for which the interactive query will be executed. Must be of the form `organizations/{organization_id}/environments/{environment_id/stats/{dimensions}` Dimensions let you view metrics in meaningful groupings. E.g. apiproxy, target_host. The value of dimensions should be comma separated list as shown below `organizations/{org}/environments/{env}/stats/apiproxy,request_verb`
* `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").
* `:accuracy` (*type:* `String.t`) - Legacy field: not used anymore. This field is present to support UI calls which still use this parameter.
* `:aggTable` (*type:* `String.t`) - If customers want to query custom aggregate tables, then this parameter can be used to specify the table name. If this parameter is skipped, then Edge Query will try to retrieve the data from fact tables which will be expensive.
* `:filter` (*type:* `String.t`) - Enables drill-down on specific dimension values
* `:limit` (*type:* `String.t`) - This parameter is used to limit the number of result items. Default and the max value is 14400.
* `:offset` (*type:* `String.t`) - Use offset with limit to enable pagination of results. For example, to display results 11-20, set limit to '10' and offset to '10'.
* `:realtime` (*type:* `boolean()`) - Legacy field: not used anymore.
* `:select` (*type:* `String.t`) - The select parameter contains a comma separated list of metrics. E.g. sum(message_count),sum(error_count)
* `:sonar` (*type:* `boolean()`) - This parameter routes the query to api monitoring service for last hour.
* `:sort` (*type:* `String.t`) - This parameter specifies if the sort order should be ascending or descending Supported values are DESC and ASC.
* `:sortby` (*type:* `String.t`) - Comma separated list of columns to sort the final result.
* `:timeRange` (*type:* `String.t`) - Time interval for the interactive query. Time range is specified as start~end E.g. 04/15/2017 00:00~05/15/2017 23:59
* `:timeUnit` (*type:* `String.t`) - A value of second, minute, hour, day, week, month. Time Unit specifies the granularity of metrics returned.
* `:topk` (*type:* `String.t`) - Take 'top k' results from results, for example, to return the top 5 results 'topk=5'.
* `:tsAscending` (*type:* `boolean()`) - Lists timestamps in ascending order if set to true. Recommend setting this value to true if you are using sortby with sort=DESC.
* `:tzo` (*type:* `String.t`) - This parameters contains the timezone offset value.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Stats{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_stats_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Stats.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_stats_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,
:accuracy => :query,
:aggTable => :query,
:filter => :query,
:limit => :query,
:offset => :query,
:realtime => :query,
:select => :query,
:sonar => :query,
:sort => :query,
:sortby => :query,
:timeRange => :query,
:timeUnit => :query,
:topk => :query,
:tsAscending => :query,
:tzo => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Stats{}])
end
@doc """
Creates a TargetServer in the specified environment.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The parent environment name under which the TargetServer will be created. Must be of the form `organizations/{org}/environments/{env}`.
* `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").
* `:name` (*type:* `String.t`) - Optional. The ID to give the TargetServer. This will overwrite the value in TargetServer.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_targetservers_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_targetservers_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:name => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/targetservers", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer{}]
)
end
@doc """
Deletes a TargetServer from an environment. Returns the deleted TargetServer resource.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the TargetServer to delete. Must be of the form `organizations/{org}/environments/{env}/targetservers/{target_server_id}`.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_targetservers_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_targetservers_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer{}]
)
end
@doc """
Gets a TargetServer resource.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the TargetServer to get. Must be of the form `organizations/{org}/environments/{env}/targetservers/{target_server_id}`.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_targetservers_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_targetservers_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer{}]
)
end
@doc """
Updates an existing TargetServer. Note that this operation has PUT semantics; it will replace the entirety of the existing TargetServer with the resource in the request body.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the TargetServer to replace. Must be of the form `organizations/{org}/environments/{env}/targetservers/{target_server_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.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_environments_targetservers_update(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_environments_targetservers_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/{+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.Apigee.V1.Model.GoogleCloudApigeeV1TargetServer{}]
)
end
@doc """
Submit a query at host level to be processed in the background. If the submission of the query succeeds, the API returns a 201 status and an ID that refer to the query. In addition to the HTTP status 201, the `state` of "enqueued" means that the request succeeded.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The parent resource name. Must be of the form `organizations/{org}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Query.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQuery{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_host_queries_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQuery.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_host_queries_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/hostQueries", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQuery{}]
)
end
@doc """
Get status of a query submitted at host level. If the query is still in progress, the `state` is set to "running" After the query has completed successfully, `state` is set to "completed"
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the asynchronous query to get. Must be of the form `organizations/{org}/queries/{queryId}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQuery{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_host_queries_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQuery.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_host_queries_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQuery{}]
)
end
@doc """
After the query is completed, use this API to retrieve the results. If the request succeeds, and there is a non-zero result set, the result is downloaded to the client as a zipped JSON file. The name of the downloaded file will be: OfflineQueryResult-.zip Example: `OfflineQueryResult-9cfc0d85-0f30-46d6-ae6f-318d0cb961bd.zip`
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the asynchronous query result to get. Must be of the form `organizations/{org}/queries/{queryId}/result`.
* `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.Apigee.V1.Model.GoogleApiHttpBody{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_host_queries_get_result(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_host_queries_get_result(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleApiHttpBody{}])
end
@doc """
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the asynchronous query result view to get. Must be of the form `organizations/{org}/queries/{queryId}/resultView`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQueryResultView{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_host_queries_get_result_view(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQueryResultView.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_host_queries_get_result_view(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1AsyncQueryResultView{}]
)
end
@doc """
Return a list of Asynchronous Queries at host level.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The parent resource name. Must be of the form `organizations/{org}`.
* `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").
* `:dataset` (*type:* `String.t`) - Filter response list by dataset. Example: `api`, `mint`
* `:envgroupHostname` (*type:* `String.t`) - Required. Filter response list by hostname.
* `:from` (*type:* `String.t`) - Filter response list by returning asynchronous queries that created after this date time. Time must be in ISO date-time format like '2011-12-03T10:15:30Z'.
* `:inclQueriesWithoutReport` (*type:* `String.t`) - Flag to include asynchronous queries that don't have a report denifition.
* `:status` (*type:* `String.t`) - Filter response list by asynchronous query status.
* `:submittedBy` (*type:* `String.t`) - Filter response list by user who submitted queries.
* `:to` (*type:* `String.t`) - Filter response list by returning asynchronous queries that created before this date time. Time must be in ISO date-time format like '2011-12-03T10:16:30Z'.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListAsyncQueriesResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_host_queries_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListAsyncQueriesResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_host_queries_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,
:dataset => :query,
:envgroupHostname => :query,
:from => :query,
:inclQueriesWithoutReport => :query,
:status => :query,
:submittedBy => :query,
:to => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/hostQueries", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListAsyncQueriesResponse{}]
)
end
@doc """
Retrieve metrics grouped by dimensions in host level. The types of metrics you can retrieve include traffic, message counts, API call latency, response size, and cache hits and counts. Dimensions let you view metrics in meaningful groups. The stats api does accept dimensions as path params. The dimensions are optional in which case the metrics are computed on the entire data for the given timerange.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The resource name for which the interactive query will be executed. Must be of the form `organizations/{organization_id}/hostStats/{dimensions}`. Dimensions let you view metrics in meaningful groupings. E.g. apiproxy, target_host. The value of dimensions should be comma separated list as shown below `organizations/{org}/hostStats/apiproxy,request_verb`
* `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").
* `:accuracy` (*type:* `String.t`) - Legacy field: not used anymore.
* `:envgroupHostname` (*type:* `String.t`) - Required. The hostname for which the interactive query will be executed.
* `:filter` (*type:* `String.t`) - Enables drill-down on specific dimension values.
* `:limit` (*type:* `String.t`) - This parameter is used to limit the number of result items. Default and the max value is 14400.
* `:offset` (*type:* `String.t`) - Use offset with limit to enable pagination of results. For example, to display results 11-20, set limit to '10' and offset to '10'.
* `:realtime` (*type:* `boolean()`) - Legacy field: not used anymore.
* `:select` (*type:* `String.t`) - The select parameter contains a comma separated list of metrics. E.g. sum(message_count),sum(error_count)
* `:sort` (*type:* `String.t`) - This parameter specifies if the sort order should be ascending or descending Supported values are DESC and ASC.
* `:sortby` (*type:* `String.t`) - Comma separated list of columns to sort the final result.
* `:timeRange` (*type:* `String.t`) - Time interval for the interactive query. Time range is specified as start~end E.g. 04/15/2017 00:00~05/15/2017 23:59
* `:timeUnit` (*type:* `String.t`) - A value of second, minute, hour, day, week, month. Time Unit specifies the granularity of metrics returned.
* `:topk` (*type:* `String.t`) - Take 'top k' results from results, for example, to return the top 5 results 'topk=5'.
* `:tsAscending` (*type:* `boolean()`) - Lists timestamps in ascending order if set to true. Recommend setting this value to true if you are using sortby with sort=DESC.
* `:tzo` (*type:* `String.t`) - This parameters contains the timezone offset value.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Stats{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_host_stats_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Stats.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_host_stats_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,
:accuracy => :query,
:envgroupHostname => :query,
:filter => :query,
:limit => :query,
:offset => :query,
:realtime => :query,
:select => :query,
:sort => :query,
:sortby => :query,
:timeRange => :query,
:timeUnit => :query,
:topk => :query,
:tsAscending => :query,
:tzo => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Stats{}])
end
@doc """
Creates an Apigee runtime instance. The instance is accessible from the authorized network configured on the organization. **Note:** Not supported for Apigee hybrid.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization. Use the following structure in your request: `organizations/{org}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Instance.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_create(connection, parent, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/instances", %{
"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.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Deletes an Apigee runtime instance. The instance stops serving requests and the runtime data is deleted. **Note:** Not supported for Apigee hybrid.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the instance. Use the following structure in your request: `organizations/{org}/instances/{instance}`.
* `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.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_delete(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Gets the details for an Apigee runtime instance. **Note:** Not supported for Apigee hybrid.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the instance. Use the following structure in your request: `organizations/{org}/instances/{instance}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1Instance{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Instance.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1Instance{}])
end
@doc """
Lists all Apigee runtime instances for the organization. **Note:** Not supported for Apigee hybrid.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization. Use the following structure in your request: `organizations/{org}`.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - Maximum number of instances to return. Defaults to 25.
* `:pageToken` (*type:* `String.t`) - Page token, returned from a previous ListInstances call, that you can use to retrieve the next page of content.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListInstancesResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_list(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListInstancesResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_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("/v1/{+parent}/instances", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListInstancesResponse{}]
)
end
@doc """
Reports the latest status for a runtime instance.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `instance` (*type:* `String.t`) - The name of the instance reporting this status. For SaaS the request will be rejected if no instance exists under this name. Format is organizations/{org}/instances/{instance}
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ReportInstanceStatusRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ReportInstanceStatusResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_report_status(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ReportInstanceStatusResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_report_status(
connection,
instance,
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/{+instance}:reportStatus", %{
"instance" => URI.encode(instance, &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.Apigee.V1.Model.GoogleCloudApigeeV1ReportInstanceStatusResponse{}]
)
end
@doc """
Creates a new attachment of an environment to an instance. **Note:** Not supported for Apigee hybrid.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the instance. Use the following structure in your request: `organizations/{org}/instances/{instance}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1InstanceAttachment.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_attachments_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_attachments_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/attachments", %{
"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.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Deletes an attachment. **Note:** Not supported for Apigee hybrid.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the attachment. Use the following structure in your request: `organizations/{org}/instances/{instance}/attachments/{attachment}`.
* `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.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_attachments_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_attachments_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Gets an attachment. **Note:** Not supported for Apigee hybrid.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the attachment. Use the following structure in your request: `organizations/{org}/instances/{instance}/attachments/{attachment}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1InstanceAttachment{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_attachments_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1InstanceAttachment.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_attachments_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1InstanceAttachment{}]
)
end
@doc """
Lists all attachments to an instance. **Note:** Not supported for Apigee hybrid.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization. Use the following structure in your request: `organizations/{org}/instances/{instance}`
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - Maximum number of instance attachments to return. Defaults to 25.
* `:pageToken` (*type:* `String.t`) - Page token, returned by a previous ListInstanceAttachments call, that you can use to retrieve the next page of content.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListInstanceAttachmentsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_attachments_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListInstanceAttachmentsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_attachments_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("/v1/{+parent}/attachments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListInstanceAttachmentsResponse{}]
)
end
@doc """
Creates a new canary evaluation for an organization.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the organization. Use the following structure in your request: `organizations/{org}/instances/{instance}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1CanaryEvaluation.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_canaryevaluations_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_canaryevaluations_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/canaryevaluations", %{
"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.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Gets a CanaryEvaluation for an organization.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the CanaryEvaluation. Use the following structure in your request: `organizations/{org}/instances/*/canaryevaluations/{evaluation}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1CanaryEvaluation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_canaryevaluations_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1CanaryEvaluation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_canaryevaluations_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1CanaryEvaluation{}]
)
end
@doc """
Activates the NAT address. The Apigee instance can now use this for Internet egress traffic. **Note:** Not supported for Apigee hybrid.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the nat address. Use the following structure in your request: `organizations/{org}/instances/{instances}/natAddresses/{nataddress}``
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ActivateNatAddressRequest.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_nat_addresses_activate(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_nat_addresses_activate(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}:activate", %{
"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.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Creates a NAT address. The address is created in the RESERVED state and a static external IP address will be provisioned. At this time, the instance will not use this IP address for Internet egress traffic. The address can be activated for use once any required firewall IP whitelisting has been completed. **Note:** Not supported for Apigee hybrid.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the instance. Use the following structure in your request: `organizations/{org}/instances/{instance}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1NatAddress.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_nat_addresses_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_nat_addresses_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/natAddresses", %{
"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.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Deletes the NAT address. Connections that are actively using the address are drained before it is removed. **Note:** Not supported for Apigee hybrid.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the nat address. Use the following structure in your request: `organizations/{org}/instances/{instances}/natAddresses/{nataddress}``
* `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.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_nat_addresses_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_nat_addresses_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Gets the details of a NAT address. **Note:** Not supported for Apigee hybrid.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the nat address. Use the following structure in your request: `organizations/{org}/instances/{instances}/natAddresses/{nataddress}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1NatAddress{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_nat_addresses_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1NatAddress.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_nat_addresses_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1NatAddress{}]
)
end
@doc """
Lists the NAT addresses for an Apigee instance. **Note:** Not supported for Apigee hybrid.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the instance. Use the following structure in your request: `organizations/{org}/instances/{instance}`
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:pageSize` (*type:* `integer()`) - Maximum number of natAddresses to return. Defaults to 25.
* `:pageToken` (*type:* `String.t`) - Page token, returned from a previous ListNatAddresses call, that you can use to retrieve the next page of content.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListNatAddressesResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_instances_nat_addresses_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListNatAddressesResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_instances_nat_addresses_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("/v1/{+parent}/natAddresses", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListNatAddressesResponse{}]
)
end
@doc """
Creates a key value map in an organization.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The name of the organization in which to create the key value map file. Must be of the form `organizations/{organization}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_keyvaluemaps_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_keyvaluemaps_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/keyvaluemaps", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap{}]
)
end
@doc """
Delete a key value map in an organization.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the key value map. Must be of the form `organizations/{organization}/keyvaluemaps/{keyvaluemap}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_keyvaluemaps_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_keyvaluemaps_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1KeyValueMap{}]
)
end
@doc """
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - The name of the operation resource.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_operations_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_operations_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleLongrunningOperation{}])
end
@doc """
Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding allows API services to override the binding to use different resource name schemes, such as `users/*/operations`. To override the binding, API services can add a binding such as `"/v1/{name=users/*}/operations"` to their service configuration. For backwards compatibility, the default name includes the operations collection id, however overriding users must ensure the name binding is the parent resource, without the operations collection id.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - The name of the operation's parent resource.
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:filter` (*type:* `String.t`) - The standard list filter.
* `:pageSize` (*type:* `integer()`) - The standard list page size.
* `:pageToken` (*type:* `String.t`) - The standard list page token.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleLongrunningListOperationsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_operations_list(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleLongrunningListOperationsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_operations_list(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:filter => :query,
:pageSize => :query,
:pageToken => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}/operations", %{
"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.Apigee.V1.Model.GoogleLongrunningListOperationsResponse{}]
)
end
@doc """
This api is similar to GetHostStats except that the response is less verbose.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The resource name for which the interactive query will be executed. Must be of the form `organizations/{organization_id}/optimizedHostStats/{dimensions}`. Dimensions let you view metrics in meaningful groupings. E.g. apiproxy, target_host. The value of dimensions should be comma separated list as shown below `organizations/{org}/optimizedHostStats/apiproxy,request_verb`
* `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").
* `:accuracy` (*type:* `String.t`) - Legacy field: not used anymore.
* `:envgroupHostname` (*type:* `String.t`) - Required. The hostname for which the interactive query will be executed.
* `:filter` (*type:* `String.t`) - Enables drill-down on specific dimension values.
* `:limit` (*type:* `String.t`) - This parameter is used to limit the number of result items. Default and the max value is 14400.
* `:offset` (*type:* `String.t`) - Use offset with limit to enable pagination of results. For example, to display results 11-20, set limit to '10' and offset to '10'.
* `:realtime` (*type:* `boolean()`) - Legacy field: not used anymore.
* `:select` (*type:* `String.t`) - Required. The select parameter contains a comma separated list of metrics. E.g. sum(message_count),sum(error_count)
* `:sort` (*type:* `String.t`) - This parameter specifies if the sort order should be ascending or descending Supported values are DESC and ASC.
* `:sortby` (*type:* `String.t`) - Comma separated list of columns to sort the final result.
* `:timeRange` (*type:* `String.t`) - Required. Time interval for the interactive query. Time range is specified as start~end. E.g 04/15/2017 00:00~05/15/2017 23:59.
* `:timeUnit` (*type:* `String.t`) - A value of second, minute, hour, day, week, month. Time Unit specifies the granularity of metrics returned.
* `:topk` (*type:* `String.t`) - Take 'top k' results from results, for example, to return the top 5 results 'topk=5'.
* `:tsAscending` (*type:* `boolean()`) - Lists timestamps in ascending order if set to true. Recommend setting this value to true if you are using sortby with sort=DESC.
* `:tzo` (*type:* `String.t`) - This parameters contains the timezone offset value.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1OptimizedStats{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_optimized_host_stats_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1OptimizedStats.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_optimized_host_stats_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,
:accuracy => :query,
:envgroupHostname => :query,
:filter => :query,
:limit => :query,
:offset => :query,
:realtime => :query,
:select => :query,
:sort => :query,
:sortby => :query,
:timeRange => :query,
:timeUnit => :query,
:topk => :query,
:tsAscending => :query,
:tzo => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1OptimizedStats{}]
)
end
@doc """
Creates a Custom Report for an Organization. A Custom Report provides Apigee Customers to create custom dashboards in addition to the standard dashboards which are provided. The Custom Report in its simplest form contains specifications about metrics, dimensions and filters. It is important to note that the custom report by itself does not provide an executable entity. The Edge UI converts the custom report definition into an analytics query and displays the result in a chart.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The parent organization name under which the Custom Report will be created. Must be of the form: `organizations/{organization_id}/reports`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1CustomReport.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1CustomReport{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_reports_create(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1CustomReport.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_reports_create(connection, parent, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/reports", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1CustomReport{}]
)
end
@doc """
Deletes an existing custom report definition
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Custom Report name of the form: `organizations/{organization_id}/reports/{report_name}`
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeleteCustomReportResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_reports_delete(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeleteCustomReportResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_reports_delete(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeleteCustomReportResponse{}]
)
end
@doc """
Retrieve a custom report definition.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Custom Report name of the form: `organizations/{organization_id}/reports/{report_name}`
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1CustomReport{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_reports_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1CustomReport.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_reports_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1CustomReport{}]
)
end
@doc """
Return a list of Custom Reports
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The parent organization name under which the API product will be listed `organizations/{organization_id}/reports`
* `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").
* `:expand` (*type:* `boolean()`) - Set to 'true' to get expanded details about each custom report.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListCustomReportsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_reports_list(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListCustomReportsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_reports_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,
:expand => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/reports", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListCustomReportsResponse{}]
)
end
@doc """
Update an existing custom report definition
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Custom Report name of the form: `organizations/{organization_id}/reports/{report_name}`
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1CustomReport.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1CustomReport{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_reports_update(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1CustomReport.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_reports_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/{+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.Apigee.V1.Model.GoogleCloudApigeeV1CustomReport{}]
)
end
@doc """
Uploads a ZIP-formatted shared flow configuration bundle to an organization. If the shared flow already exists, this creates a new revision of it. If the shared flow does not exist, this creates it. Once imported, the shared flow revision must be deployed before it can be accessed at runtime. The size limit of a shared flow bundle is 15 MB.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The name of the parent organization under which to create the shared flow. Must be of the form: `organizations/{organization_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").
* `:action` (*type:* `String.t`) - Required. Must be set to either `import` or `validate`.
* `:name` (*type:* `String.t`) - Required. The name to give the shared flow
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlowRevision{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sharedflows_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlowRevision.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sharedflows_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:action => :query,
:name => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/sharedflows", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlowRevision{}]
)
end
@doc """
Deletes a shared flow and all it's revisions. The shared flow must be undeployed before you can delete it.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. shared flow name of the form: `organizations/{organization_id}/sharedflows/{shared_flow_id}`
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlow{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sharedflows_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlow.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sharedflows_delete(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlow{}]
)
end
@doc """
Gets a shared flow by name, including a list of its revisions.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the shared flow to get. Must be of the form: `organizations/{organization_id}/sharedflows/{shared_flow_id}`
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlow{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sharedflows_get(Tesla.Env.client(), String.t(), keyword(), keyword()) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlow.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sharedflows_get(connection, name, optional_params \\ [], opts \\ []) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlow{}]
)
end
@doc """
Lists all shared flows in the organization.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. The name of the parent organization under which to get shared flows. Must be of the form: `organizations/{organization_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").
* `:includeMetaData` (*type:* `boolean()`) - Indicates whether to include shared flow metadata in the response.
* `:includeRevisions` (*type:* `boolean()`) - Indicates whether to include a list of revisions in the response.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListSharedFlowsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sharedflows_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListSharedFlowsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sharedflows_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,
:includeMetaData => :query,
:includeRevisions => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+parent}/sharedflows", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListSharedFlowsResponse{}]
)
end
@doc """
Lists all deployments of a shared flow.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the shared flow for which to return deployment information in the following format: `organizations/{org}/sharedflows/{sharedflow}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sharedflows_deployments_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sharedflows_deployments_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("/v1/{+parent}/deployments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}]
)
end
@doc """
Deletes a shared flow and all associated policies, resources, and revisions. You must undeploy the shared flow before deleting it.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the shared flow revision to delete. Must be of the form: `organizations/{organization_id}/sharedflows/{shared_flow_id}/revisions/{revision_id}`
* `optional_params` (*type:* `keyword()`) - Optional parameters
* `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
* `:access_token` (*type:* `String.t`) - OAuth access token.
* `:alt` (*type:* `String.t`) - Data format for response.
* `:callback` (*type:* `String.t`) - JSONP
* `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
* `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
* `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
* `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
* `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
* `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlowRevision{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sharedflows_revisions_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlowRevision.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sharedflows_revisions_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlowRevision{}]
)
end
@doc """
Gets a revision of a shared flow. If `format=bundle` is passed, it instead outputs a shared flow revision as a ZIP-formatted bundle of code and config files.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the shared flow revision to get. Must be of the form: `organizations/{organization_id}/sharedflows/{shared_flow_id}/revisions/{revision_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").
* `:format` (*type:* `String.t`) - Specify `bundle` to export the contents of the shared flow bundle. Otherwise, the bundle metadata is returned.
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleApiHttpBody{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sharedflows_revisions_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sharedflows_revisions_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,
:format => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleApiHttpBody{}])
end
@doc """
Updates a shared flow revision. This operation is only allowed on revisions which have never been deployed. After deployment a revision becomes immutable, even if it becomes undeployed. The payload is a ZIP-formatted shared flow. Content type must be either multipart/form-data or application/octet-stream.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. The name of the shared flow revision to update. Must be of the form: `organizations/{organization_id}/sharedflows/{shared_flow_id}/revisions/{revision_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").
* `:validate` (*type:* `boolean()`) - Ignored. All uploads are validated regardless of the value of this field. It is kept for compatibility with existing APIs. Must be `true` or `false` if provided.
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleApiHttpBody.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlowRevision{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sharedflows_revisions_update_shared_flow_revision(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlowRevision.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sharedflows_revisions_update_shared_flow_revision(
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,
:validate => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1SharedFlowRevision{}]
)
end
@doc """
Lists all deployments of a shared flow revision.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the API proxy revision for which to return deployment information in the following format: `organizations/{org}/sharedflows/{sharedflow}/revisions/{rev}`.
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sharedflows_revisions_deployments_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sharedflows_revisions_deployments_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("/v1/{+parent}/deployments", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListDeploymentsResponse{}]
)
end
@doc """
Creates a new category on the portal.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the portal. Use the following structure in your request: `organizations/{org}/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").
* `:body` (*type:* `GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiCategoryData.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiCategory{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sites_apicategories_create(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiCategory.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sites_apicategories_create(
connection,
parent,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:post)
|> Request.url("/v1/{+parent}/apicategories", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ApiCategory{}]
)
end
@doc """
Deletes a category from the portal.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the category. Use the following structure in your request: `organizations/{org}/sites/{site}/apicategories/{apicategory}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ApiResponseWrapper{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sites_apicategories_delete(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiResponseWrapper.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sites_apicategories_delete(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:delete)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiResponseWrapper{}]
)
end
@doc """
Gets a category on the portal.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the category. Use the following structure in your request: `organizations/{org}/sites/{site}/apicategories/{apicategory}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ApiCategory{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sites_apicategories_get(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiCategory.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sites_apicategories_get(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query
}
request =
Request.new()
|> Request.method(:get)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiCategory{}]
)
end
@doc """
Lists the categories on the portal.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `parent` (*type:* `String.t`) - Required. Name of the portal. Use the following structure in your request: `organizations/{org}/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.Apigee.V1.Model.GoogleCloudApigeeV1ListApiCategoriesResponse{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sites_apicategories_list(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ListApiCategoriesResponse.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sites_apicategories_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("/v1/{+parent}/apicategories", %{
"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.Apigee.V1.Model.GoogleCloudApigeeV1ListApiCategoriesResponse{}]
)
end
@doc """
Updates a category on the portal.
## Parameters
* `connection` (*type:* `GoogleApi.Apigee.V1.Connection.t`) - Connection to server
* `name` (*type:* `String.t`) - Required. Name of the category. Use the following structure in your request: `organizations/{org}/sites/{site}/apicategories/{apicategory}`
* `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.Apigee.V1.Model.GoogleCloudApigeeV1ApiCategoryData.t`) -
* `opts` (*type:* `keyword()`) - Call options
## Returns
* `{:ok, %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiCategory{}}` on success
* `{:error, info}` on failure
"""
@spec apigee_organizations_sites_apicategories_patch(
Tesla.Env.client(),
String.t(),
keyword(),
keyword()
) ::
{:ok, GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiCategory.t()}
| {:ok, Tesla.Env.t()}
| {:error, any()}
def apigee_organizations_sites_apicategories_patch(
connection,
name,
optional_params \\ [],
opts \\ []
) do
optional_params_config = %{
:"$.xgafv" => :query,
:access_token => :query,
:alt => :query,
:callback => :query,
:fields => :query,
:key => :query,
:oauth_token => :query,
:prettyPrint => :query,
:quotaUser => :query,
:uploadType => :query,
:upload_protocol => :query,
:body => :body
}
request =
Request.new()
|> Request.method(:patch)
|> Request.url("/v1/{+name}", %{
"name" => URI.encode(name, &URI.char_unreserved?/1)
})
|> Request.add_optional_params(optional_params_config, optional_params)
|> Request.library_version(@library_version)
connection
|> Connection.execute(request)
|> Response.decode(
opts ++ [struct: %GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1ApiCategory{}]
)
end
end
| 47.312746 | 1,691 | 0.622502 |
ff84418f1a60f0b317461af148fc7ea8f53a3c52 | 4,988 | ex | Elixir | lib/web/controllers/export_controller.ex | raphpap/accent | 1669582c72f1e0f30e78f02ad2be3e674929a4cb | [
"BSD-3-Clause"
] | null | null | null | lib/web/controllers/export_controller.ex | raphpap/accent | 1669582c72f1e0f30e78f02ad2be3e674929a4cb | [
"BSD-3-Clause"
] | null | null | null | lib/web/controllers/export_controller.ex | raphpap/accent | 1669582c72f1e0f30e78f02ad2be3e674929a4cb | [
"BSD-3-Clause"
] | null | null | null | defmodule Accent.ExportController do
use Plug.Builder
import Canary.Plugs
import Accent.Plugs.RevisionIdFromProjectLanguage
alias Accent.Scopes.Document, as: DocumentScope
alias Accent.Scopes.Revision, as: RevisionScope
alias Accent.Scopes.Translation, as: Scope
alias Accent.Scopes.Version, as: VersionScope
alias Accent.{
Document,
Language,
Project,
Repo,
Revision,
Translation,
Version
}
plug(Plug.Assign, %{canary_action: :export_revision})
plug(:load_resource, model: Project, id_name: "project_id")
plug(:load_resource, model: Language, id_name: "language", id_field: "slug")
plug(:fetch_revision_id_from_project_language)
plug(:load_resource, model: Revision, id_name: "revision_id", preload: :language)
plug(:fetch_order)
plug(:fetch_document)
plug(:fetch_version)
plug(:fetch_translations)
plug(:fetch_master_revision)
plug(:fetch_master_translations)
plug(:fetch_rendered_document)
plug(:index)
@doc """
Export a revision to a file
## Endpoint
GET /export
### Required params
- `project_id`
- `language`
- `document_format`
- `document_path`
### Optional params
- `order_by`
- `inline_render`
### Response
#### Success
`200` - A file containing the rendered document.
#### Error
- `404` Unknown revision id.
"""
def index(conn = %{query_params: %{"inline_render" => "true"}}, _) do
conn
|> put_resp_header("content-type", "text/plain")
|> send_resp(:ok, conn.assigns[:document].render)
end
def index(conn, _) do
file =
[
System.tmp_dir(),
Accent.Utils.SecureRandom.urlsafe_base64(16)
]
|> Path.join()
:ok = File.write(file, conn.assigns[:document].render)
conn
|> put_resp_header("content-disposition", "inline; filename=\"#{conn.params["document_path"]}\"")
|> send_file(200, file)
end
defp fetch_order(conn = %{params: %{"order_by" => ""}}, _), do: assign(conn, :order, "index")
defp fetch_order(conn = %{params: %{"order_by" => order}}, _), do: assign(conn, :order, order)
defp fetch_order(conn, _), do: assign(conn, :order, "index")
defp fetch_translations(conn = %{assigns: %{document: document, order: order, revision: revision, version: version}}, _) do
translations =
Translation
|> Scope.active()
|> Scope.from_document(document.id)
|> Scope.from_revision(revision.id)
|> Scope.from_version(version && version.id)
|> Scope.parse_order(order)
|> Repo.all()
assign(conn, :translations, translations)
end
defp fetch_master_revision(conn = %{assigns: %{project: project}}, _) do
revision =
project
|> Ecto.assoc(:revisions)
|> RevisionScope.master()
|> Repo.one()
|> Repo.preload(:language)
assign(conn, :master_revision, revision)
end
defp fetch_master_translations(conn = %{assigns: %{revision: %{master: true}, translations: translations}}, _) do
assign(conn, :master_translations, translations)
end
defp fetch_master_translations(conn = %{assigns: %{document: document, version: version, master_revision: master_revision}}, _) do
translations =
Translation
|> Scope.active()
|> Scope.from_document(document.id)
|> Scope.from_revision(master_revision.id)
|> Scope.from_version(version && version.id)
|> Repo.all()
assign(conn, :master_translations, translations)
end
defp fetch_document(conn = %{params: params, assigns: %{project: project}}, _) do
Document
|> DocumentScope.from_project(project.id)
|> DocumentScope.from_path(params["document_path"])
|> Repo.one()
|> case do
document = %Document{} ->
document = Map.put(document, :format, params["document_format"])
assign(conn, :document, document)
_ ->
Accent.ErrorController.handle_not_found(conn)
end
end
defp fetch_version(conn = %{params: %{"version" => version_param}, assigns: %{project: project}}, _) do
Version
|> VersionScope.from_project(project.id)
|> VersionScope.from_tag(version_param)
|> Repo.one()
|> case do
version = %Version{} ->
assign(conn, :version, version)
_ ->
Accent.ErrorController.handle_not_found(conn)
end
end
defp fetch_version(conn, _), do: assign(conn, :version, nil)
defp fetch_rendered_document(
conn = %{assigns: %{master_revision: master_revision, master_translations: master_translations, translations: translations, revision: revision, document: document}},
_
) do
%{render: render} =
Accent.TranslationsRenderer.render(%{
master_translations: master_translations,
master_revision: master_revision,
translations: translations,
language: revision.language,
document: document
})
document = Map.put(document, :render, render)
assign(conn, :document, document)
end
end
| 28.180791 | 174 | 0.660385 |
ff8482a1dbd24c01ebcb9ef6fc908a9324ae59a5 | 7,030 | ex | Elixir | lib/goldie/components/socket_handler.ex | scatterbrain/goldie | db649f9555d453541d01d0707d86b41f41156640 | [
"MIT"
] | null | null | null | lib/goldie/components/socket_handler.ex | scatterbrain/goldie | db649f9555d453541d01d0707d86b41f41156640 | [
"MIT"
] | null | null | null | lib/goldie/components/socket_handler.ex | scatterbrain/goldie | db649f9555d453541d01d0707d86b41f41156640 | [
"MIT"
] | null | null | null | defmodule Goldie.Component.SocketHandler do
use Goldie.Component
alias Goldie.Event
require Logger
use Bitwise
## pings sent every KEEPALIVE_INTERVAL to prevent stale sockets
@keepalive_interval 30000
@socket_keepalive_length 90000 ##If we don't get socket messages for 90 seconds, disconnect
@socket_keepalive_interval 5000 ##Check if we have received messages every 5 seconds
@msg_id_length 4 ##bytes- uint 32 bit value
@nonce_bytes_length 33 ##bytes
@hmac_bytes_length 11 ##bytes
@compress_threshold_bytes 512
@ckey <<48,168,223,40,213,245,25,36,115,66,70,149,127,121,245,188,77,50,54,111>> #Client key
@skey <<170,59,187,127,112,41,118,62,24,236,86,74,226,21,193,181,157,150,112,47>> #Server key
@doc """
Send a message to caller's own socket
"""
@spec send_socket(map) :: :ok
def send_socket(msg) do
Event.send_event(self(), {:socket_send, msg})
end
@spec setup(Goldie.Player) :: {:ok, Goldie.Player}
def setup(state) do
state = %Goldie.Player { state |
msg_sent_uncompressed: 0,
msg_sent_compressed: 0,
socket_keepalive_timestamp: Goldie.Utils.timestamp_epoch(),
last_msg_id: {0, 0, nil}
}
state = state
|> setup_protocol_integrity
|> setup_connection
{:ok, state}
end
@doc """
Event Handler: Receive a TCP message
"""
@spec handle_event(Event.t, pid, Goldie.Player) :: {:ok|:stop, Event.t, Goldie.Player}
def handle_event({:socket_receive, packet} = _event, _from, %{ :entity => entity } = state) do
<<msg_id :: little-unsigned-integer-size(32), hmac :: binary-size(@hmac_bytes_length), xorred_msg_data :: binary>> = packet
{:ok, msg} = xorred_msg_data
|> xor_cipher(hmac)
|> :erlang.list_to_binary
|> Goldie.Message.decode
Logger.debug("[SOCKET RECEIVE #{entity.id}]: #{inspect msg}")
Event.send_event(self(), {String.to_atom(msg._cmd), msg})
##TODO We need to send ping ack at the latest 2 seconds after receiving this message if no natural
## message traffic is happening (player is idling)
msg_arrival_timestamp = Goldie.Utils.timestamp_ms()
{_, _, backup_timer_ref} = state.last_msg_id
new_backup_timer_ref = case backup_timer_ref do
nil ->
:erlang.send_after(2000, self(), {:ping_backup_timer_timeout})
_ ->
backup_timer_ref
end
{:ok, {:socket_receive, msg}, %Goldie.Player { state |
last_client_hmac: hmac,
socket_keepalive_timestamp: Goldie.Utils.timestamp_epoch(),
last_msg_id: {msg_id, msg_arrival_timestamp, new_backup_timer_ref}
}}
end
@doc """
Event Handler: Send a TCP message
"""
def handle_event({:socket_send, msg} = _event, _from, %{ :socket => socket, :transport => transport } = state) do
state = send(transport, socket, msg, state.entity.id, state)
{:ok, {:socket_send, msg}, state}
end
@doc """
Event Handler sink
"""
def handle_event(event, _from, state) do
{:ok, event, state}
end
# setups the required state data for protocol integrity
@spec setup_protocol_integrity(Goldie.Player) :: Goldie.Player
defp setup_protocol_integrity(state) do
nonce = :crypto.rand_bytes(@nonce_bytes_length)
%Goldie.Player{ state | nonce: nonce, last_client_hmac: <<>>, last_server_hmac: <<>> }
end
## sends the initial connection message to the client.
## The connection between the server and the client is ready after the
## client receives this message.
@spec setup_connection(Goldie.Player) :: Goldie.Player
defp setup_connection(%Goldie.Player { :transport => transport, :socket => socket } = state) do
send(transport, socket, Goldie.Message.handshake(), "Unknown", state)
end
## Send a message to the client's socket.
@spec send(term, port, map, binary, Goldie.Player) :: Goldie.Player
defp send(transport, socket, message, player_name, state) do
Logger.debug("[SOCKET SEND #{player_name}]: #{inspect message}")
case Goldie.Message.encode(message) do
{:ok, packet} ->
compressed = packet
|> :erlang.iolist_to_binary
|> compress
key = [@skey, state.nonce]
data = [state.last_server_hmac, compressed]
hmac = :crypto.sha_mac(key, data, @hmac_bytes_length)
xorred = xor_cipher(compressed, hmac)
## If this is the first message, send Nonce
packet_without_ping = case state.last_server_hmac do
<<>> ->
[state.nonce, hmac, xorred]
_ ->
[hmac, xorred]
end
{last_msg_id, last_msg_arrival_timestamp, ping_ack_backup_timer} = state.last_msg_id
## Mark if this message has ping information or not
has_ping_info = last_msg_id != 0
packet_with_ping = case has_ping_info do
true ->
now_ms = Goldie.Utils.timestamp_ms()
server_delay = now_ms - last_msg_arrival_timestamp
ping_header = << <<1>> :: binary, last_msg_id :: little-unsigned-size(32), server_delay :: little-unsigned-integer-size(16)>>
[ping_header | packet_without_ping]
false ->
ping_header = <<0>>
[ping_header | packet_without_ping]
end
:ok = do_send(transport, socket, packet_with_ping)
case ping_ack_backup_timer do
nil ->
:ok
_ ->
## We can cancel the backup timer because we send normal traffic
:erlang.cancel_timer(ping_ack_backup_timer)
end
uncompressed_size = byte_size(packet)
compressed_size = byte_size(compressed)
uncompressed_sum = state.msg_sent_uncompressed + uncompressed_size
compressed_sum = state.msg_sent_compressed + compressed_size
%Goldie.Player { state |
:last_server_hmac => hmac,
:msg_sent_uncompressed => uncompressed_sum,
:msg_sent_compressed => compressed_sum,
:last_msg_id => {0, 0, nil}
}
_ ->
exit({:error, {:failed_encode, message}})
end
end
defp do_send(transport, socket, _) when is_nil(transport) or is_nil(socket) do
#For testing purposes
:ok
end
defp do_send(transport, socket, packet) do
transport.send(socket, packet)
end
## compresses using deflate
@spec compress(binary) :: binary
defp compress(data) do
case byte_size(data) > @compress_threshold_bytes do
true ->
compressed = :zlib.zip(data)
<< <<1>> :: binary, compressed :: binary>>
_ ->
<< <<0>> :: binary, data :: binary>>
end
end
## xor cipher the data with the key
@spec xor_cipher(binary, binary) :: binary()
def xor_cipher(xdata, key) do
key_size = byte_size(key)
sequence = 0..byte_size(xdata) - 1
Enum.map(sequence, fn(index) ->
item = :binary.at(xdata, index)
key_index = rem(index, key_size)
key_item = :binary.at(key, key_index)
item ^^^ key_item
end)
end
end
| 34.80198 | 137 | 0.646515 |
ff848cadc83cb47cae4761d963fbb88bb039ee9e | 1,883 | exs | Elixir | test/formatters/ecto/changeset_test.exs | floatingpointio/delirium_tremexs | 6b7bb1918b7a8a02c4af3b7e266e30b67eba59bc | [
"MIT"
] | 4 | 2019-09-24T09:32:31.000Z | 2021-02-21T13:13:18.000Z | test/formatters/ecto/changeset_test.exs | floatingpointio/delirium_tremexs | 6b7bb1918b7a8a02c4af3b7e266e30b67eba59bc | [
"MIT"
] | 2 | 2019-02-20T14:24:43.000Z | 2019-05-08T08:54:49.000Z | test/formatters/ecto/changeset_test.exs | floatingpointio/delirium_tremexs | 6b7bb1918b7a8a02c4af3b7e266e30b67eba59bc | [
"MIT"
] | 1 | 2020-02-19T19:43:11.000Z | 2020-02-19T19:43:11.000Z | defmodule DeliriumTremex.Formatters.Ecto.ChangesetTest do
use ExUnit.Case
doctest DeliriumTremex
alias DeliriumTremex.Formatters.Ecto.Changeset
describe "nested changeset formatting" do
test "error nested inside map returns error inside suberrors list" do
data = {:address, %{address_line1: [{"can't be blank", [validation: :required]}]}}
formatted_data = Changeset.format(data)
assert formatted_data[:suberrors] == [
%{
full_messages: ["Address_line1 can't be blank"],
index: nil,
key: :address_line1,
message: "Address_line1 can't be blank",
messages: ["can't be blank"],
suberrors: nil
}
]
end
test "error nested inside list of maps returns error inside nested suberrors list" do
data =
{:comments,
[
%{
user_id: [
{"does not exist",
[
constraint: :foreign,
constraint_name: "comments_user_id_fkey"
]}
]
},
%{}
]}
formatted_data = Changeset.format(data)
assert formatted_data[:suberrors] == [
%{
full_messages: nil,
index: nil,
key: :comments,
message: "Comments errors",
messages: nil,
suberrors: [
%{
full_messages: ["User_id does not exist"],
index: nil,
key: :user_id,
message: "User_id does not exist",
messages: ["does not exist"],
suberrors: nil
}
]
}
]
end
end
end
| 29.421875 | 89 | 0.462029 |
ff849078d1a055e25d62d272fb83d1d2c32ad8bc | 67 | ex | Elixir | lib/portfolio_web/views/layout_view.ex | abullard/portfolio | fb3190b5b1d1f0ca6cda394e312fbb2d1a908a23 | [
"MIT"
] | null | null | null | lib/portfolio_web/views/layout_view.ex | abullard/portfolio | fb3190b5b1d1f0ca6cda394e312fbb2d1a908a23 | [
"MIT"
] | 11 | 2020-04-29T10:28:20.000Z | 2020-04-29T11:03:13.000Z | portfolio/lib/portfolio_web/views/layout_view.ex | JackMaarek/portfolio | 4423e67df870b14228edbc9e4ce3f3cdf1bccc2d | [
"MIT"
] | null | null | null | defmodule PortfolioWeb.LayoutView do
use PortfolioWeb, :view
end
| 16.75 | 36 | 0.820896 |
ff84e4d3277f4e6ebeece29b10ac9f8372e81746 | 830 | ex | Elixir | lib/chat_api_web/controllers/user_settings_controller.ex | ZmagoD/papercups | dff9a5822b809edc4fd8ecf198566f9b14ab613f | [
"MIT"
] | 4,942 | 2020-07-20T22:35:28.000Z | 2022-03-31T15:38:51.000Z | lib/chat_api_web/controllers/user_settings_controller.ex | ZmagoD/papercups | dff9a5822b809edc4fd8ecf198566f9b14ab613f | [
"MIT"
] | 552 | 2020-07-22T01:39:04.000Z | 2022-02-01T00:26:35.000Z | lib/chat_api_web/controllers/user_settings_controller.ex | ZmagoD/papercups | dff9a5822b809edc4fd8ecf198566f9b14ab613f | [
"MIT"
] | 396 | 2020-07-22T19:27:48.000Z | 2022-03-31T05:25:24.000Z | defmodule ChatApiWeb.UserSettingsController do
use ChatApiWeb, :controller
alias ChatApi.Users
action_fallback ChatApiWeb.FallbackController
@spec show(Plug.Conn.t(), map()) :: Plug.Conn.t()
def show(conn, _params) do
with %{id: user_id} <- conn.assigns.current_user do
user_settings = Users.get_user_settings(user_id)
render(conn, "show.json", user_settings: user_settings)
end
end
@spec update(Plug.Conn.t(), map()) :: Plug.Conn.t()
def update(conn, %{"user_settings" => user_settings_params}) do
with %{id: user_id} <- conn.assigns.current_user,
params <- Map.merge(user_settings_params, %{"user_id" => user_id}),
{:ok, user_settings} <- Users.update_user_settings(user_id, params) do
render(conn, "show.json", user_settings: user_settings)
end
end
end
| 33.2 | 79 | 0.693976 |
ff8502576f2cd0e092588aad21c417a08ac8b514 | 2,180 | ex | Elixir | clients/display_video/lib/google_api/display_video/v1/model/line_item_flight.ex | MasashiYokota/elixir-google-api | 975dccbff395c16afcb62e7a8e411fbb58e9ab01 | [
"Apache-2.0"
] | null | null | null | clients/display_video/lib/google_api/display_video/v1/model/line_item_flight.ex | MasashiYokota/elixir-google-api | 975dccbff395c16afcb62e7a8e411fbb58e9ab01 | [
"Apache-2.0"
] | null | null | null | clients/display_video/lib/google_api/display_video/v1/model/line_item_flight.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.DisplayVideo.V1.Model.LineItemFlight do
@moduledoc """
Settings that control the active duration of a line item.
## Attributes
* `dateRange` (*type:* `GoogleApi.DisplayVideo.V1.Model.DateRange.t`, *default:* `nil`) - The flight start and end dates of the line item. They are resolved relative to the parent advertiser's time zone. * Required when flight_date_type is `LINE_ITEM_FLIGHT_DATE_TYPE_CUSTOM`. Output only otherwise. * When creating a new flight, both `start_date` and `end_date` must be in the future. * An existing flight with a `start_date` in the past has a mutable `end_date` but an immutable `start_date`. * `end_date` must be the `start_date` or later, both before the year 2037.
* `flightDateType` (*type:* `String.t`, *default:* `nil`) - Required. The type of the line item's flight dates.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:dateRange => GoogleApi.DisplayVideo.V1.Model.DateRange.t(),
:flightDateType => String.t()
}
field(:dateRange, as: GoogleApi.DisplayVideo.V1.Model.DateRange)
field(:flightDateType)
end
defimpl Poison.Decoder, for: GoogleApi.DisplayVideo.V1.Model.LineItemFlight do
def decode(value, options) do
GoogleApi.DisplayVideo.V1.Model.LineItemFlight.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.DisplayVideo.V1.Model.LineItemFlight do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 43.6 | 573 | 0.744954 |
ff8512df68f4a69e2dd5b76d2218c98948563543 | 1,243 | exs | Elixir | code/general/ets_vs_gen_server_write.exs | TheMaikXX/fast-elixir | 0e622c3f8bb4751fd023fde1e34ec78cf4337dfd | [
"CC0-1.0"
] | 1,154 | 2017-05-04T10:18:30.000Z | 2022-03-29T06:43:28.000Z | code/general/ets_vs_gen_server_write.exs | TheMaikXX/fast-elixir | 0e622c3f8bb4751fd023fde1e34ec78cf4337dfd | [
"CC0-1.0"
] | 13 | 2017-05-22T21:58:36.000Z | 2022-02-25T15:52:12.000Z | code/general/ets_vs_gen_server_write.exs | TheMaikXX/fast-elixir | 0e622c3f8bb4751fd023fde1e34ec78cf4337dfd | [
"CC0-1.0"
] | 35 | 2017-05-27T17:55:07.000Z | 2022-03-13T18:55:48.000Z | defmodule RetrieveState.Fast do
def put_state(ets_pid, state) do
:ets.insert(ets_pid, {:stored_state, state})
end
end
defmodule StateHolder do
use GenServer
def init(_), do: {:ok, %{}}
def start_link(state \\ []), do: GenServer.start_link(__MODULE__, state, name: __MODULE__)
def put_state(value), do: GenServer.call(__MODULE__, {:put_state, value})
def handle_call({:put_state, value}, _from, state), do: {:reply, true, Map.put(state, :stored_state, value)}
end
defmodule RetrieveState.Medium do
def put_state(value) do
StateHolder.put_state(value)
end
end
defmodule RetrieveState.Slow do
def put_state(value) do
:persistent_term.put(:stored_state, value)
end
end
defmodule RetrieveState.Benchmark do
def benchmark do
ets_pid = :ets.new(:state_store, [:set, :public])
StateHolder.start_link()
Benchee.run(
%{
"ets table" => fn -> RetrieveState.Fast.put_state(ets_pid, :returned_value) end,
"gen server" => fn -> RetrieveState.Medium.put_state(:returned_value) end,
"persistent term" => fn -> RetrieveState.Slow.put_state(:returned_value) end
},
time: 10,
print: [fast_warning: false]
)
end
end
RetrieveState.Benchmark.benchmark()
| 25.367347 | 110 | 0.693484 |
ff855d392e7a8603bdde41e40163600ef57b853a | 1,122 | ex | Elixir | clients/groups_migration/lib/google_api/groups_migration/v1/connection.ex | pojiro/elixir-google-api | 928496a017d3875a1929c6809d9221d79404b910 | [
"Apache-2.0"
] | 1 | 2021-12-20T03:40:53.000Z | 2021-12-20T03:40:53.000Z | clients/groups_migration/lib/google_api/groups_migration/v1/connection.ex | pojiro/elixir-google-api | 928496a017d3875a1929c6809d9221d79404b910 | [
"Apache-2.0"
] | 1 | 2020-08-18T00:11:23.000Z | 2020-08-18T00:44:16.000Z | clients/groups_migration/lib/google_api/groups_migration/v1/connection.ex | pojiro/elixir-google-api | 928496a017d3875a1929c6809d9221d79404b910 | [
"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.GroupsMigration.V1.Connection do
@moduledoc """
Handle Tesla connections for GoogleApi.GroupsMigration.V1.
"""
@type t :: Tesla.Env.client()
use GoogleApi.Gax.Connection,
scopes: [
# Manage messages in groups on your domain
"https://www.googleapis.com/auth/apps.groups.migration"
],
otp_app: :google_api_groups_migration,
base_url: "https://groupsmigration.googleapis.com/"
end
| 34 | 74 | 0.743316 |
ff858899a2d617e3ba4662994600aa05bdfaca4e | 1,976 | ex | Elixir | apps/andi/lib/andi_web/live/helpers/metadata_form_helpers.ex | calebcarroll1/smartcitiesdata | b0f03496f6c592c82ba14aebf6c5996311cf3cd0 | [
"Apache-2.0"
] | 26 | 2019-09-20T23:54:45.000Z | 2020-08-20T14:23:32.000Z | apps/andi/lib/andi_web/live/helpers/metadata_form_helpers.ex | calebcarroll1/smartcitiesdata | b0f03496f6c592c82ba14aebf6c5996311cf3cd0 | [
"Apache-2.0"
] | 757 | 2019-08-15T18:15:07.000Z | 2020-09-18T20:55:31.000Z | apps/andi/lib/andi_web/live/helpers/metadata_form_helpers.ex | calebcarroll1/smartcitiesdata | b0f03496f6c592c82ba14aebf6c5996311cf3cd0 | [
"Apache-2.0"
] | 9 | 2019-11-12T16:43:46.000Z | 2020-03-25T16:23:16.000Z | defmodule AndiWeb.Helpers.MetadataFormHelpers do
@moduledoc """
This module contains dropdown options and text helpers shared between the submission and
curator versions of the metadata form.
"""
alias AndiWeb.Views.Options
alias Andi.Services.OrgStore
alias Andi.Schemas.User
def map_to_dropdown_options(options) do
Enum.map(options, fn {actual_value, description} -> [key: description, value: actual_value] end)
end
def top_level_selector_label_class(source_format) when source_format in ["text/xml", "xml"], do: "label label--required"
def top_level_selector_label_class(_), do: "label"
def rating_selection_prompt(), do: "Please Select a Value"
def get_language_options(), do: map_to_dropdown_options(Options.language())
def get_level_of_access_options, do: map_to_dropdown_options(Options.level_of_access())
def get_rating_options(), do: map_to_dropdown_options(Options.ratings())
def get_source_type_options(), do: map_to_dropdown_options(Options.source_type())
def get_org_options(), do: Options.organizations(OrgStore.get_all())
def get_owner_options(), do: Options.users(User.get_all())
def get_source_format_options(source_type) when source_type in ["remote", "host"] do
Options.source_format_extended()
end
def get_source_format_options(_), do: Options.source_format()
def get_language(nil), do: "english"
def get_language(lang), do: lang
def get_license(nil), do: "https://creativecommons.org/licenses/by/4.0/"
def get_license(license), do: license
def keywords_to_string(nil), do: ""
def keywords_to_string(keywords) when is_binary(keywords), do: keywords
def keywords_to_string(keywords), do: Enum.join(keywords, ", ")
def safe_calendar_value(nil), do: nil
def safe_calendar_value(%{calendar: _, day: day, month: month, year: year}) do
Timex.parse!("#{year}-#{month}-#{day}", "{YYYY}-{M}-{D}")
|> NaiveDateTime.to_date()
end
def safe_calendar_value(value), do: value
end
| 39.52 | 122 | 0.75253 |
ff85a94563a985a0933964d07e3611838a1d99a1 | 3,088 | ex | Elixir | lib/sequential_store.ex | chewy-soft/elixir-sequential-store | d79475e4f9974eb2f040ba6e33868b483f3a7fd3 | [
"MIT"
] | null | null | null | lib/sequential_store.ex | chewy-soft/elixir-sequential-store | d79475e4f9974eb2f040ba6e33868b483f3a7fd3 | [
"MIT"
] | null | null | null | lib/sequential_store.ex | chewy-soft/elixir-sequential-store | d79475e4f9974eb2f040ba6e33868b483f3a7fd3 | [
"MIT"
] | null | null | null | defmodule SequentialStore do
defstruct block_size: nil, store_size: nil, separator: nil, store_path: nil, loop: false
def create(%__MODULE__{} = config, name) do
if exists?(config, name) do
{:error, :eexist}
else
SequentialStore.File.allocate_file(path(config, name), file_size(config))
end
end
def open(config, name) do
SequentialStore.File.open(path(config, name))
end
def close({:file_descriptor, _, _} = fp) do
SequentialStore.File.close(fp)
end
def drop(config, name) do
SequentialStore.File.delete_file(path(config, name))
end
def exists?(config, name) do
File.exists?(path(config, name))
end
def read(config, name, index) do
read(config, name, index, 1)
end
def read(config, name_or_fp, index, len)
when is_number(index) and is_number(len) do
path_or_fp = if is_binary(name_or_fp), do: path(config, name_or_fp), else: name_or_fp
index = if config.loop, do: rem(index, config.store_size), else: index
if config.loop and config.store_size < index + len do
len_to_last = config.store_size - index
len_from_start = index + len - config.store_size
{:ok, pre} = do_read(config, path_or_fp, index, len_to_last)
{:ok, post} = do_read(config, path_or_fp, 0, len_from_start)
{:ok, pre <> config.separator <> post}
else
do_read(config, path_or_fp, index, len)
end
end
defp do_read(config, path_or_fp, index, len) do
sep_size = byte_size(config.separator)
byte_length = (config.block_size + sep_size) * len - sep_size
SequentialStore.File.read_file(path_or_fp, offset(config, index), byte_length)
end
def write(config, name_or_fp, index, binary)
when is_number(index) and is_binary(binary) do
path_or_fp = if is_binary(name_or_fp), do: path(config, name_or_fp), else: name_or_fp
index = if config.loop, do: rem(index, config.store_size), else: index
cond do
is_binary(name_or_fp) and not exists?(config, name_or_fp) ->
{:error, :file_notfound}
index > config.store_size - 1 ->
{:error, :store_exceeded}
index < 0 ->
{:error, :invalid_index}
byte_size(binary) > config.block_size ->
{:error, :toolong}
true ->
do_write(config, path_or_fp, index, binary)
end
end
defp do_write(config, path_or_fp, index, block) do
pad = String.duplicate(" ", config.block_size - byte_size(block))
block = block <> pad
block = block <> config.separator
SequentialStore.File.write_file(path_or_fp, offset(config, index), block)
end
@doc """
this func is dev usage only
"""
def offset(config, index) do
sep_size = config.separator |> byte_size()
index * (config.block_size + sep_size)
end
def info(config, name) do
SequentialStore.DevTool.info(path(config, name))
end
defp path(config, name) do
Path.join([config.store_path, name])
end
defp file_size(%__MODULE__{} = config) do
sep_size = config.separator |> byte_size()
(config.block_size + sep_size) * config.store_size
end
end
| 29.132075 | 90 | 0.672927 |
ff85be0618e3409c6b7e06a47d75c88c8d6a699b | 84 | ex | Elixir | lib/sleep.ex | hh-ex/kata-sleepsort | b22126fcfcaf443b291ef6e31eb60d52422fcb50 | [
"MIT"
] | null | null | null | lib/sleep.ex | hh-ex/kata-sleepsort | b22126fcfcaf443b291ef6e31eb60d52422fcb50 | [
"MIT"
] | null | null | null | lib/sleep.ex | hh-ex/kata-sleepsort | b22126fcfcaf443b291ef6e31eb60d52422fcb50 | [
"MIT"
] | null | null | null | defmodule Sleep do
def sort(i) do
# your wonderful code goes here
end
end
| 10.5 | 35 | 0.678571 |
ff85cb5884279d1d09345e8e96acb8c6d1f53cd7 | 170 | ex | Elixir | lib/ex_taxjar/validations.ex | cas27/ex_taxjar | 507d474dbd7e72a21b2e14194b39170b535913bc | [
"MIT"
] | 6 | 2018-04-13T17:50:57.000Z | 2019-09-08T01:25:56.000Z | lib/ex_taxjar/validations.ex | cas27/ex_taxjar | 507d474dbd7e72a21b2e14194b39170b535913bc | [
"MIT"
] | null | null | null | lib/ex_taxjar/validations.ex | cas27/ex_taxjar | 507d474dbd7e72a21b2e14194b39170b535913bc | [
"MIT"
] | 1 | 2021-06-24T20:11:16.000Z | 2021-06-24T20:11:16.000Z | defmodule ExTaxjar.Validations do
def validate(vat) do
{:ok, %{body: body}} = ExTaxjar.get("/validation", [], params: %{vat: vat})
body["validation"]
end
end
| 24.285714 | 79 | 0.641176 |
ff85fa23977a71ab01b627f9309b74eed9c598fe | 301 | exs | Elixir | test/plugin_test.exs | amco/exrm | 2600bffb92c6e129dd513978578992fc64d9ce08 | [
"MIT"
] | 986 | 2015-01-01T13:20:41.000Z | 2021-09-03T02:18:55.000Z | test/plugin_test.exs | amco/exrm | 2600bffb92c6e129dd513978578992fc64d9ce08 | [
"MIT"
] | 332 | 2015-01-02T09:17:25.000Z | 2018-04-06T22:32:25.000Z | test/plugin_test.exs | amco/exrm | 2600bffb92c6e129dd513978578992fc64d9ce08 | [
"MIT"
] | 132 | 2015-01-05T06:11:21.000Z | 2019-10-31T13:31:12.000Z | defmodule PluginTest do
use ExUnit.Case
alias ReleaseManager.Utils
test "can fetch a list of plugins" do
active = [
ReleaseManager.Plugin.Appups,
ReleaseManager.Plugin.Consolidation,
] |> Enum.sort
assert active == ReleaseManager.Plugin.load_all |> Enum.sort
end
end
| 21.5 | 64 | 0.707641 |
ff85fd902015dc2bf5500727334006465aaf545d | 602 | ex | Elixir | lib/vex/struct.ex | emjrdev/vex | c4a863ed39d4723ccf45231252d81c0f0df45de1 | [
"MIT"
] | 560 | 2015-01-12T00:07:27.000Z | 2022-02-07T03:21:44.000Z | lib/vex/struct.ex | emjrdev/vex | c4a863ed39d4723ccf45231252d81c0f0df45de1 | [
"MIT"
] | 55 | 2015-02-16T18:59:57.000Z | 2021-12-23T12:34:25.000Z | lib/vex/struct.ex | emjrdev/vex | c4a863ed39d4723ccf45231252d81c0f0df45de1 | [
"MIT"
] | 63 | 2015-02-12T03:49:50.000Z | 2021-12-12T00:11:01.000Z | defmodule Vex.Struct do
@moduledoc false
defmacro __using__(_) do
quote do
@vex_validations %{}
@before_compile unquote(__MODULE__)
import unquote(__MODULE__)
def valid?(self), do: Vex.valid?(self)
end
end
defmacro __before_compile__(_) do
quote do
def __vex_validations__(), do: @vex_validations
require Vex.Extract.Struct
Vex.Extract.Struct.for_struct()
end
end
defmacro validates(name, validations \\ []) do
quote do
@vex_validations Map.put(@vex_validations, unquote(name), unquote(validations))
end
end
end
| 21.5 | 85 | 0.67608 |
ff8618afef79a6ba5c24916940eaea497eeab6fc | 2,602 | exs | Elixir | test/date_time_parser_test.exs | mrwizard82d1/time_calc_ex | c2f2127330f821a02a7686a7b1baca3304afbd65 | [
"MIT"
] | null | null | null | test/date_time_parser_test.exs | mrwizard82d1/time_calc_ex | c2f2127330f821a02a7686a7b1baca3304afbd65 | [
"MIT"
] | null | null | null | test/date_time_parser_test.exs | mrwizard82d1/time_calc_ex | c2f2127330f821a02a7686a7b1baca3304afbd65 | [
"MIT"
] | null | null | null | defmodule DateTimeParserTest do
use ExUnit.Case
test "parse date text when date valid" do
year = NaiveDateTime.local_now().year
assert TimeCalc.DateTimeParser.parse_date_text("05-Apr") == {:ok, Date.new!(year, 4, 5)}
assert TimeCalc.DateTimeParser.parse_date_text("01-Aug") == {:ok, Date.new!(year, 8, 1)}
assert TimeCalc.DateTimeParser.parse_date_text("01-Dec") == {:ok, Date.new!(year, 12, 1)}
assert TimeCalc.DateTimeParser.parse_date_text("28-Feb") == {:ok, Date.new!(year, 2, 28)}
assert TimeCalc.DateTimeParser.parse_date_text("31-Jul") == {:ok, Date.new!(year, 7, 31)}
assert TimeCalc.DateTimeParser.parse_date_text("31-Dec") == {:ok, Date.new!(year, 12, 31)}
end
test "parse date text when date invalid" do
year = NaiveDateTime.local_now().year
assert TimeCalc.DateTimeParser.parse_date_text("05-Mat") == {:error, "Unrecognized short month, 'Mat'."}
assert TimeCalc.DateTimeParser.parse_date_text("00-Aug") == Date.new(year, 8, 0)
assert TimeCalc.DateTimeParser.parse_date_text("31-Mar") == Date.new(year, 3, 31)
end
test "parse time text when time valid" do
assert TimeCalc.DateTimeParser.parse_time_text("0000") ==
{:ok, %TimeCalc.DateTimeParser.ParsedTime{time: Time.new!(0, 0, 0)}}
assert TimeCalc.DateTimeParser.parse_time_text("2217") ==
{:ok, %TimeCalc.DateTimeParser.ParsedTime{time: Time.new!(22, 17, 0)}}
assert TimeCalc.DateTimeParser.parse_time_text("0859") ==
{:ok, %TimeCalc.DateTimeParser.ParsedTime{time: Time.new!(8, 59, 0)}}
assert TimeCalc.DateTimeParser.parse_time_text("2400") ==
{:ok, %TimeCalc.DateTimeParser.ParsedTime{time: Time.new!(0, 0, 0), is_midnight: true}}
end
test "parse time text when time invalid" do
assert TimeCalc.DateTimeParser.parse_time_text("000") == {:error, "Time must have exactly 4 digits but was '000'"}
assert TimeCalc.DateTimeParser.parse_time_text("01132") == {:error, "Time must have exactly 4 digits but was '01132'"}
assert TimeCalc.DateTimeParser.parse_time_text("-124") ==
{:error, "Hour must be between 0 and 24, inclusive, but was '-1'"}
assert TimeCalc.DateTimeParser.parse_time_text("2503") ==
{:error, "Hour must be between 0 and 24, inclusive, but was '25'"}
assert TimeCalc.DateTimeParser.parse_time_text("03-1") ==
{:error, "Minute must be between 0 and 59, inclusive, but was '-1'"}
assert TimeCalc.DateTimeParser.parse_time_text("1760") ==
{:error, "Minute must be between 0 and 59, inclusive, but was '60'"}
end
end
| 56.565217 | 122 | 0.682168 |
ff863c8a6ba30bb9954f95f1b10bf81e2bb52350 | 2,220 | ex | Elixir | lib/calc.ex | leonardofirmeza/calc-elixir | baf1d457643df020602e52c3e9b5d001146a3b29 | [
"MIT"
] | 1 | 2021-09-24T11:59:05.000Z | 2021-09-24T11:59:05.000Z | lib/calc.ex | leonardofirmeza/calc-elixir | baf1d457643df020602e52c3e9b5d001146a3b29 | [
"MIT"
] | null | null | null | lib/calc.ex | leonardofirmeza/calc-elixir | baf1d457643df020602e52c3e9b5d001146a3b29 | [
"MIT"
] | null | null | null | defmodule Calc do
@moduledoc """
Documentation for `Calc`.
"""
def min(x, y) do
if x < y do
x
else
y
end
end
def min3(x, y, z) do
Calc.min(x, Calc.min(y, z))
end
def somat(n) when n > 0 do
somat(n - 1) + n
end
def somat(0) do
0
end
def fat(n) when n > 1 do
fat(n - 1) * n
end
def fat(1) do
1
end
def fat(0) do
1
end
def somat2(n) do
if n == 0 do
0
else
somat2(n - 1) + n
end
end
def fat2(n) do
if n == 1 do
1
else
if n == 0 do
1
else
fat2(n - 1) * n
end
end
end
def fatduplo(n) when n > 1 do
fatduplo(n - 2) * n
end
def fatduplo(1) do
1
end
def fattriplo(n) when n > 3 do
fattriplo(n - 3) * n
end
def fattriplo(3) do
3
end
def somat3(n) when n > 0 do
n + somat3(n - 1)
end
def somat3(0) do
0
end
def fat3(n) when n > 1 do
n * fat3(n - 1)
end
def fat3(1) do
1
end
def fat3(0) do
1
end
def mult(x, y) do
if x == 0 || y == 0 do
0
else
x * y
end
end
def potencia_de_2(i) when i > 1 do
2 * potencia_de_2(i - 1)
end
def potencia_de_2(1) do
2
end
def hanoi(n) when n > 1 do
2 * hanoi(n - 1) + 1
end
def hanoi(0) do
0
end
def hanoi(1) do
1
end
def serie(n) when n > 1 do
3 * serie(n - 1) - 2
end
def serie(0) do
0
end
def serie(1) do
3
end
def negativo(n) do
n - 2 * n
end
def coprimo(x, y) do
if (rem(x, 2) == 1 || rem(x, 3) == 1) && (rem(y, 2) == 1 || rem(y, 3) == 1) do
Verdadeiro
else
Falso
end
end
def sinal(x, y) do
if x > y do
1
else
if x < y do
-1
else
0
end
end
end
def hms_tempo(h, m, s) do
if h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59 do
h * 3600 + m * 60 + s
else
IO.puts("algum dado fornecido está incorreto")
end
end
def div84(n) do
if div(n, 8) == 4 do
Verdadeiro
else
Falso
end
end
def divx(n, d) do
if div(n, d) == 4 do
Verdadeiro
else
Falso
end
end
end
| 12.197802 | 82 | 0.461712 |
ff863cd80d792e21da0f3cd4b21df1968536f443 | 1,061 | exs | Elixir | test/views/layout_view_test.exs | octosteve/remote_retro | 3385b0db3c2daab934ce12a2f7642a5f10ac5147 | [
"MIT"
] | 523 | 2017-03-15T15:21:11.000Z | 2022-03-14T03:04:18.000Z | test/views/layout_view_test.exs | octosteve/remote_retro | 3385b0db3c2daab934ce12a2f7642a5f10ac5147 | [
"MIT"
] | 524 | 2017-03-16T18:31:09.000Z | 2022-02-26T10:02:06.000Z | test/views/layout_view_test.exs | octosteve/remote_retro | 3385b0db3c2daab934ce12a2f7642a5f10ac5147 | [
"MIT"
] | 60 | 2017-05-01T18:02:28.000Z | 2022-03-04T21:04:56.000Z | defmodule RemoteRetro.LayoutViewTest do
use RemoteRetroWeb.ConnCase, async: true
alias RemoteRetroWeb.LayoutView
test "app_js is served by the webpack dev server (at port 5001) in dev" do
Application.put_env(:remote_retro, :env, :dev)
conn = get(build_conn(), "/")
assert LayoutView.app_js(conn) =~ "localhost:5001/js/app.js"
Application.put_env(:remote_retro, :env, :test)
end
test "app_js is served by a default host at path js/app.js in other environments" do
conn = get(build_conn(), "/")
assert LayoutView.app_js(conn) == "/js/app.js"
end
test "app_css is served by the webpack dev server (at port 5001) in dev" do
Application.put_env(:remote_retro, :env, :dev)
conn = get(build_conn(), "/")
assert LayoutView.app_css(conn) =~ "localhost:5001/css/app.css"
Application.put_env(:remote_retro, :env, :test)
end
test "app_css is served by a default host at path css/app.css in other environments" do
conn = get(build_conn(), "/")
assert LayoutView.app_css(conn) == "/css/app.css"
end
end
| 36.586207 | 89 | 0.697455 |
ff8641e61d6b2d2f33f34263f2aa7fb08c4de428 | 3,621 | ex | Elixir | lib/exvcr/converter.ex | fastindian84/exvcr | b9e38de8379627b344cbc2d57bd1eab6d5c1b08a | [
"MIT"
] | null | null | null | lib/exvcr/converter.ex | fastindian84/exvcr | b9e38de8379627b344cbc2d57bd1eab6d5c1b08a | [
"MIT"
] | null | null | null | lib/exvcr/converter.ex | fastindian84/exvcr | b9e38de8379627b344cbc2d57bd1eab6d5c1b08a | [
"MIT"
] | null | null | null | defmodule ExVCR.Converter do
@moduledoc """
Provides helpers for adapter converters.
"""
defmacro __using__(_) do
quote do
@doc """
Parse string format into original request / response tuples.
"""
def convert_from_string(%{"request" => request, "response" => response}) do
%{ request: string_to_request(request), response: string_to_response(response) }
end
defoverridable [convert_from_string: 1]
@doc """
Parse request and response tuples into string format.
"""
def convert_to_string(request, response) do
%{ request: request_to_string(request), response: response_to_string(response) }
end
defoverridable [convert_to_string: 2]
def string_to_request(string) do
request = Enum.map(string, fn({x,y}) -> {String.to_atom(x),y} end) |> Enum.into(%{})
struct(ExVCR.Request, request)
end
defoverridable [string_to_request: 1]
def string_to_response(string), do: raise ExVCR.ImplementationMissingError
defoverridable [string_to_response: 1]
def request_to_string(request), do: raise ExVCR.ImplementationMissingError
defoverridable [request_to_string: 1]
def response_to_string(response), do: raise ExVCR.ImplementationMissingError
defoverridable [response_to_string: 1]
def parse_headers(headers) do
do_parse_headers(headers, [])
end
defoverridable [parse_headers: 1]
def do_parse_headers([], acc) do
Enum.reverse(acc)
end
def do_parse_headers([header|tail], acc) do
{key,value} = case is_map(header) do
true -> header |> Enum.to_list |> hd
false -> header
end
replaced_value = to_string(value) |> ExVCR.Filter.filter_sensitive_data
replaced_value = ExVCR.Filter.filter_request_header(to_string(key), to_string(replaced_value))
do_parse_headers(tail, [%{to_string(key) => replaced_value}|acc])
end
defoverridable [do_parse_headers: 2]
def parse_options(options) do
do_parse_options(options, [])
end
defoverridable [parse_options: 1]
def do_parse_options([], acc) do
Enum.reverse(acc) |> Enum.into(%{})
end
def do_parse_options([{key,value}|tail], acc) when is_function(value) do
do_parse_options(tail, acc)
end
def do_parse_options([{key,value}|tail], acc) do
replaced_value = atom_to_string(value) |> ExVCR.Filter.filter_sensitive_data
replaced_value = ExVCR.Filter.filter_request_option(to_string(key), atom_to_string(replaced_value))
do_parse_options(tail, [{to_string(key), replaced_value}|acc])
end
defoverridable [do_parse_options: 2]
def parse_url(url) do
to_string(url) |> ExVCR.Filter.filter_url_params
end
defoverridable [parse_url: 1]
def parse_keyword_list(params) do
Enum.map(params, fn({k,v}) -> {k,to_string(v)} end)
end
defoverridable [parse_keyword_list: 1]
def parse_request_body(:error), do: ""
def parse_request_body({:ok, body}) do
parse_request_body(body)
end
def parse_request_body(body) do
body_string = try do
to_string(body)
rescue
_e in Protocol.UndefinedError -> inspect(body)
end
ExVCR.Filter.filter_sensitive_data(body_string)
end
defoverridable [parse_request_body: 1]
defp atom_to_string(atom) do
if is_atom(atom) do
to_string(atom)
else
atom
end
end
end
end
end
| 32.330357 | 107 | 0.652306 |
ff8641f1d676852316db768771034163f3ff11eb | 498 | ex | Elixir | lib/mix/tasks/secrex.decrypt.ex | forzafootball/secrex | b0792efc3be87ddf239159a965c118f81cde04f6 | [
"0BSD"
] | 15 | 2020-09-20T09:22:41.000Z | 2022-03-29T04:35:47.000Z | lib/mix/tasks/secrex.decrypt.ex | forzafootball/secrex | b0792efc3be87ddf239159a965c118f81cde04f6 | [
"0BSD"
] | 2 | 2020-09-20T09:17:12.000Z | 2021-03-10T02:39:05.000Z | lib/mix/tasks/secrex.decrypt.ex | forzafootball/secrex | b0792efc3be87ddf239159a965c118f81cde04f6 | [
"0BSD"
] | 2 | 2021-07-02T12:50:47.000Z | 2021-11-11T05:08:30.000Z | defmodule Mix.Tasks.Secrex.Decrypt do
@moduledoc """
Decrypts secrets to the configured files.
"""
use Mix.Task
import Mix.Secrex
@shortdoc "Decrypts secrets to the configured files"
@impl true
def run(_args) do
key = encryption_key()
for path <- secret_files() do
enc_path = encrypted_path(path)
Mix.shell().info("Decrypting #{enc_path}")
File.write!(path, decrypt(enc_path, key))
end
Mix.shell().info("Files have been decrypted")
end
end
| 19.92 | 54 | 0.668675 |
ff864f2cbd44b45974158fcee33b927e0bcf2e73 | 96,936 | ex | Elixir | lib/elixir/lib/kernel.ex | montague/elixir | ff2138b05345d0b3136a374259e9c3ba7208e3da | [
"Apache-2.0"
] | null | null | null | lib/elixir/lib/kernel.ex | montague/elixir | ff2138b05345d0b3136a374259e9c3ba7208e3da | [
"Apache-2.0"
] | null | null | null | lib/elixir/lib/kernel.ex | montague/elixir | ff2138b05345d0b3136a374259e9c3ba7208e3da | [
"Apache-2.0"
] | null | null | null | # Use elixir_bootstrap module to be able to bootstrap Kernel.
# The bootstrap module provides simpler implementations of the
# functions removed, simple enough to bootstrap.
import Kernel, except: [@: 1, defmodule: 2, def: 1, def: 2, defp: 2,
defmacro: 1, defmacro: 2, defmacrop: 2]
import :elixir_bootstrap
defmodule Kernel do
@moduledoc """
`Kernel` provides the default macros and functions
Elixir imports into your environment. These macros and functions
can be skipped or cherry-picked via the `import` macro. For
instance, if you want to tell Elixir not to import the `if`
macro, you can do:
import Kernel, except: [if: 2]
Elixir also has special forms that are always imported and
cannot be skipped. These are described in `Kernel.SpecialForms`.
Some of the functions described in this module are inlined by
the Elixir compiler into their Erlang counterparts in the `:erlang`
module. Those functions are called BIFs (builtin internal functions)
in Erlang-land and they exhibit interesting properties, as some of
them are allowed in guards and others are used for compiler
optimizations.
Most of the inlined functions can be seen in effect when capturing
the function:
iex> &Kernel.is_atom/1
&:erlang.is_atom/1
Those functions will be explicitly marked in their docs as
"inlined by the compiler".
"""
## Delegations to Erlang with inlining (macros)
@doc """
Returns an integer or float which is the arithmetical absolute value of `number`.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> abs(-3.33)
3.33
iex> abs(-3)
3
"""
@spec abs(number) :: number
def abs(number) do
:erlang.abs(number)
end
@doc """
Invokes the given `fun` with the array of arguments `args`.
Inlined by the compiler.
## Examples
iex> apply(fn x -> x * 2 end, [2])
4
"""
@spec apply(fun, [any]) :: any
def apply(fun, args) do
:erlang.apply(fun, args)
end
@doc """
Invokes the given `fun` from `module` with the array of arguments `args`.
Inlined by the compiler.
## Examples
iex> apply(Enum, :reverse, [[1, 2, 3]])
[3, 2, 1]
"""
@spec apply(module, atom, [any]) :: any
def apply(module, fun, args) do
:erlang.apply(module, fun, args)
end
@doc """
Extracts the part of the binary starting at `start` with length `length`.
Binaries are zero-indexed.
If `start` or `length` reference in any way outside the binary, an
`ArgumentError` exception is raised.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> binary_part("foo", 1, 2)
"oo"
A negative `length` can be used to extract bytes that come *before* the byte
at `start`:
iex> binary_part("Hello", 5, -3)
"llo"
"""
@spec binary_part(binary, pos_integer, integer) :: binary
def binary_part(binary, start, length) do
:erlang.binary_part(binary, start, length)
end
@doc """
Returns an integer which is the size in bits of `bitstring`.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> bit_size(<<433::16, 3::3>>)
19
iex> bit_size(<<1, 2, 3>>)
24
"""
@spec bit_size(bitstring) :: non_neg_integer
def bit_size(bitstring) do
:erlang.bit_size(bitstring)
end
@doc """
Returns the number of bytes needed to contain `bitstring`.
That is, if the number of bits in `bitstring` is not divisible by 8, the
resulting number of bytes will be rounded up (by excess). This operation
happens in constant time.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> byte_size(<<433::16, 3::3>>)
3
iex> byte_size(<<1, 2, 3>>)
3
"""
@spec byte_size(binary) :: non_neg_integer
def byte_size(binary) do
:erlang.byte_size(binary)
end
@doc """
Performs an integer division.
Raises an `ArithmeticError` exception if one of the arguments is not an
integer.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> div(5, 2)
2
"""
@spec div(integer, integer) :: integer
def div(left, right) do
:erlang.div(left, right)
end
@doc """
Stops the execution of the calling process with the given reason.
Since evaluating this function causes the process to terminate,
it has no return value.
Inlined by the compiler.
## Examples
When a process reaches its end, by default it exits with
reason `:normal`. You can also call `exit/1` explicitly if you
want to terminate a process but not signal any failure:
exit(:normal)
In case something goes wrong, you can also use `exit/1` with
a different reason:
exit(:seems_bad)
If the exit reason is not `:normal`, all the processes linked to the process
that exited will crash (unless they are trapping exits).
## OTP exits
Exits are used by the OTP to determine if a process exited abnormally
or not. The following exits are considered "normal":
* `exit(:normal)`
* `exit(:shutdown)`
* `exit({:shutdown, term})`
Exiting with any other reason is considered abnormal and treated
as a crash. This means the default supervisor behaviour kicks in,
error reports are emitted, etc.
This behaviour is relied on in many different places. For example,
`ExUnit` uses `exit(:shutdown)` when exiting the test process to
signal linked processes, supervision trees and so on to politely
shutdown too.
## CLI exits
Building on top of the exit signals mentioned above, if the
process started by the command line exits with any of the three
reasons above, its exit is considered normal and the Operating
System process will exit with status 0.
It is, however, possible to customize the Operating System exit
signal by invoking:
exit({:shutdown, integer})
This will cause the OS process to exit with the status given by
`integer` while signaling all linked OTP processes to politely
shutdown.
Any other exit reason will cause the OS process to exit with
status `1` and linked OTP processes to crash.
"""
@spec exit(term) :: no_return
def exit(reason) do
:erlang.exit(reason)
end
@doc """
Returns the head of a list; raises `ArgumentError` if the list is empty.
Inlined by the compiler.
## Examples
iex> hd([1, 2, 3, 4])
1
"""
@spec hd(list) :: term
def hd(list) do
:erlang.hd(list)
end
@doc """
Returns `true` if `term` is an atom; otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
"""
@spec is_atom(term) :: boolean
def is_atom(term) do
:erlang.is_atom(term)
end
@doc """
Returns `true` if `term` is a binary; otherwise returns `false`.
A binary always contains a complete number of bytes.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> is_binary "foo"
true
iex> is_binary <<1::3>>
false
"""
@spec is_binary(term) :: boolean
def is_binary(term) do
:erlang.is_binary(term)
end
@doc """
Returns `true` if `term` is a bitstring (including a binary); otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> is_bitstring "foo"
true
iex> is_bitstring <<1::3>>
true
"""
@spec is_bitstring(term) :: boolean
def is_bitstring(term) do
:erlang.is_bitstring(term)
end
@doc """
Returns `true` if `term` is either the atom `true` or the atom `false` (i.e.,
a boolean); otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
"""
@spec is_boolean(term) :: boolean
def is_boolean(term) do
:erlang.is_boolean(term)
end
@doc """
Returns `true` if `term` is a floating point number; otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
"""
@spec is_float(term) :: boolean
def is_float(term) do
:erlang.is_float(term)
end
@doc """
Returns `true` if `term` is a function; otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
"""
@spec is_function(term) :: boolean
def is_function(term) do
:erlang.is_function(term)
end
@doc """
Returns `true` if `term` is a function that can be applied with `arity` number of arguments;
otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> is_function(fn(x) -> x * 2 end, 1)
true
iex> is_function(fn(x) -> x * 2 end, 2)
false
"""
@spec is_function(term, non_neg_integer) :: boolean
def is_function(term, arity) do
:erlang.is_function(term, arity)
end
@doc """
Returns `true` if `term` is an integer; otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
"""
@spec is_integer(term) :: boolean
def is_integer(term) do
:erlang.is_integer(term)
end
@doc """
Returns `true` if `term` is a list with zero or more elements; otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
"""
@spec is_list(term) :: boolean
def is_list(term) do
:erlang.is_list(term)
end
@doc """
Returns `true` if `term` is either an integer or a floating point number;
otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
"""
@spec is_number(term) :: boolean
def is_number(term) do
:erlang.is_number(term)
end
@doc """
Returns `true` if `term` is a pid (process identifier); otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
"""
@spec is_pid(term) :: boolean
def is_pid(term) do
:erlang.is_pid(term)
end
@doc """
Returns `true` if `term` is a port identifier; otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
"""
@spec is_port(term) :: boolean
def is_port(term) do
:erlang.is_port(term)
end
@doc """
Returns `true` if `term` is a reference; otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
"""
@spec is_reference(term) :: boolean
def is_reference(term) do
:erlang.is_reference(term)
end
@doc """
Returns `true` if `term` is a tuple; otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
"""
@spec is_tuple(term) :: boolean
def is_tuple(term) do
:erlang.is_tuple(term)
end
@doc """
Returns `true` if `term` is a map; otherwise returns `false`.
Allowed in guard tests. Inlined by the compiler.
"""
@spec is_map(term) :: boolean
def is_map(term) do
:erlang.is_map(term)
end
@doc """
Returns the length of `list`.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> length([1, 2, 3, 4, 5, 6, 7, 8, 9])
9
"""
@spec length(list) :: non_neg_integer
def length(list) do
:erlang.length(list)
end
@doc """
Returns an almost unique reference.
The returned reference will re-occur after approximately 2^82 calls;
therefore it is unique enough for practical purposes.
Inlined by the compiler.
## Examples
make_ref() #=> #Reference<0.0.0.135>
"""
@spec make_ref() :: reference
def make_ref() do
:erlang.make_ref()
end
@doc """
Returns the size of a map.
The size of a map is the number of key-value pairs that the map contains.
This operation happens in constant time.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> map_size(%{a: "foo", b: "bar"})
2
"""
@spec map_size(map) :: non_neg_integer
def map_size(map) do
:erlang.map_size(map)
end
@doc """
Returns the biggest of the two given terms according to
Erlang's term ordering. If the terms compare equal, the
first one is returned.
Inlined by the compiler.
## Examples
iex> max(1, 2)
2
iex> max(:a, :b)
:b
"""
@spec max(term, term) :: term
def max(first, second) do
:erlang.max(first, second)
end
@doc """
Returns the smallest of the two given terms according to
Erlang's term ordering. If the terms compare equal, the
first one is returned.
Inlined by the compiler.
## Examples
iex> min(1, 2)
1
iex> min("foo", "bar")
"bar"
"""
@spec min(term, term) :: term
def min(first, second) do
:erlang.min(first, second)
end
@doc """
Returns an atom representing the name of the local node.
If the node is not alive, `:nonode@nohost` is returned instead.
Allowed in guard tests. Inlined by the compiler.
"""
@spec node() :: node
def node do
:erlang.node
end
@doc """
Returns the node where the given argument is located.
The argument can be a pid, a reference, or a port.
If the local node is not alive, `:nonode@nohost` is returned.
Allowed in guard tests. Inlined by the compiler.
"""
@spec node(pid | reference | port) :: node
def node(arg) do
:erlang.node(arg)
end
@doc """
Computes the remainder of an integer division.
Raises an `ArithmeticError` exception if one of the arguments is not an
integer.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> rem(5, 2)
1
"""
@spec rem(integer, integer) :: integer
def rem(left, right) do
:erlang.rem(left, right)
end
@doc """
Rounds a number to the nearest integer.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> round(5.6)
6
iex> round(5.2)
5
iex> round(-9.9)
-10
"""
@spec round(number) :: integer
def round(number) do
:erlang.round(number)
end
@doc """
Sends a message to the given `dest` and returns the message.
`dest` may be a remote or local pid, a (local) port, a locally
registered name, or a tuple `{registered_name, node}` for a registered
name at another node.
Inlined by the compiler.
## Examples
iex> send self(), :hello
:hello
"""
@spec send(dest :: pid | port | atom | {atom, node}, msg) :: msg when msg: any
def send(dest, msg) do
:erlang.send(dest, msg)
end
@doc """
Returns the pid (process identifier) of the calling process.
Allowed in guard clauses. Inlined by the compiler.
"""
@spec self() :: pid
def self() do
:erlang.self()
end
@doc """
Spawns the given function and returns its pid.
Check the `Process` and `Node` modules for other functions
to handle processes, including spawning functions in nodes.
Inlined by the compiler.
## Examples
current = self()
child = spawn(fn -> send current, {self(), 1 + 2} end)
receive do
{^child, 3} -> IO.puts "Received 3 back"
end
"""
@spec spawn((() -> any)) :: pid
def spawn(fun) do
:erlang.spawn(fun)
end
@doc """
Spawns the given module and function passing the given args
and returns its pid.
Check the `Process` and `Node` modules for other functions
to handle processes, including spawning functions in nodes.
Inlined by the compiler.
## Examples
spawn(SomeModule, :function, [1, 2, 3])
"""
@spec spawn(module, atom, list) :: pid
def spawn(module, fun, args) do
:erlang.spawn(module, fun, args)
end
@doc """
Spawns the given function, links it to the current process and returns its pid.
Check the `Process` and `Node` modules for other functions
to handle processes, including spawning functions in nodes.
Inlined by the compiler.
## Examples
current = self()
child = spawn_link(fn -> send current, {self(), 1 + 2} end)
receive do
{^child, 3} -> IO.puts "Received 3 back"
end
"""
@spec spawn_link((() -> any)) :: pid
def spawn_link(fun) do
:erlang.spawn_link(fun)
end
@doc """
Spawns the given module and function passing the given args,
links it to the current process and returns its pid.
Check the `Process` and `Node` modules for other functions
to handle processes, including spawning functions in nodes.
Inlined by the compiler.
## Examples
spawn_link(SomeModule, :function, [1, 2, 3])
"""
@spec spawn_link(module, atom, list) :: pid
def spawn_link(module, fun, args) do
:erlang.spawn_link(module, fun, args)
end
@doc """
Spawns the given function, monitors it and returns its pid
and monitoring reference.
Check the `Process` and `Node` modules for other functions
to handle processes, including spawning functions in nodes.
Inlined by the compiler.
## Examples
current = self()
spawn_monitor(fn -> send current, {self(), 1 + 2} end)
"""
@spec spawn_monitor((() -> any)) :: {pid, reference}
def spawn_monitor(fun) do
:erlang.spawn_monitor(fun)
end
@doc """
Spawns the given module and function passing the given args,
monitors it and returns its pid and monitoring reference.
Check the `Process` and `Node` modules for other functions
to handle processes, including spawning functions in nodes.
Inlined by the compiler.
## Examples
spawn_monitor(SomeModule, :function, [1, 2, 3])
"""
@spec spawn_monitor(module, atom, list) :: {pid, reference}
def spawn_monitor(module, fun, args) do
:erlang.spawn_monitor(module, fun, args)
end
@doc """
A non-local return from a function. Check `Kernel.SpecialForms.try/1` for more information.
Inlined by the compiler.
"""
@spec throw(term) :: no_return
def throw(term) do
:erlang.throw(term)
end
@doc """
Returns the tail of a list. Raises `ArgumentError` if the list is empty.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> tl([1, 2, 3, :go])
[2, 3, :go]
"""
@spec tl(maybe_improper_list) :: maybe_improper_list
def tl(list) do
:erlang.tl(list)
end
@doc """
Returns the integer part of `number`.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> trunc(5.4)
5
iex> trunc(5.99)
5
"""
@spec trunc(number) :: integer
def trunc(number) do
:erlang.trunc(number)
end
@doc """
Returns the size of a tuple.
This operation happens in constant time.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> tuple_size {:a, :b, :c}
3
"""
@spec tuple_size(tuple) :: non_neg_integer
def tuple_size(tuple) do
:erlang.tuple_size(tuple)
end
@doc """
Arithmetic addition.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> 1 + 2
3
"""
@spec (number + number) :: number
def left + right do
:erlang.+(left, right)
end
@doc """
Arithmetic subtraction.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> 1 - 2
-1
"""
@spec (number - number) :: number
def left - right do
:erlang.-(left, right)
end
@doc """
Arithmetic unary plus.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> +1
1
"""
@spec (+number) :: number
def (+value) do
:erlang.+(value)
end
@doc """
Arithmetic unary minus.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> -2
-2
"""
@spec (-number) :: number
def (-value) do
:erlang.-(value)
end
@doc """
Arithmetic multiplication.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> 1 * 2
2
"""
@spec (number * number) :: number
def left * right do
:erlang.*(left, right)
end
@doc """
Arithmetic division.
The result is always a float. Use `div/2` and `rem/2` if you want
an integer division or the remainder.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> 1 / 2
0.5
iex> 2 / 1
2.0
"""
@spec (number / number) :: float
def left / right do
:erlang./(left, right)
end
@doc """
Concatenates two lists.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> [1] ++ [2, 3]
[1, 2, 3]
iex> 'foo' ++ 'bar'
'foobar'
"""
@spec (list ++ term) :: maybe_improper_list
def left ++ right do
:erlang.++(left, right)
end
@doc """
Removes the first occurrence of an item on the left list
for each item on the right.
Inlined by the compiler.
## Examples
iex> [1, 2, 3] -- [1, 2]
[3]
iex> [1, 2, 3, 2, 1] -- [1, 2, 2]
[3, 1]
"""
@spec (list -- list) :: list
def left -- right do
:erlang.--(left, right)
end
@doc """
Boolean not.
`arg` must be a boolean; if it's not, an `ArgumentError` exception is raised.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> not false
true
"""
@spec not(boolean) :: boolean
def not(arg) do
:erlang.not(arg)
end
@doc """
Returns `true` if left is less than right.
All terms in Elixir can be compared with each other.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> 1 < 2
true
"""
@spec (term < term) :: boolean
def left < right do
:erlang.<(left, right)
end
@doc """
Returns `true` if left is more than right.
All terms in Elixir can be compared with each other.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> 1 > 2
false
"""
@spec (term > term) :: boolean
def left > right do
:erlang.>(left, right)
end
@doc """
Returns `true` if left is less than or equal to right.
All terms in Elixir can be compared with each other.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> 1 <= 2
true
"""
@spec (term <= term) :: boolean
def left <= right do
:erlang."=<"(left, right)
end
@doc """
Returns `true` if left is more than or equal to right.
All terms in Elixir can be compared with each other.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> 1 >= 2
false
"""
@spec (term >= term) :: boolean
def left >= right do
:erlang.>=(left, right)
end
@doc """
Returns `true` if the two items are equal.
This operator considers 1 and 1.0 to be equal. For match
semantics, use `===` instead.
All terms in Elixir can be compared with each other.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> 1 == 2
false
iex> 1 == 1.0
true
"""
@spec (term == term) :: boolean
def left == right do
:erlang.==(left, right)
end
@doc """
Returns `true` if the two items are not equal.
This operator considers 1 and 1.0 to be equal. For match
comparison, use `!==` instead.
All terms in Elixir can be compared with each other.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> 1 != 2
true
iex> 1 != 1.0
false
"""
@spec (term != term) :: boolean
def left != right do
:erlang."/="(left, right)
end
@doc """
Returns `true` if the two items are match.
This operator gives the same semantics as the one existing in
pattern matching, i.e., `1` and `1.0` are equal, but they do
not match.
All terms in Elixir can be compared with each other.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> 1 === 2
false
iex> 1 === 1.0
false
"""
@spec (term === term) :: boolean
def left === right do
:erlang."=:="(left, right)
end
@doc """
Returns `true` if the two items do not match.
All terms in Elixir can be compared with each other.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> 1 !== 2
true
iex> 1 !== 1.0
true
"""
@spec (term !== term) :: boolean
def left !== right do
:erlang."=/="(left, right)
end
@doc """
Gets the element at the zero-based `index` in `tuple`.
Allowed in guard tests. Inlined by the compiler.
## Examples
iex> tuple = {:foo, :bar, 3}
iex> elem(tuple, 1)
:bar
"""
@spec elem(tuple, non_neg_integer) :: term
def elem(tuple, index) do
:erlang.element(index + 1, tuple)
end
@doc """
Inserts `value` at the given zero-based `index` in `tuple`.
Inlined by the compiler.
## Examples
iex> tuple = {:foo, :bar, 3}
iex> put_elem(tuple, 0, :baz)
{:baz, :bar, 3}
"""
@spec put_elem(tuple, non_neg_integer, term) :: tuple
def put_elem(tuple, index, value) do
:erlang.setelement(index + 1, tuple, value)
end
## Implemented in Elixir
@doc """
Boolean or.
If the first argument is `true`, `true` is returned; otherwise, the second
argument is returned.
Requires only the first argument to be a boolean since it short-circuits.
If the first argument is not a boolean, an `ArgumentError` exception is
raised.
Allowed in guard tests.
## Examples
iex> true or false
true
iex> false or 42
42
"""
defmacro left or right do
quote do: __op__(:orelse, unquote(left), unquote(right))
end
@doc """
Boolean and.
If the first argument is `false`, `false` is returned; otherwise, the second
argument is returned.
Requires only the first argument to be a boolean since it short-circuits. If
the first argument is not a boolean, an `ArgumentError` exception is raised.
Allowed in guard tests.
## Examples
iex> true and false
false
iex> true and "yay!"
"yay!"
"""
defmacro left and right do
quote do: __op__(:andalso, unquote(left), unquote(right))
end
@doc """
Boolean not.
Receives any argument (not just booleans) and returns `true` if the argument
is `false` or `nil`; returns `false` otherwise.
Not allowed in guard clauses.
## Examples
iex> !Enum.empty?([])
false
iex> !List.first([])
true
"""
defmacro !(arg)
defmacro !({:!, _, [arg]}) do
optimize_boolean(quote do
case unquote(arg) do
x when x in [false, nil] -> false
_ -> true
end
end)
end
defmacro !(arg) do
optimize_boolean(quote do
case unquote(arg) do
x when x in [false, nil] -> true
_ -> false
end
end)
end
@doc """
Concatenates two binaries.
## Examples
iex> "foo" <> "bar"
"foobar"
The `<>` operator can also be used in pattern matching (and guard clauses) as
long as the first part is a literal binary:
iex> "foo" <> x = "foobar"
iex> x
"bar"
`x <> "bar" = "foobar"` would have resulted in a `CompileError` exception.
"""
defmacro left <> right do
concats = extract_concatenations({:<>, [], [left, right]})
quote do: <<unquote_splicing(concats)>>
end
# Extracts concatenations in order to optimize many
# concatenations into one single clause.
defp extract_concatenations({:<>, _, [left, right]}) do
[wrap_concatenation(left)|extract_concatenations(right)]
end
defp extract_concatenations(other) do
[wrap_concatenation(other)]
end
defp wrap_concatenation(binary) when is_binary(binary) do
binary
end
defp wrap_concatenation(other) do
{:::, [], [other, {:binary, [], nil}]}
end
@doc """
Raises an exception.
If the argument `msg` is a binary, it raises a `RuntimeError` exception
using the given argument as message.
If `msg` is an atom, it just calls `raise/2` with the atom as the first
argument and `[]` as the second argument.
If `msg` is anything else, raises an `ArgumentError` exception.
## Examples
iex> raise "Oops"
** (RuntimeError) Oops
try do
1 + :foo
rescue
x in [ArithmeticError] ->
IO.puts "that was expected"
raise x
end
"""
defmacro raise(msg) do
# Try to figure out the type at compilation time
# to avoid dead code and make dialyzer happy.
msg = case not is_binary(msg) and bootstraped?(Macro) do
true -> Macro.expand(msg, __CALLER__)
false -> msg
end
case msg do
msg when is_binary(msg) ->
quote do
:erlang.error RuntimeError.exception(unquote(msg))
end
{:<<>>, _, _} = msg ->
quote do
:erlang.error RuntimeError.exception(unquote(msg))
end
alias when is_atom(alias) ->
quote do
:erlang.error unquote(alias).exception([])
end
_ ->
quote do
case unquote(msg) do
msg when is_binary(msg) ->
:erlang.error RuntimeError.exception(msg)
atom when is_atom(atom) ->
:erlang.error atom.exception([])
%{__struct__: struct, __exception__: true} = other when is_atom(struct) ->
:erlang.error other
other ->
message = "raise/1 expects an alias, string or exception as the first argument, got: #{inspect other}"
:erlang.error ArgumentError.exception(message)
end
end
end
end
@doc """
Raises an exception.
Calls the `exception/1` function on the given argument (which has to be a
module name like `ArgumentError` or `RuntimeError`) passing `attrs` as the
attributes in order to retrieve the exception struct.
Any module that contains a call to the `defexception/1` macro automatically
implements the `exception/1` callback expected by `raise/2`. See the docs for
`defexception/1` for more information.
## Examples
iex> raise(ArgumentError, message: "Sample")
** (ArgumentError) Sample
"""
defmacro raise(exception, attrs) do
quote do
:erlang.error unquote(exception).exception(unquote(attrs))
end
end
@doc """
Raises an exception preserving a previous stacktrace.
Works like `raise/1` but does not generate a new stacktrace.
Notice that `System.stacktrace/0` returns the stacktrace
of the last exception. That said, it is common to assign
the stacktrace as the first expression inside a `rescue`
clause as any other exception potentially raised (and
rescued) between the rescue clause and the raise call
may change the `System.stacktrace/0` value.
## Examples
try do
raise "Oops"
rescue
exception ->
stacktrace = System.stacktrace
if Exception.message(exception) == "Oops" do
reraise exception, stacktrace
end
end
"""
defmacro reraise(msg, stacktrace) do
# Try to figure out the type at compilation time
# to avoid dead code and make dialyzer happy.
case Macro.expand(msg, __CALLER__) do
msg when is_binary(msg) ->
quote do
:erlang.raise :error, RuntimeError.exception(unquote(msg)), unquote(stacktrace)
end
{:<<>>, _, _} = msg ->
quote do
:erlang.raise :error, RuntimeError.exception(unquote(msg)), unquote(stacktrace)
end
alias when is_atom(alias) ->
quote do
:erlang.raise :error, unquote(alias).exception([]), unquote(stacktrace)
end
msg ->
quote do
stacktrace = unquote(stacktrace)
case unquote(msg) do
msg when is_binary(msg) ->
:erlang.raise :error, RuntimeError.exception(msg), stacktrace
atom when is_atom(atom) ->
:erlang.raise :error, atom.exception([]), stacktrace
%{__struct__: struct, __exception__: true} = other when is_atom(struct) ->
:erlang.raise :error, other, stacktrace
other ->
message = "reraise/2 expects an alias, string or exception as the first argument, got: #{inspect other}"
:erlang.error ArgumentError.exception(message)
end
end
end
end
@doc """
Raises an exception preserving a previous stacktrace.
`reraise/3` works like `reraise/2`, except it passes arguments to the
`exception/1` function like explained in `raise/2`.
## Examples
try do
raise "Oops"
rescue
exception ->
stacktrace = System.stacktrace
reraise WrapperError, [exception: exception], stacktrace
end
"""
defmacro reraise(exception, attrs, stacktrace) do
quote do
:erlang.raise :error, unquote(exception).exception(unquote(attrs)), unquote(stacktrace)
end
end
@doc """
Matches the term on the left against the regular expression or string on the
right. Returns `true` if `left` matches `right` (if it's a regular expression)
or contains `right` (if it's a string).
## Examples
iex> "abcd" =~ ~r/c(d)/
true
iex> "abcd" =~ ~r/e/
false
iex> "abcd" =~ "bc"
true
iex> "abcd" =~ "ad"
false
iex> "abcd" =~ ""
true
"""
@spec (String.t =~ (String.t | Regex.t)) :: boolean
def left =~ "" when is_binary(left), do: true
def left =~ right when is_binary(left) and is_binary(right) do
:binary.match(left, right) != :nomatch
end
def left =~ right when is_binary(left) do
Regex.match?(right, left)
end
@doc ~S"""
Inspects the given argument according to the `Inspect` protocol.
The second argument is a keyword list with options to control
inspection.
## Options
`inspect/2` accepts a list of options that are internally
translated to an `Inspect.Opts` struct. Check the docs for
`Inspect.Opts` to see the supported options.
## Examples
iex> inspect(:foo)
":foo"
iex> inspect [1, 2, 3, 4, 5], limit: 3
"[1, 2, 3, ...]"
iex> inspect("olá" <> <<0>>)
"<<111, 108, 195, 161, 0>>"
iex> inspect("olá" <> <<0>>, binaries: :as_strings)
"\"olá\\0\""
iex> inspect("olá", binaries: :as_binaries)
"<<111, 108, 195, 161>>"
iex> inspect('bar')
"'bar'"
iex> inspect([0|'bar'])
"[0, 98, 97, 114]"
iex> inspect(100, base: :octal)
"0o144"
iex> inspect(100, base: :hex)
"0x64"
Note that the `Inspect` protocol does not necessarily return a valid
representation of an Elixir term. In such cases, the inspected result
must start with `#`. For example, inspecting a function will return:
inspect fn a, b -> a + b end
#=> #Function<...>
"""
@spec inspect(Inspect.t, Keyword.t) :: String.t
def inspect(arg, opts \\ []) when is_list(opts) do
opts = struct(Inspect.Opts, opts)
limit = case opts.pretty do
true -> opts.width
false -> :infinity
end
IO.iodata_to_binary(
Inspect.Algebra.format(Inspect.Algebra.to_doc(arg, opts), limit)
)
end
@doc """
Creates and updates structs.
The `struct` argument may be an atom (which defines `defstruct`)
or a `struct` itself. The second argument is any `Enumerable` that
emits two-item tuples (key-value pairs) during enumeration.
Keys in the `Enumerable` that don't exist in the struct are automatically
discarded.
This function is useful for dynamically creating and updating
structs, as well as for converting maps to structs; in the latter case, just
inserting the appropriate `:__struct__` field into the map may not be enough
and `struct/2` should be used instead.
## Examples
defmodule User do
defstruct name: "john"
end
struct(User)
#=> %User{name: "john"}
opts = [name: "meg"]
user = struct(User, opts)
#=> %User{name: "meg"}
struct(user, unknown: "value")
#=> %User{name: "meg"}
struct(User, %{name: "meg"})
#=> %User{name: "meg"}
"""
@spec struct(module | map, Enum.t) :: map
def struct(struct, kv \\ [])
def struct(struct, []) when is_atom(struct) do
apply(struct, :__struct__, [])
end
def struct(struct, kv) when is_atom(struct) do
struct(apply(struct, :__struct__, []), kv)
end
def struct(%{__struct__: _} = struct, []) do
struct
end
def struct(%{__struct__: _} = struct, kv) do
Enum.reduce(kv, struct, fn {k, v}, acc ->
case :maps.is_key(k, acc) and k != :__struct__ do
true -> :maps.put(k, v, acc)
false -> acc
end
end)
end
@doc """
Gets a value from a nested structure.
Uses the `Access` protocol to traverse the structures
according to the given `keys`, unless the `key` is a
function.
If a key is a function, the function will be invoked
passing three arguments, the operation (`:get`), the
data to be accessed, and a function to be invoked next.
This means `get_in/2` can be extended to provide
custom lookups. The downside is that functions cannot be
stored as keys in the accessed data structures.
## Examples
iex> users = %{"john" => %{age: 27}, "meg" => %{age: 23}}
iex> get_in(users, ["john", :age])
27
In case any of entries in the middle returns `nil`, `nil` will be returned
as per the Access protocol:
iex> users = %{"john" => %{age: 27}, "meg" => %{age: 23}}
iex> get_in(users, ["unknown", :age])
nil
When one of the keys is a function, the function is invoked.
In the example below, we use a function to get all the maps
inside a list:
iex> users = [%{name: "john", age: 27}, %{name: "meg", age: 23}]
iex> all = fn :get, data, next -> Enum.map(data, next) end
iex> get_in(users, [all, :age])
[27, 23]
If the previous value before invoking the function is `nil`,
the function *will* receive nil as a value and must handle it
accordingly.
"""
@spec get_in(Access.t, nonempty_list(term)) :: term
def get_in(data, keys)
def get_in(data, [h]) when is_function(h),
do: h.(:get, data, &(&1))
def get_in(data, [h|t]) when is_function(h),
do: h.(:get, data, &get_in(&1, t))
def get_in(nil, [_]),
do: nil
def get_in(nil, [_|t]),
do: get_in(nil, t)
def get_in(data, [h]),
do: Access.get(data, h)
def get_in(data, [h|t]),
do: get_in(Access.get(data, h), t)
@doc """
Puts a value in a nested structure.
Uses the `Access` protocol to traverse the structures
according to the given `keys`, unless the `key` is a
function. If the key is a function, it will be invoked
as specified in `get_and_update_in/3`.
## Examples
iex> users = %{"john" => %{age: 27}, "meg" => %{age: 23}}
iex> put_in(users, ["john", :age], 28)
%{"john" => %{age: 28}, "meg" => %{age: 23}}
In case any of entries in the middle returns `nil`,
an error will be raised when trying to access it next.
"""
@spec put_in(Access.t, nonempty_list(term), term) :: Access.t
def put_in(data, keys, value) do
elem(get_and_update_in(data, keys, fn _ -> {nil, value} end), 1)
end
@doc """
Updates a key in a nested structure.
Uses the `Access` protocol to traverse the structures
according to the given `keys`, unless the `key` is a
function. If the key is a function, it will be invoked
as specified in `get_and_update_in/3`.
## Examples
iex> users = %{"john" => %{age: 27}, "meg" => %{age: 23}}
iex> update_in(users, ["john", :age], &(&1 + 1))
%{"john" => %{age: 28}, "meg" => %{age: 23}}
In case any of entries in the middle returns `nil`,
an error will be raised when trying to access it next.
"""
@spec update_in(Access.t, nonempty_list(term), (term -> term)) :: Access.t
def update_in(data, keys, fun) do
elem(get_and_update_in(data, keys, fn x -> {nil, fun.(x)} end), 1)
end
@doc """
Gets a value and updates a nested structure.
It expects a tuple to be returned, containing the value
retrieved and the update one.
Uses the `Access` protocol to traverse the structures
according to the given `keys`, unless the `key` is a
function.
If a key is a function, the function will be invoked
passing three arguments, the operation (`:get_and_update`),
the data to be accessed, and a function to be invoked next.
This means `get_and_update_in/3` can be extended to provide
custom lookups. The downside is that functions cannot be stored
as keys in the accessed data structures.
## Examples
This function is useful when there is a need to retrieve the current
value (or something calculated in function of the current value) and
update it at the same time. For example, it could be used to increase
the age of a user by one and return the previous age in one pass:
iex> users = %{"john" => %{age: 27}, "meg" => %{age: 23}}
iex> get_and_update_in(users, ["john", :age], &{&1, &1 + 1})
{27, %{"john" => %{age: 28}, "meg" => %{age: 23}}}
When one of the keys is a function, the function is invoked.
In the example below, we use a function to get and increment all
ages inside a list:
iex> users = [%{name: "john", age: 27}, %{name: "meg", age: 23}]
iex> all = fn :get_and_update, data, next ->
...> Enum.map(data, next) |> :lists.unzip
...> end
iex> get_and_update_in(users, [all, :age], &{&1, &1 + 1})
{[27, 23], [%{name: "john", age: 28}, %{name: "meg", age: 24}]}
If the previous value before invoking the function is `nil`,
the function *will* receive `nil` as a value and must handle it
accordingly (be it by failing or providing a sane default).
"""
@spec get_and_update_in(Access.t, nonempty_list(term),
(term -> {get, term})) :: {get, Access.t} when get: var
def get_and_update_in(data, keys, fun)
def get_and_update_in(data, [h], fun) when is_function(h),
do: h.(:get_and_update, data, fun)
def get_and_update_in(data, [h|t], fun) when is_function(h),
do: h.(:get_and_update, data, &get_and_update_in(&1, t, fun))
def get_and_update_in(data, [h], fun),
do: Access.get_and_update(data, h, fun)
def get_and_update_in(data, [h|t], fun),
do: Access.get_and_update(data, h, &get_and_update_in(&1, t, fun))
@doc """
Puts a value in a nested structure via the given `path`.
This is similar to `put_in/3`, except the path is extracted via
a macro rather than passing a list. For example:
put_in(opts[:foo][:bar], :baz)
Is equivalent to:
put_in(opts, [:foo, :bar], :baz)
Note that in order for this macro to work, the complete path must always
be visible by this macro. For more information about the supported path
expressions, please check `get_and_update_in/2` docs.
## Examples
iex> users = %{"john" => %{age: 27}, "meg" => %{age: 23}}
iex> put_in(users["john"][:age], 28)
%{"john" => %{age: 28}, "meg" => %{age: 23}}
iex> users = %{"john" => %{age: 27}, "meg" => %{age: 23}}
iex> put_in(users["john"].age, 28)
%{"john" => %{age: 28}, "meg" => %{age: 23}}
"""
defmacro put_in(path, value) do
case unnest(path, [], true, "put_in/2") do
{[h|t], true} ->
nest_update_in(h, t, quote(do: fn _ -> unquote(value) end))
{[h|t], false} ->
expr = nest_get_and_update_in(h, t, quote(do: fn _ -> {nil, unquote(value)} end))
quote do: :erlang.element(2, unquote(expr))
end
end
@doc """
Updates a nested structure via the given `path`.
This is similar to `update_in/3`, except the path is extracted via
a macro rather than passing a list. For example:
update_in(opts[:foo][:bar], &(&1 + 1))
Is equivalent to:
update_in(opts, [:foo, :bar], &(&1 + 1))
Note that in order for this macro to work, the complete path must always
be visible by this macro. For more information about the supported path
expressions, please check `get_and_update_in/2` docs.
## Examples
iex> users = %{"john" => %{age: 27}, "meg" => %{age: 23}}
iex> update_in(users["john"][:age], &(&1 + 1))
%{"john" => %{age: 28}, "meg" => %{age: 23}}
iex> users = %{"john" => %{age: 27}, "meg" => %{age: 23}}
iex> update_in(users["john"].age, &(&1 + 1))
%{"john" => %{age: 28}, "meg" => %{age: 23}}
"""
defmacro update_in(path, fun) do
case unnest(path, [], true, "update_in/2") do
{[h|t], true} ->
nest_update_in(h, t, fun)
{[h|t], false} ->
expr = nest_get_and_update_in(h, t, quote(do: fn x -> {nil, unquote(fun).(x)} end))
quote do: :erlang.element(2, unquote(expr))
end
end
@doc """
Gets a value and updates a nested data structure via the given `path`.
This is similar to `get_and_update_in/3`, except the path is extracted
via a macro rather than passing a list. For example:
get_and_update_in(opts[:foo][:bar], &{&1, &1 + 1})
Is equivalent to:
get_and_update_in(opts, [:foo, :bar], &{&1, &1 + 1})
Note that in order for this macro to work, the complete path must always
be visible by this macro. See the Paths section below.
## Examples
iex> users = %{"john" => %{age: 27}, "meg" => %{age: 23}}
iex> get_and_update_in(users["john"].age, &{&1, &1 + 1})
{27, %{"john" => %{age: 28}, "meg" => %{age: 23}}}
## Paths
A path may start with a variable, local or remote call, and must be
followed by one or more:
* `foo[bar]` - access a field; in case an intermediate field is not
present or returns `nil`, an empty map is used
* `foo.bar` - access a map/struct field; in case the field is not
present, an error is raised
Here are some valid paths:
users["john"][:age]
users["john"].age
User.all["john"].age
all_users()["john"].age
Here are some invalid ones:
# Does a remote call after the initial value
users["john"].do_something(arg1, arg2)
# Does not access any field
users
"""
defmacro get_and_update_in(path, fun) do
{[h|t], _} = unnest(path, [], true, "get_and_update_in/2")
nest_get_and_update_in(h, t, fun)
end
defp nest_update_in([], fun), do: fun
defp nest_update_in(list, fun) do
quote do
fn x -> unquote(nest_update_in(quote(do: x), list, fun)) end
end
end
defp nest_update_in(h, [{:map, key}|t], fun) do
quote do
Map.update!(unquote(h), unquote(key), unquote(nest_update_in(t, fun)))
end
end
defp nest_get_and_update_in([], fun), do: fun
defp nest_get_and_update_in(list, fun) do
quote do
fn x -> unquote(nest_get_and_update_in(quote(do: x), list, fun)) end
end
end
defp nest_get_and_update_in(h, [{:access, key}|t], fun) do
quote do
Access.get_and_update(
unquote(h),
unquote(key),
unquote(nest_get_and_update_in(t, fun))
)
end
end
defp nest_get_and_update_in(h, [{:map, key}|t], fun) do
quote do
Map.get_and_update!(unquote(h), unquote(key), unquote(nest_get_and_update_in(t, fun)))
end
end
defp unnest({{:., _, [Access, :get]}, _, [expr, key]}, acc, _all_map?, kind) do
unnest(expr, [{:access, key}|acc], false, kind)
end
defp unnest({{:., _, [expr, key]}, _, []}, acc, all_map?, kind)
when is_tuple(expr) and
:erlang.element(1, expr) != :__aliases__ and
:erlang.element(1, expr) != :__MODULE__ do
unnest(expr, [{:map, key}|acc], all_map?, kind)
end
defp unnest(other, [], _all_map?, kind) do
raise ArgumentError,
"expected expression given to #{kind} to access at least one element, got: #{Macro.to_string other}"
end
defp unnest(other, acc, all_map?, kind) do
case proper_start?(other) do
true -> {[other|acc], all_map?}
false ->
raise ArgumentError,
"expression given to #{kind} must start with a variable, local or remote call " <>
"and be followed by an element access, got: #{Macro.to_string other}"
end
end
defp proper_start?({{:., _, [expr, _]}, _, _args})
when is_atom(expr)
when :erlang.element(1, expr) == :__aliases__
when :erlang.element(1, expr) == :__MODULE__, do: true
defp proper_start?({atom, _, _args})
when is_atom(atom), do: true
defp proper_start?(other),
do: not is_tuple(other)
@doc """
Converts the argument to a string according to the
`String.Chars` protocol.
This is the function invoked when there is string interpolation.
## Examples
iex> to_string(:foo)
"foo"
"""
# If it is a binary at compilation time, simply return it.
defmacro to_string(arg) when is_binary(arg), do: arg
defmacro to_string(arg) do
quote do: String.Chars.to_string(unquote(arg))
end
@doc """
Converts the argument to a char list according to the `List.Chars` protocol.
## Examples
iex> to_char_list(:foo)
'foo'
"""
defmacro to_char_list(arg) do
quote do: List.Chars.to_char_list(unquote(arg))
end
@doc """
Returns `true` if `term` is `nil`, `false` otherwise.
Allowed in guard clauses.
## Examples
iex> is_nil(1)
false
iex> is_nil(nil)
true
"""
defmacro is_nil(term) do
quote do: unquote(term) == nil
end
@doc """
A convenience macro that checks if the right side (an expression) matches the
left side (a pattern).
## Examples
iex> match?(1, 1)
true
iex> match?(1, 2)
false
iex> match?({1, _}, {1, 2})
true
iex> map = %{a: 1, b: 2}
iex> match?(%{a: _}, map)
true
iex> a = 1
iex> match?(^a, 1)
true
`match?/2` is very useful when filtering of finding a value in an enumerable:
list = [{:a, 1}, {:b, 2}, {:a, 3}]
Enum.filter list, &match?({:a, _}, &1)
#=> [{:a, 1}, {:a, 3}]
Guard clauses can also be given to the match:
list = [{:a, 1}, {:b, 2}, {:a, 3}]
Enum.filter list, &match?({:a, x} when x < 2, &1)
#=> [{:a, 1}]
However, variables assigned in the match will not be available
outside of the function call (unlike regular pattern matching with the `=`
operator):
iex> match?(_x, 1)
true
iex> binding()
[]
"""
defmacro match?(pattern, expr)
# Special case where underscore, which always matches, is passed as the first
# argument.
defmacro match?({:_, _, atom}, _right) when is_atom(atom) do
true
end
defmacro match?(left, right) do
quote do
case unquote(right) do
unquote(left) ->
true
_ ->
false
end
end
end
@doc """
Reads and writes attributes of the current module.
The canonical example for attributes is annotating that a module
implements the OTP behaviour called `gen_server`:
defmodule MyServer do
@behaviour :gen_server
# ... callbacks ...
end
By default Elixir supports all the module attributes supported by Erlang, but
custom attributes can be used as well:
defmodule MyServer do
@my_data 13
IO.inspect @my_data #=> 13
end
Unlike Erlang, such attributes are not stored in the module by default since
it is common in Elixir to use custom attributes to store temporary data that
will be available at compile-time. Custom attributes may be configured to
behave closer to Erlang by using `Module.register_attribute/3`.
Finally, notice that attributes can also be read inside functions:
defmodule MyServer do
@my_data 11
def first_data, do: @my_data
@my_data 13
def second_data, do: @my_data
end
MyServer.first_data #=> 11
MyServer.second_data #=> 13
It is important to note that reading an attribute takes a snapshot of
its current value. In other words, the value is read at compilation
time and not at runtime. Check the `Module` module for other functions
to manipulate module attributes.
"""
defmacro @(expr)
# Typespecs attributes are special cased by the compiler so far
defmacro @({name, _, args}) do
# Check for Macro as it is compiled later than Module
case bootstraped?(Module) do
false -> nil
true ->
assert_module_scope(__CALLER__, :@, 1)
function? = __CALLER__.function != nil
case not function? and __CALLER__.context == :match do
false -> nil
true ->
raise ArgumentError, "invalid write attribute syntax, you probably meant to use: @#{name} expression"
end
case is_list(args) and length(args) == 1 and typespec(name) do
false ->
do_at(args, name, function?, __CALLER__)
macro ->
case bootstraped?(Kernel.Typespec) do
false -> nil
true -> quote do: Kernel.Typespec.unquote(macro)(unquote(hd(args)))
end
end
end
end
# @attribute value
defp do_at([arg], name, function?, env) do
case function? do
true ->
raise ArgumentError, "cannot set attribute @#{name} inside function/macro"
false ->
case name do
:behavior ->
:elixir_errors.warn env.line, env.file,
"@behavior attribute is not supported, please use @behaviour instead"
_ ->
:ok
end
quote do: Module.put_attribute(__MODULE__, unquote(name), unquote(arg))
end
end
# @attribute or @attribute()
defp do_at(args, name, function?, env) when is_atom(args) or args == [] do
stack = env_stacktrace(env)
case function? do
true ->
attr = Module.get_attribute(env.module, name, stack)
try do
:elixir_quote.escape(attr, false)
rescue
e in [ArgumentError] ->
raise ArgumentError, "cannot inject attribute @#{name} into function/macro because " <> Exception.message(e)
else
{val, _} -> val
end
false ->
escaped = case stack do
[] -> []
_ -> Macro.escape(stack)
end
quote do: Module.get_attribute(__MODULE__, unquote(name), unquote(escaped))
end
end
# All other cases
defp do_at(args, name, _function?, _env) do
raise ArgumentError, "expected 0 or 1 argument for @#{name}, got: #{length(args)}"
end
defp typespec(:type), do: :deftype
defp typespec(:typep), do: :deftypep
defp typespec(:opaque), do: :defopaque
defp typespec(:spec), do: :defspec
defp typespec(:callback), do: :defcallback
defp typespec(_), do: false
@doc """
Returns the binding for the given context as a keyword list.
In the returned result, keys are variable names and values are the
corresponding variable values.
If the given `context` is `nil` (by default it is), the binding for the
current context is returned.
## Examples
iex> x = 1
iex> binding()
[x: 1]
iex> x = 2
iex> binding()
[x: 2]
iex> binding(:foo)
[]
iex> var!(x, :foo) = 1
1
iex> binding(:foo)
[x: 1]
"""
defmacro binding(context \\ nil) do
in_match? = Macro.Env.in_match?(__CALLER__)
for {v, c} <- __CALLER__.vars, c == context do
{v, wrap_binding(in_match?, {v, [], c})}
end
end
defp wrap_binding(true, var) do
quote do: ^(unquote(var))
end
defp wrap_binding(_, var) do
var
end
@doc """
Provides an `if` macro.
This macro expects the first argument to be a condition and the second
argument to be a keyword list.
## One-liner examples
if(foo, do: bar)
In the example above, `bar` will be returned if `foo` evaluates to
`true` (i.e., it is neither `false` nor `nil`). Otherwise, `nil` will be
returned.
An `else` option can be given to specify the opposite:
if(foo, do: bar, else: baz)
## Blocks examples
It's also possible to pass a block to the `if` macro. The first
example above would be translated to:
if foo do
bar
end
Note that `do/end` become delimiters. The second example would
translate to:
if foo do
bar
else
baz
end
In order to compare more than two clauses, the `cond/1` macro has to be used.
"""
defmacro if(condition, clauses) do
do_clause = Keyword.get(clauses, :do, nil)
else_clause = Keyword.get(clauses, :else, nil)
optimize_boolean(quote do
case unquote(condition) do
x when x in [false, nil] -> unquote(else_clause)
_ -> unquote(do_clause)
end
end)
end
@doc """
Provides an `unless` macro.
This macro evaluates and returns the `do` block passed in as the second
argument unless `clause` evaluates to `true`. Otherwise, it returns the value
of the `else` block if present or `nil` if not.
See also `if/2`.
## Examples
iex> unless(Enum.empty?([]), do: "Hello")
nil
iex> unless(Enum.empty?([1, 2, 3]), do: "Hello")
"Hello"
iex> unless Enum.sum([2, 2]) == 5 do
...> "Math still works"
...> else
...> "Math is broken"
...> end
"Math still works"
"""
defmacro unless(clause, options) do
do_clause = Keyword.get(options, :do, nil)
else_clause = Keyword.get(options, :else, nil)
quote do
if(unquote(clause), do: unquote(else_clause), else: unquote(do_clause))
end
end
@doc """
Destructures two lists, assigning each term in the
right one to the matching term in the left one.
Unlike pattern matching via `=`, if the sizes of the left
and right lists don't match, destructuring simply stops
instead of raising an error.
## Examples
iex> destructure([x, y, z], [1, 2, 3, 4, 5])
iex> {x, y, z}
{1, 2, 3}
In the example above, even though the right list has more entries than the
left one, destructuring works fine. If the right list is smaller, the
remaining items are simply set to `nil`:
iex> destructure([x, y, z], [1])
iex> {x, y, z}
{1, nil, nil}
The left-hand side supports any expression you would use
on the left-hand side of a match:
x = 1
destructure([^x, y, z], [1, 2, 3])
The example above will only work if `x` matches the first value in the right
list. Otherwise, it will raise a `MatchError` (like the `=` operator would
do).
"""
defmacro destructure(left, right) when is_list(left) do
Enum.reduce left, right, fn item, acc ->
{:case, meta, args} =
quote do
case unquote(acc) do
[h|t] ->
unquote(item) = h
t
other when other == [] or other == nil ->
unquote(item) = nil
[]
end
end
{:case, meta, args}
end
end
@doc """
Returns a range with the specified start and end.
Both ends are included.
## Examples
iex> 0 in 1..3
false
iex> 1 in 1..3
true
iex> 2 in 1..3
true
iex> 3 in 1..3
true
"""
defmacro first .. last do
{:%{}, [], [__struct__: Elixir.Range, first: first, last: last]}
end
@doc """
Provides a short-circuit operator that evaluates and returns
the second expression only if the first one evaluates to `true`
(i.e., it is not `nil` nor `false`). Returns the first expression
otherwise.
Not allowed in guard clauses.
## Examples
iex> Enum.empty?([]) && Enum.empty?([])
true
iex> List.first([]) && true
nil
iex> Enum.empty?([]) && List.first([1])
1
iex> false && throw(:bad)
false
Note that, unlike Erlang's `and` operator,
this operator accepts any expression as the first argument,
not only booleans.
"""
defmacro left && right do
quote do
case unquote(left) do
x when x in [false, nil] ->
x
_ ->
unquote(right)
end
end
end
@doc """
Provides a short-circuit operator that evaluates and returns the second
expression only if the first one does not evaluate to `true` (i.e., it
is either `nil` or `false`). Returns the first expression otherwise.
Not allowed in guard clauses.
## Examples
iex> Enum.empty?([1]) || Enum.empty?([1])
false
iex> List.first([]) || true
true
iex> Enum.empty?([1]) || 1
1
iex> Enum.empty?([]) || throw(:bad)
true
Note that, unlike Erlang's `or` operator,
this operator accepts any expression as the first argument,
not only booleans.
"""
defmacro left || right do
quote do
case unquote(left) do
x when x in [false, nil] ->
unquote(right)
x ->
x
end
end
end
@doc """
Pipe operator.
This operator introduces the expression on the left-hand side as
the first argument to the function call on the right-hand side.
## Examples
iex> [1, [2], 3] |> List.flatten()
[1, 2, 3]
The example above is the same as calling `List.flatten([1, [2], 3])`.
The `|>` operator is mostly useful when there is a desire to execute a series
of operations resembling a pipeline:
iex> [1, [2], 3] |> List.flatten |> Enum.map(fn x -> x * 2 end)
[2, 4, 6]
In the example above, the list `[1, [2], 3]` is passed as the first argument
to the `List.flatten/1` function, then the flattened list is passed as the
first argument to the `Enum.map/2` function which doubles each element of the
list.
In other words, the expression above simply translates to:
Enum.map(List.flatten([1, [2], 3]), fn x -> x * 2 end)
Beware of operator precedence when using the pipe operator.
For example, the following expression:
String.graphemes "Hello" |> Enum.reverse
Translates to:
String.graphemes("Hello" |> Enum.reverse)
which results in an error as the `Enumerable` protocol is not defined
for binaries. Adding explicit parentheses resolves the ambiguity:
String.graphemes("Hello") |> Enum.reverse
Or, even better:
"Hello" |> String.graphemes |> Enum.reverse
"""
defmacro left |> right do
[{h, _}|t] = Macro.unpipe({:|>, [], [left, right]})
:lists.foldl fn {x, pos}, acc -> Macro.pipe(acc, x, pos) end, h, t
end
@doc """
Returns `true` if `module` is loaded and contains a
public `function` with the given `arity`, otherwise `false`.
Note that this function does not load the module in case
it is not loaded. Check `Code.ensure_loaded/1` for more
information.
## Examples
iex> function_exported?(Enum, :member?, 2)
true
"""
@spec function_exported?(atom | tuple, atom, arity) :: boolean
def function_exported?(module, function, arity) do
:erlang.function_exported(module, function, arity)
end
@doc """
Returns `true` if `module` is loaded and contains a
public `macro` with the given `arity`, otherwise `false`.
Note that this function does not load the module in case
it is not loaded. Check `Code.ensure_loaded/1` for more
information.
## Examples
iex> macro_exported?(Kernel, :use, 2)
true
"""
@spec macro_exported?(atom, atom, integer) :: boolean
def macro_exported?(module, macro, arity) do
case :code.is_loaded(module) do
{:file, _} -> :lists.member({macro, arity}, module.__info__(:macros))
_ -> false
end
end
@doc """
Checks if the element on the left-hand side is a member of the
collection on the right-hand side.
## Examples
iex> x = 1
iex> x in [1, 2, 3]
true
This operator (which is a macro) simply translates to a call to
`Enum.member?/2`. The example above would translate to:
Enum.member?([1, 2, 3], x)
## Guards
The `in` operator can be used in guard clauses as long as the
right-hand side is a range or a list. In such cases, Elixir will expand the
operator to a valid guard expression. For example:
when x in [1, 2, 3]
translates to:
when x === 1 or x === 2 or x === 3
When using ranges:
when x in 1..3
translates to:
when x >= 1 and x <= 3
"""
defmacro left in right do
in_module? = (__CALLER__.context == nil)
right = case bootstraped?(Macro) and not in_module? do
true -> Macro.expand(right, __CALLER__)
false -> right
end
case right do
_ when in_module? ->
quote do: Elixir.Enum.member?(unquote(right), unquote(left))
[] ->
false
[h|t] ->
:lists.foldr(fn x, acc ->
quote do
unquote(comp(left, x)) or unquote(acc)
end
end, comp(left, h), t)
{:%{}, [], [__struct__: Elixir.Range, first: first, last: last]} ->
in_range(left, Macro.expand(first, __CALLER__), Macro.expand(last, __CALLER__))
_ ->
raise ArgumentError, <<"invalid args for operator in, it expects a compile time list ",
"or range on the right side when used in guard expressions, got: ",
Macro.to_string(right) :: binary>>
end
end
defp in_range(left, first, last) do
case opt_in?(first) and opt_in?(last) do
true ->
case first <= last do
true -> increasing_compare(left, first, last)
false -> decreasing_compare(left, first, last)
end
false ->
quote do
(:erlang."=<"(unquote(first), unquote(last)) and
unquote(increasing_compare(left, first, last)))
or
(:erlang."<"(unquote(last), unquote(first)) and
unquote(decreasing_compare(left, first, last)))
end
end
end
defp opt_in?(x), do: is_integer(x) or is_float(x) or is_atom(x)
defp comp(left, right) do
quote(do: :erlang."=:="(unquote(left), unquote(right)))
end
defp increasing_compare(var, first, last) do
quote do
:erlang.">="(unquote(var), unquote(first)) and
:erlang."=<"(unquote(var), unquote(last))
end
end
defp decreasing_compare(var, first, last) do
quote do
:erlang."=<"(unquote(var), unquote(first)) and
:erlang.">="(unquote(var), unquote(last))
end
end
@doc """
When used inside quoting, marks that the given variable should
not be hygienized.
The argument can be either a variable unquoted or in standard tuple form
`{name, meta, context}`.
Check `Kernel.SpecialForms.quote/2` for more information.
"""
defmacro var!(var, context \\ nil)
defmacro var!({name, meta, atom}, context) when is_atom(name) and is_atom(atom) do
do_var!(name, meta, context, __CALLER__)
end
defmacro var!(x, _context) do
raise ArgumentError, "expected a var to be given to var!, got: #{Macro.to_string(x)}"
end
defp do_var!(name, meta, context, env) do
# Remove counter and force them to be vars
meta = :lists.keydelete(:counter, 1, meta)
meta = :lists.keystore(:var, 1, meta, {:var, true})
case Macro.expand(context, env) do
x when is_atom(x) ->
{name, meta, x}
x ->
raise ArgumentError, "expected var! context to expand to an atom, got: #{Macro.to_string(x)}"
end
end
@doc """
When used inside quoting, marks that the given alias should not
be hygienized. This means the alias will be expanded when
the macro is expanded.
Check `Kernel.SpecialForms.quote/2` for more information.
"""
defmacro alias!(alias)
defmacro alias!(alias) when is_atom(alias) do
alias
end
defmacro alias!({:__aliases__, meta, args}) do
# Simply remove the alias metadata from the node
# so it does not affect expansion.
{:__aliases__, :lists.keydelete(:alias, 1, meta), args}
end
## Definitions implemented in Elixir
@doc ~S"""
Defines a module given by name with the given contents.
This macro defines a module with the given `alias` as its name and with the
given contents. It returns a tuple with four elements:
* `:module`
* the module name
* the binary contents of the module
* the result of evaluating the contents block
## Examples
iex> defmodule Foo do
...> def bar, do: :baz
...> end
iex> Foo.bar
:baz
## Nesting
Nesting a module inside another module affects the name of the nested module:
defmodule Foo do
defmodule Bar do
end
end
In the example above, two modules - `Foo` and `Foo.Bar` - are created.
When nesting, Elixir automatically creates an alias to the inner module,
allowing the second module `Foo.Bar` to be accessed as `Bar` in the same
lexical scope where it's defined (the `Foo` module).
If the `Foo.Bar` module is moved somewhere else, the references to `Bar` in
the `Foo` module need to be updated to the fully-qualified name (`Foo.Bar`) or
an alias has to be explicitly set in the `Foo` module with the help of
`Kernel.SpecialForms.alias/2`.
defmodule Foo.Bar do
# code
end
defmodule Foo do
alias Foo.Bar
# code here can refer to `Foo.Bar` as just `Bar`
end
## Dynamic names
Elixir module names can be dynamically generated. This is very
useful when working with macros. For instance, one could write:
defmodule String.to_atom("Foo#{1}") do
# contents ...
end
Elixir will accept any module name as long as the expression passed as the
first argument to `defmodule/2` evaluates to an atom.
Note that, when a dynamic name is used, Elixir won't nest the name under the
current module nor automatically set up an alias.
"""
defmacro defmodule(alias, do: block) do
env = __CALLER__
boot? = bootstraped?(Macro)
expanded =
case boot? do
true -> Macro.expand(alias, env)
false -> alias
end
{expanded, with_alias} =
case boot? and is_atom(expanded) do
true ->
# Expand the module considering the current environment/nesting
full = expand_module(alias, expanded, env)
# Generate the alias for this module definition
{new, old} = module_nesting(env.module, full)
meta = [defined: full, context: env.module] ++ alias_meta(alias)
{full, {:alias, meta, [old, [as: new, warn: false]]}}
false ->
{expanded, nil}
end
{escaped, _} = :elixir_quote.escape(block, false)
module_vars = module_vars(env.vars, 0)
quote do
unquote(with_alias)
:elixir_module.compile(unquote(expanded), unquote(escaped),
unquote(module_vars), __ENV__)
end
end
defp alias_meta({:__aliases__, meta, _}), do: meta
defp alias_meta(_), do: []
# defmodule :foo
defp expand_module(raw, _module, _env) when is_atom(raw),
do: raw
# defmodule Elixir.Alias
defp expand_module({:__aliases__, _, [:Elixir|t]}, module, _env) when t != [],
do: module
# defmodule Alias in root
defp expand_module({:__aliases__, _, _}, module, %{module: nil}),
do: module
# defmodule Alias nested
defp expand_module({:__aliases__, _, t}, _module, env),
do: :elixir_aliases.concat([env.module|t])
# defmodule _
defp expand_module(_raw, module, env),
do: :elixir_aliases.concat([env.module, module])
# quote vars to be injected into the module definition
defp module_vars([{key, kind}|vars], counter) do
var =
case is_atom(kind) do
true -> {key, [], kind}
false -> {key, [counter: kind], nil}
end
under = String.to_atom(<<"_@", :erlang.integer_to_binary(counter)::binary>>)
args = [key, kind, under, var]
[{:{}, [], args}|module_vars(vars, counter+1)]
end
defp module_vars([], _counter) do
[]
end
# Gets two modules names and return an alias
# which can be passed down to the alias directive
# and it will create a proper shortcut representing
# the given nesting.
#
# Examples:
#
# module_nesting('Elixir.Foo.Bar', 'Elixir.Foo.Bar.Baz.Bat')
# {'Elixir.Baz', 'Elixir.Foo.Bar.Baz'}
#
# In case there is no nesting/no module:
#
# module_nesting(nil, 'Elixir.Foo.Bar.Baz.Bat')
# {false, 'Elixir.Foo.Bar.Baz.Bat'}
#
defp module_nesting(nil, full),
do: {false, full}
defp module_nesting(prefix, full) do
case split_module(prefix) do
[] -> {false, full}
prefix -> module_nesting(prefix, split_module(full), [], full)
end
end
defp module_nesting([x|t1], [x|t2], acc, full),
do: module_nesting(t1, t2, [x|acc], full)
defp module_nesting([], [h|_], acc, _full),
do: {String.to_atom(<<"Elixir.", h::binary>>),
:elixir_aliases.concat(:lists.reverse([h|acc]))}
defp module_nesting(_, _, _acc, full),
do: {false, full}
defp split_module(atom) do
case :binary.split(Atom.to_string(atom), ".", [:global]) do
["Elixir"|t] -> t
_ -> []
end
end
@doc """
Defines a function with the given name and body.
## Examples
defmodule Foo do
def bar, do: :baz
end
Foo.bar #=> :baz
A function that expects arguments can be defined as follows:
defmodule Foo do
def sum(a, b) do
a + b
end
end
In the example above, a `sum/2` function is defined; this function receives
two arguments and returns their sum.
"""
defmacro def(call, expr \\ nil) do
define(:def, call, expr, __CALLER__)
end
@doc """
Defines a private function with the given name and body.
Private functions are only accessible from within the module in which they are
defined. Trying to access a private function from outside the module it's
defined in results in an `UndefinedFunctionError` exception.
Check `def/2` for more information.
## Examples
defmodule Foo do
def bar do
sum(1, 2)
end
defp sum(a, b), do: a + b
end
Foo.bar #=> 3
Foo.sum(1, 2) #=> ** (UndefinedFunctionError) undefined function: Foo.sum/2
"""
defmacro defp(call, expr \\ nil) do
define(:defp, call, expr, __CALLER__)
end
@doc """
Defines a macro with the given name and body.
## Examples
defmodule MyLogic do
defmacro unless(expr, opts) do
quote do
if !unquote(expr), unquote(opts)
end
end
end
require MyLogic
MyLogic.unless false do
IO.puts "It works"
end
"""
defmacro defmacro(call, expr \\ nil) do
define(:defmacro, call, expr, __CALLER__)
end
@doc """
Defines a private macro with the given name and body.
Private macros are only accessible from the same module in which they are
defined.
Check `defmacro/2` for more information.
"""
defmacro defmacrop(call, expr \\ nil) do
define(:defmacrop, call, expr, __CALLER__)
end
defp define(kind, call, expr, env) do
assert_module_scope(env, kind, 2)
assert_no_function_scope(env, kind, 2)
line = env.line
{call, uc} = :elixir_quote.escape(call, true)
{expr, ue} = :elixir_quote.escape(expr, true)
# Do not check clauses if any expression was unquoted
check_clauses = not(ue or uc)
pos = :elixir_locals.cache_env(env)
quote do
:elixir_def.store_definition(unquote(line), unquote(kind), unquote(check_clauses),
unquote(call), unquote(expr), unquote(pos))
end
end
@doc """
Defines a struct.
A struct is a tagged map that allows developers to provide
default values for keys, tags to be used in polymorphic
dispatches and compile time assertions.
The only thing needed to define a struct is a `__struct__/0` function that
returns a map with the struct fields and their default values. `defstruct/1`
is a convenience macro which defines such a function (as well as a `t` type
and deriving conveniences).
When using `defstruct/1`, a struct named like the enclosing module is defined.
For more information about structs, please check `Kernel.SpecialForms.%/2`.
## Examples
defmodule User do
defstruct name: nil, age: nil
end
Struct fields are evaluated at compile-time, which allows
them to be dynamic. In the example below, `10 + 11` is
evaluated at compile-time and the age field is stored
with value `21`:
defmodule User do
defstruct name: nil, age: 10 + 11
end
The `fields` argument is usually a keyword list with fields as keys and
default values as corresponding values. `defstruct/1` also supports a list of
atoms as its argument: in that case, the atoms in the list will be used as
the struct's fields and they will all default to `nil`.
defmodule Post do
defstruct [:title, :content, :author]
end
## Deriving
Although structs are maps, by default structs do not implement
any of the protocols implemented for maps. For example, attempting
to use a protocol with the `User` struct leads to an error:
john = %User{name: "John"}
MyProtocol.call(john)
** (Protocol.UndefinedError) protocol MyProtocol not implemented for %User{...}
`defstruct/1`, however, allows protocol implementations to be
*derived*. This can be done by defining a `@derive` attribute as a
list before invoking `defstruct/1`:
defmodule User do
@derive [MyProtocol]
defstruct name: nil, age: 10 + 11
end
MyProtocol.call(john) #=> works
For each protocol in the `@derive` list, Elixir will assert there is an
implementation of that protocol for any (regardless if fallback to any
is true) and check if the any implementation defines a `__deriving__/3`
callback. If so, the callback is invoked, otherwise an implementation
that simply points to the any implementation is automatically derived.
## Types
It is recommended to define types for structs. By convention such type
is called `t`. To define a struct inside a type, the struct literal syntax
is used:
defmodule User do
defstruct name: "John", age: 25
@type t :: %User{name: String.t, age: non_neg_integer}
end
It is recommended to only use the struct syntax when defining the struct's
type. When referring to another struct it's better to use `User.t`instead of
`%User{}`.
The types of the struct fields that are not included in the struct's type
default to `term`.
Structs whose internal structure is private to the local module (pattern
matching them or directly accessing their fields should not be allowed) should
use the `@opaque` attribute. Structs whose internal structure is public should
use `@type`. See `Kernel.Typespec` for more information on opaque types.
"""
defmacro defstruct(fields) do
quote bind_quoted: [fields: fields] do
fields = Kernel.Def.struct(__MODULE__, fields)
@struct fields
case Module.get_attribute(__MODULE__, :derive) do
[] -> :ok
derive -> Protocol.__derive__(derive, __MODULE__, __ENV__)
end
def __struct__() do
@struct
end
fields
end
end
@doc ~S"""
Defines an exception.
Exceptions are structs backed by a module that implements
the `Exception` behaviour. The `Exception` behaviour requires
two functions to be implemented:
* `exception/1` - receives the arguments given to `raise/2`
and returns the exception struct. The default implementation
accepts either a set of keyword arguments that is merged into
the struct or a string to be used as the exception's message.
* `message/1` - receives the exception struct and must return its
message. Most commonly exceptions have a message field which
by default is accessed by this function. However, if an exception
does not have a message field, this function must be explicitly
implemented.
Since exceptions are structs, the API supported by `defstruct/1`
is also available in `defexception/1`.
## Raising exceptions
The most common way to raise an exception is via `raise/2`:
defmodule MyAppError do
defexception [:message]
end
value = [:hello]
raise MyAppError,
message: "did not get what was expected, got: #{inspect value}"
In many cases it is more convenient to pass the expected value to
`raise/2` and generate the message in the `exception/1` callback:
defmodule MyAppError do
defexception [:message]
def exception(value) do
msg = "did not get what was expected, got: #{inspect value}"
%MyAppError{message: msg}
end
end
raise MyAppError, value
The example above shows the preferred strategy for customizing
exception messages.
"""
defmacro defexception(fields) do
fields = case is_list(fields) do
true -> [{:__exception__, true}|fields]
false -> quote(do: [{:__exception__, true}] ++ unquote(fields))
end
quote do
@behaviour Exception
fields = defstruct unquote(fields)
if Map.has_key?(fields, :message) do
@spec message(Exception.t) :: String.t
def message(exception) do
exception.message
end
defoverridable message: 1
@spec exception(String.t) :: Exception.t
def exception(msg) when is_binary(msg) do
exception(message: msg)
end
end
@spec exception(Keyword.t) :: Exception.t
def exception(args) when is_list(args) do
Kernel.struct(__struct__, args)
end
defoverridable exception: 1
end
end
@doc """
Defines a protocol.
A protocol specifies an API that should be defined by its
implementations.
## Examples
In Elixir, only `false` and `nil` are considered falsy values.
Everything else evaluates to `true` in `if` clauses. Depending
on the application, it may be important to specify a `blank?`
protocol that returns a boolean for other data types that should
be considered "blank". For instance, an empty list or an empty
binary could be considered blank.
Such protocol could be implemented as follows:
defprotocol Blank do
@doc "Returns `true` if `data` is considered blank/empty"
def blank?(data)
end
Now that the protocol is defined it can be implemented. It needs to be
implemented for each Elixir type; for example:
# Integers are never blank
defimpl Blank, for: Integer do
def blank?(number), do: false
end
# The only blank list is the empty one
defimpl Blank, for: List do
def blank?([]), do: true
def blank?(_), do: false
end
# The only blank atoms are `false` and `nil`
defimpl Blank, for: Atom do
def blank?(false), do: true
def blank?(nil), do: true
def blank?(_), do: false
end
The implementation of the `Blank` protocol would need to be defined for all
Elixir types. The available types are:
* Structs (see below)
* `Tuple`
* `Atom`
* `List`
* `BitString`
* `Integer`
* `Float`
* `Function`
* `PID`
* `Map`
* `Port`
* `Reference`
* `Any` (see below)
## Protocols and Structs
The real benefit of protocols comes when mixed with structs.
For instance, Elixir ships with many data types implemented as
structs, like `HashDict` and `HashSet`. We can implement the
`Blank` protocol for those types as well:
defimpl Blank, for: [HashDict, HashSet] do
def blank?(enum_like), do: Enum.empty?(enum_like)
end
When implementing a protocol for a struct, the `:for` option can be omitted if
the `defimpl` call is inside the module that defines the struct:
defmodule User do
defstruct [:email, :name]
defimpl Blank do
def blank?(%User{}), do: false
end
end
If a protocol is not found for a given type, it will fallback to
`Any`.
## Fallback to any
In some cases, it may be convenient to provide a default
implementation for all types. This can be achieved by
setting the `@fallback_to_any` attribute to `true` in the protocol
definition:
defprotocol Blank do
@fallback_to_any true
def blank?(data)
end
The `Blank` protocol can now be implemented for `Any`:
defimpl Blank, for: Any do
def blank?(_), do: true
end
One may wonder why such behaviour (fallback to any) is not the default one.
It is two-fold: first, the majority of protocols cannot
implement an action in a generic way for all types; in fact,
providing a default implementation may be harmful, because users
may rely on the default implementation instead of providing a
specialized one.
Second, falling back to `Any` adds an extra lookup to all types,
which is unnecessary overhead unless an implementation for `Any` is
required.
## Types
Defining a protocol automatically defines a type named `t`, which
can be used as follows:
@spec present?(Blank.t) :: boolean
def present?(blank) do
not Blank.blank?(blank)
end
The `@spec` above expresses that all types allowed to implement the
given protocol are valid argument types for the given function.
## Reflection
Any protocol module contains three extra functions:
* `__protocol__/1` - returns the protocol name when `:name` is given, and a
keyword list with the protocol functions and their arities when
`:functions` is given
* `impl_for/1` - receives a structure and returns the module that
implements the protocol for the structure, `nil` otherwise
* `impl_for!/1` - same as above but raises an error if an implementation is
not found
Enumerable.__protocol__(:functions)
#=> [count: 1, member?: 2, reduce: 3]
Enumerable.impl_for([])
#=> Enumerable.List
Enumerable.impl_for(42)
#=> nil
## Consolidation
In order to cope with code loading in development, protocols in
Elixir provide a slow implementation of protocol dispatching specific
to development.
In order to speed up dispatching in production environments, where
all implementations are known up-front, Elixir provides a feature
called protocol consolidation. For this reason, all protocols are
compiled with `debug_info` set to `true`, regardless of the option
set by `elixirc` compiler. The debug info though may be removed
after consolidation.
For more information on how to apply protocol consolidation to
a given project, please check the functions in the `Protocol`
module or the `mix compile.protocols` task.
"""
defmacro defprotocol(name, do: block) do
Protocol.__protocol__(name, do: block)
end
@doc """
Defines an implementation for the given protocol.
See `defprotocol/2` for more information and examples on protocols.
Inside an implementation, the name of the protocol can be accessed
via `@protocol` and the current target as `@for`.
"""
defmacro defimpl(name, opts, do_block \\ []) do
merged = Keyword.merge(opts, do_block)
merged = Keyword.put_new(merged, :for, __CALLER__.module)
Protocol.__impl__(name, merged)
end
@doc """
Makes the given functions in the current module overridable.
An overridable function is lazily defined, allowing a developer to override
it.
## Example
defmodule DefaultMod do
defmacro __using__(_opts) do
quote do
def test(x, y) do
x + y
end
defoverridable [test: 2]
end
end
end
defmodule InheritMod do
use DefaultMod
def test(x, y) do
x * y + super(x, y)
end
end
As seen as in the example above, `super` can be used to call the default
implementation.
"""
defmacro defoverridable(keywords) do
quote do
Module.make_overridable(__MODULE__, unquote(keywords))
end
end
@doc """
`use` is a simple mechanism for using a given module into
the current context.
## Examples
For example, in order to write tests using the ExUnit framework,
a developer should use the `ExUnit.Case` module:
defmodule AssertionTest do
use ExUnit.Case, async: true
test "always pass" do
assert true
end
end
By calling `use`, a hook called `__using__` will be invoked in
`ExUnit.Case` which will then do the proper setup.
Simply put, `use` translates to to:
defmodule AssertionTest do
require ExUnit.Case
ExUnit.Case.__using__([async: true])
test "always pass" do
assert true
end
end
`__using__/1` is just a regular macro that can be defined in any module:
defmodule MyModule do
defmacro __using__(opts) do
quote do
# code that will run in the module that uses MyModule
end
end
end
"""
defmacro use(module, opts \\ []) do
expanded = Macro.expand(module, __CALLER__)
case is_atom(expanded) do
false ->
raise ArgumentError, "invalid arguments for use, expected an atom or alias as argument"
true ->
quote do
require unquote(expanded)
unquote(expanded).__using__(unquote(opts))
end
end
end
@doc """
Define a function that delegates to another module.
Functions defined with `defdelegate/2` are public and can be invoked from
outside the module they're defined in (like if they were defined using
`def/2`). When the desire is to delegate as private functions, `import` should
be used.
Delegation only works with functions; delegating macros is not supported.
## Options
* `:to` - the expression to delegate to. Any expression
is allowed and its results will be evaluated at runtime. Usually
evaluates to the name of a module.
* `:as` - the function to call on the target given in `:to`.
This parameter is optional and defaults to the name being
delegated (`funs`).
* `:append_first` - if `true`, when delegated, the first argument
passed to the delegated function will be relocated to the end of the
arguments when dispatched to the target.
The motivation behind this is because Elixir normalizes
the "handle" as the first argument while some Erlang modules
expect it as the last argument.
## Examples
defmodule MyList do
defdelegate reverse(list), to: :lists
defdelegate other_reverse(list), to: :lists, as: :reverse
defdelegate [reverse(list), map(list, callback)], to: :lists, append_first: true
end
MyList.reverse([1, 2, 3])
#=> [3, 2, 1]
MyList.other_reverse([1, 2, 3])
#=> [3, 2, 1]
MyList.map([1, 2, 3], &(&1 * 2))
#=> [2, 4, 6]
"""
defmacro defdelegate(funs, opts) do
funs = Macro.escape(funs, unquote: true)
quote bind_quoted: [funs: funs, opts: opts] do
target = Keyword.get(opts, :to) ||
raise ArgumentError, "expected to: to be given as argument"
for fun <- List.wrap(funs) do
{name, args, as, as_args} = Kernel.Def.delegate(fun, opts)
def unquote(name)(unquote_splicing(args)) do
unquote(target).unquote(as)(unquote_splicing(as_args))
end
end
end
end
## Sigils
@doc ~S"""
Handles the sigil `~S`.
It simply returns a string without escaping characters and without
interpolations.
## Examples
iex> ~S(foo)
"foo"
iex> ~S(f#{o}o)
"f\#{o}o"
"""
defmacro sigil_S(term, modifiers)
defmacro sigil_S(string, []), do: string
@doc ~S"""
Handles the sigil `~s`.
It returns a string as if it was a double quoted string, unescaping characters
and replacing interpolations.
## Examples
iex> ~s(foo)
"foo"
iex> ~s(f#{:o}o)
"foo"
iex> ~s(f\#{:o}o)
"f\#{:o}o"
"""
defmacro sigil_s(term, modifiers)
defmacro sigil_s({:<<>>, line, pieces}, []) do
{:<<>>, line, Macro.unescape_tokens(pieces)}
end
@doc ~S"""
Handles the sigil `~C`.
It simply returns a char list without escaping characters and without
interpolations.
## Examples
iex> ~C(foo)
'foo'
iex> ~C(f#{o}o)
'f\#{o}o'
"""
defmacro sigil_C(term, modifiers)
defmacro sigil_C({:<<>>, _line, [string]}, []) when is_binary(string) do
String.to_char_list(string)
end
@doc ~S"""
Handles the sigil `~c`.
It returns a char list as if it were a single quoted string, unescaping
characters and replacing interpolations.
## Examples
iex> ~c(foo)
'foo'
iex> ~c(f#{:o}o)
'foo'
iex> ~c(f\#{:o}o)
'f\#{:o}o'
"""
defmacro sigil_c(term, modifiers)
# We can skip the runtime conversion if we are
# creating a binary made solely of series of chars.
defmacro sigil_c({:<<>>, _line, [string]}, []) when is_binary(string) do
String.to_char_list(Macro.unescape_string(string))
end
defmacro sigil_c({:<<>>, line, pieces}, []) do
binary = {:<<>>, line, Macro.unescape_tokens(pieces)}
quote do: String.to_char_list(unquote(binary))
end
@doc """
Handles the sigil `~r`.
It returns a regular expression pattern, unescaping characters and replacing
interpolations.
More information on regexes can be found in the `Regex` module.
## Examples
iex> Regex.match?(~r(foo), "foo")
true
iex> Regex.match?(~r/a#{:b}c/, "abc")
true
"""
defmacro sigil_r(term, modifiers)
defmacro sigil_r({:<<>>, _line, [string]}, options) when is_binary(string) do
binary = Macro.unescape_string(string, fn(x) -> Regex.unescape_map(x) end)
regex = Regex.compile!(binary, :binary.list_to_bin(options))
Macro.escape(regex)
end
defmacro sigil_r({:<<>>, line, pieces}, options) do
binary = {:<<>>, line, Macro.unescape_tokens(pieces, fn(x) -> Regex.unescape_map(x) end)}
quote do: Regex.compile!(unquote(binary), unquote(:binary.list_to_bin(options)))
end
@doc ~S"""
Handles the sigil `~R`.
It returns a regular expression pattern without escaping
nor interpreting interpolations.
More information on regexes can be found in the `Regex` module.
## Examples
iex> Regex.match?(~R(f#{1,3}o), "f#o")
true
"""
defmacro sigil_R(term, modifiers)
defmacro sigil_R({:<<>>, _line, [string]}, options) when is_binary(string) do
regex = Regex.compile!(string, :binary.list_to_bin(options))
Macro.escape(regex)
end
@doc ~S"""
Handles the sigil `~w`.
It returns a list of "words" split by whitespace. Character unescaping and
interpolation happens for each word.
## Modifiers
* `s`: words in the list are strings (default)
* `a`: words in the list are atoms
* `c`: words in the list are char lists
## Examples
iex> ~w(foo #{:bar} baz)
["foo", "bar", "baz"]
iex> ~w(--source test/enum_test.exs)
["--source", "test/enum_test.exs"]
iex> ~w(foo bar baz)a
[:foo, :bar, :baz]
"""
defmacro sigil_w(term, modifiers)
defmacro sigil_w({:<<>>, _line, [string]}, modifiers) when is_binary(string) do
split_words(Macro.unescape_string(string), modifiers)
end
defmacro sigil_w({:<<>>, line, pieces}, modifiers) do
binary = {:<<>>, line, Macro.unescape_tokens(pieces)}
split_words(binary, modifiers)
end
@doc ~S"""
Handles the sigil `~W`.
It returns a list of "words" split by whitespace without escaping nor
interpreting interpolations.
## Modifiers
* `s`: words in the list are strings (default)
* `a`: words in the list are atoms
* `c`: words in the list are char lists
## Examples
iex> ~W(foo #{bar} baz)
["foo", "\#{bar}", "baz"]
"""
defmacro sigil_W(term, modifiers)
defmacro sigil_W({:<<>>, _line, [string]}, modifiers) when is_binary(string) do
split_words(string, modifiers)
end
defp split_words("", _modifiers), do: []
defp split_words(string, modifiers) do
mod =
case modifiers do
[] -> ?s
[mod] when mod == ?s or mod == ?a or mod == ?c -> mod
_else -> raise ArgumentError, "modifier must be one of: s, a, c"
end
case is_binary(string) do
true ->
case mod do
?s -> String.split(string)
?a -> for p <- String.split(string), do: String.to_atom(p)
?c -> for p <- String.split(string), do: String.to_char_list(p)
end
false ->
case mod do
?s -> quote do: String.split(unquote(string))
?a -> quote do: for(p <- String.split(unquote(string)), do: String.to_atom(p))
?c -> quote do: for(p <- String.split(unquote(string)), do: String.to_char_list(p))
end
end
end
## Shared functions
defp optimize_boolean({:case, meta, args}) do
{:case, [{:optimize_boolean, true}|meta], args}
end
# We need this check only for bootstrap purposes.
# Once Kernel is loaded and we recompile, it is a no-op.
case :code.ensure_loaded(Kernel) do
{:module, _} ->
defp bootstraped?(_), do: true
{:error, _} ->
defp bootstraped?(module), do: :code.ensure_loaded(module) == {:module, module}
end
defp assert_module_scope(env, fun, arity) do
case env.module do
nil -> raise ArgumentError, "cannot invoke #{fun}/#{arity} outside module"
_ -> :ok
end
end
defp assert_no_function_scope(env, fun, arity) do
case env.function do
nil -> :ok
_ -> raise ArgumentError, "cannot invoke #{fun}/#{arity} inside function/macro"
end
end
defp env_stacktrace(env) do
case bootstraped?(Path) do
true -> Macro.Env.stacktrace(env)
false -> []
end
end
end
| 25.422502 | 120 | 0.630736 |
ff867a5447c96b984bf2fc5ac61a42831c9c80f2 | 534 | ex | Elixir | lib/input_event/enumerate.ex | fhunleth/input_event | eab66b277f7d290ece3820229d9c937e71c8ad25 | [
"Apache-2.0"
] | null | null | null | lib/input_event/enumerate.ex | fhunleth/input_event | eab66b277f7d290ece3820229d9c937e71c8ad25 | [
"Apache-2.0"
] | null | null | null | lib/input_event/enumerate.ex | fhunleth/input_event | eab66b277f7d290ece3820229d9c937e71c8ad25 | [
"Apache-2.0"
] | null | null | null | defmodule InputEvent.Enumerate do
@doc """
Return the paths to all device files
"""
@spec all_devices() :: [Path.t()]
def all_devices() do
Path.wildcard("/dev/input/event*")
end
@doc """
Enumerate all input event devices
"""
@spec enumerate() :: [{String.t(), Info.t()}]
def enumerate() do
all_devices()
|> Enum.map(&get_info/1)
end
defp get_info(path) do
{:ok, server} = InputEvent.start_link(path)
info = InputEvent.info(server)
InputEvent.stop(server)
{path, info}
end
end
| 20.538462 | 47 | 0.629213 |
ff868ab2f7b02162570cbb5c562607a9d4bc6253 | 2,478 | ex | Elixir | clients/analytics_data/lib/google_api/analytics_data/v1alpha/model/metric.ex | mcrumm/elixir-google-api | 544f22797cec52b3a23dfb6e39117f0018448610 | [
"Apache-2.0"
] | null | null | null | clients/analytics_data/lib/google_api/analytics_data/v1alpha/model/metric.ex | mcrumm/elixir-google-api | 544f22797cec52b3a23dfb6e39117f0018448610 | [
"Apache-2.0"
] | 1 | 2020-12-18T09:25:12.000Z | 2020-12-18T09:25:12.000Z | clients/analytics_data/lib/google_api/analytics_data/v1alpha/model/metric.ex | mcrumm/elixir-google-api | 544f22797cec52b3a23dfb6e39117f0018448610 | [
"Apache-2.0"
] | null | null | null | # Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.
defmodule GoogleApi.AnalyticsData.V1alpha.Model.Metric do
@moduledoc """
The quantitative measurements of a report. For example, the metric `eventCount` is the total number of events. Requests are allowed up to 10 metrics.
## Attributes
* `expression` (*type:* `String.t`, *default:* `nil`) - A mathematical expression for derived metrics. For example, the metric Event count per user is `eventCount/totalUsers`.
* `invisible` (*type:* `boolean()`, *default:* `nil`) - Indicates if a metric is invisible in the report response. If a metric is invisible, the metric will not produce a column in the response, but can be used in `metricFilter`, `orderBys`, or a metric `expression`.
* `name` (*type:* `String.t`, *default:* `nil`) - The name of the metric. See the [API Metrics](https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema#metrics) for the list of metric names. If `expression` is specified, `name` can be any string that you would like. For example if `expression` is `screenPageViews/sessions`, you could call that metric's name = `viewsPerSession`. Metrics are referenced by `name` in `metricFilter`, `orderBys`, and metric `expression`.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:expression => String.t(),
:invisible => boolean(),
:name => String.t()
}
field(:expression)
field(:invisible)
field(:name)
end
defimpl Poison.Decoder, for: GoogleApi.AnalyticsData.V1alpha.Model.Metric do
def decode(value, options) do
GoogleApi.AnalyticsData.V1alpha.Model.Metric.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.AnalyticsData.V1alpha.Model.Metric do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 46.754717 | 496 | 0.730831 |
ff86904363f0cfe25952c950c3bcecc96644f17c | 1,075 | exs | Elixir | config/config.exs | Project-ShangriLa/sana_server_phoenix | d2ea4cc023d02e7249ae9267bb2b41a212b79ce7 | [
"Apache-2.0"
] | 5 | 2015-11-07T11:27:08.000Z | 2017-06-23T00:54:20.000Z | config/config.exs | Project-ShangriLa/sana_server_phoenix | d2ea4cc023d02e7249ae9267bb2b41a212b79ce7 | [
"Apache-2.0"
] | null | null | null | config/config.exs | Project-ShangriLa/sana_server_phoenix | d2ea4cc023d02e7249ae9267bb2b41a212b79ce7 | [
"Apache-2.0"
] | 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 :sana_server_phoenix, SanaServerPhoenix.Endpoint,
url: [host: "localhost"],
root: Path.dirname(__DIR__),
secret_key_base: "1wPBy2oOPyw398Rni9aSvg3TSzWp08zb/zMrXEm+hiRj0vrc7oYyJtUgXM8i9CxB",
render_errors: [accepts: ~w(html json)],
pubsub: [name: SanaServerPhoenix.PubSub,
adapter: Phoenix.PubSub.PG2]
# Configures Elixir's Logger
config :logger, backends: [{LoggerFileBackend, :file}]
config :logger, :file,
path: "./log/sana_api_phoenix.log",
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env}.exs"
# Configure phoenix generators
config :phoenix, :generators,
migration: true,
binary_id: false
| 33.59375 | 86 | 0.76 |
ff86bcf1bc0fc52c6c559a7f77974e191a48e28c | 1,540 | exs | Elixir | test/services/coto_search_service_test.exs | fmorita/cotoami | e3eb92ad15829f99cf3e8974077f135e789924cf | [
"Apache-2.0"
] | null | null | null | test/services/coto_search_service_test.exs | fmorita/cotoami | e3eb92ad15829f99cf3e8974077f135e789924cf | [
"Apache-2.0"
] | null | null | null | test/services/coto_search_service_test.exs | fmorita/cotoami | e3eb92ad15829f99cf3e8974077f135e789924cf | [
"Apache-2.0"
] | null | null | null | defmodule Cotoami.CotoSearchServiceTest do
use Cotoami.ModelCase
import ShorterMaps
alias Cotoami.{
Repo, EmailUser, Coto,
AmishiService, CotoService, CotonomaService, CotoSearchService
}
setup do
amishi_a = AmishiService.insert_or_update!(%EmailUser{email: "amishi_a@example.com"})
amishi_b = AmishiService.insert_or_update!(%EmailUser{email: "amishi_b@example.com"})
{%Coto{cotonoma: cotonoma_a}, _} = CotonomaService.create!(amishi_a, "cotonoma a", false)
~M{amishi_a, amishi_b, cotonoma_a}
end
describe "when there are private cotos by amishi_a" do
setup ~M{amishi_a, cotonoma_a} do
CotoService.create!(amishi_a, "Search has become an important feature.")
CotoService.create!(amishi_a, "You are often asked to add search.", nil, cotonoma_a.id)
:ok
end
test "one coto can be searched by amishi_a", ~M{amishi_a} do
assert search(amishi_a, "important") == [
"Search has become an important feature."
]
end
test "multiple results should be sorted in ascending order of date", ~M{amishi_a} do
assert search(amishi_a, "search") == [
"You are often asked to add search.",
"Search has become an important feature."
]
end
test "no cotos can be searched by amishi_b", ~M{amishi_b} do
assert search(amishi_b, "search") == []
end
end
defp search(amishi, search_string) do
Coto
|> CotoSearchService.search(amishi, search_string)
|> Repo.all()
|> Enum.map(&(&1.content))
end
end
| 31.428571 | 93 | 0.680519 |
ff86c9f6efe490610045c2b130a2fc51a4f95a28 | 514 | exs | Elixir | phoenix_maru/config/test.exs | elixir-maru/maru_examples | f0dcbf3c17c9df8b89b378953b71b54a53047806 | [
"MIT"
] | 27 | 2016-12-28T15:00:19.000Z | 2021-11-09T12:55:23.000Z | phoenix_maru/config/test.exs | elixir-maru/maru_examples | f0dcbf3c17c9df8b89b378953b71b54a53047806 | [
"MIT"
] | 5 | 2017-02-13T13:11:55.000Z | 2019-07-22T19:38:09.000Z | phoenix_maru/config/test.exs | elixir-maru/maru_examples | f0dcbf3c17c9df8b89b378953b71b54a53047806 | [
"MIT"
] | 8 | 2017-02-08T10:18:50.000Z | 2020-06-01T11:42:04.000Z | use Mix.Config
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :phoenix_maru, PhoenixMaru.Endpoint,
http: [port: 4001],
server: false
# Print only warnings and errors during test
config :logger, level: :warn
# Configure your database
config :phoenix_maru, PhoenixMaru.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "postgres",
database: "phoenix_maru_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox
| 25.7 | 56 | 0.745136 |
ff86e43530786a58be1f4826a8e5440fe7ce33ca | 4,303 | ex | Elixir | lib/updater.ex | noizu-labs/elixometer | c6ab9542f8280025d94aed0936e67bf1a573caae | [
"Apache-2.0"
] | null | null | null | lib/updater.ex | noizu-labs/elixometer | c6ab9542f8280025d94aed0936e67bf1a573caae | [
"Apache-2.0"
] | null | null | null | lib/updater.ex | noizu-labs/elixometer | c6ab9542f8280025d94aed0936e67bf1a573caae | [
"Apache-2.0"
] | null | null | null | defmodule Elixometer.Updater do
@moduledoc false
@max_messages 1000
@default_formatter Elixometer.Utils
import Elixometer, only: [ensure_registered: 2, add_counter: 2, add_counter: 1]
use GenServer
def init(_args) do
config = Application.get_env(:elixometer, __MODULE__, [])
max_messages = Keyword.get(config, :max_messages, @max_messages)
formatter = Keyword.get(config, :formatter, @default_formatter)
{:ok, pobox} = :pobox.start_link(self(), max_messages, :queue)
Process.register(pobox, :elixometer_pobox)
activate_pobox()
{:ok, %{formatter: formatter}}
end
def start_link(args) do
GenServer.start_link(__MODULE__, args, name: __MODULE__)
end
def timer(name, units, elapsed) do
:pobox.post(:elixometer_pobox, {:timer, name, units, elapsed})
end
def gauge(name, value) do
:pobox.post(:elixometer_pobox, {:gauge, name, value})
end
def fast_counter(_name, {m, f}, _reset_seconds) do
apply(m, f, [])
end
def declare_fast_counter(name, target, reset_seconds) do
:pobox.post(:elixometer_pobox, {:declare_fast_counter, name, target, reset_seconds})
end
def counter(name, delta, reset_seconds) do
:pobox.post(:elixometer_pobox, {:counter, name, delta, reset_seconds})
end
def spiral(name, delta, opts) do
:pobox.post(:elixometer_pobox, {:spiral, name, delta, opts})
end
def histogram(name, delta, reset_seconds, truncate) do
:pobox.post(:elixometer_pobox, {:histogram, name, delta, reset_seconds, truncate})
end
def handle_info({:mail, _pid, messages, _, _}, %{formatter: formatter} = state) do
Enum.each(messages, fn message ->
do_update(message, formatter)
end)
activate_pobox()
{:noreply, state}
end
def do_update({:histogram, name, delta, aggregate_seconds, truncate}, formatter) do
monitor = do_format(formatter, :histograms, name)
ensure_registered(monitor, fn ->
:exometer.new(
monitor,
:histogram,
time_span: :timer.seconds(aggregate_seconds),
truncate: truncate
)
end)
:exometer.update(monitor, delta)
end
def do_update({:spiral, name, delta, opts}, formatter) do
monitor = do_format(formatter, :spirals, name)
ensure_registered(monitor, fn ->
:exometer.new(monitor, :spiral, opts)
end)
:exometer.update(monitor, delta)
end
def do_update({:counter, name, delta, reset_seconds}, formatter) do
monitor = do_format(formatter, :counters, name)
ensure_registered(monitor, fn ->
:exometer.new(monitor, :counter, [])
if is_nil(reset_seconds) do
add_counter(monitor)
else
add_counter(monitor, reset_seconds * 1000)
end
end)
:exometer.update(monitor, delta)
end
def do_update({:declare_fast_counter, name, {m, f}, reset_seconds}, formatter) do
monitor = do_format(formatter, :counters, name)
:exometer.new(monitor, :fast_counter, [{:function, {m, f}}])
if is_nil(reset_seconds) do
add_counter(monitor)
else
add_counter(monitor, reset_seconds * 1000)
end
Elixometer.subscribe(monitor)
rescue
e in ErlangError -> e
end
def do_update({:gauge, name, value}, formatter) do
monitor = do_format(formatter, :gauges, name)
ensure_registered(monitor, fn ->
:exometer.new(monitor, :gauge, [])
end)
:exometer.update(monitor, value)
end
def do_update({:timer, name, units, elapsed_us}, formatter) do
timer = do_format(formatter, :timers, name)
ensure_registered(timer, fn ->
:exometer.new(timer, :histogram, [])
end)
elapsed_time =
cond do
units in [:nanosecond, :nanoseconds] -> elapsed_us * 1000
units in [:micros, :microsecond, :microseconds] -> elapsed_us
units in [:millis, :millisecond, :milliseconds] -> div(elapsed_us, 1000)
units in [:second, :seconds] -> div(elapsed_us, 1_000_000)
end
:exometer.update(timer, elapsed_time)
end
defp activate_pobox do
:pobox.active(:elixometer_pobox, fn msg, _ -> {{:ok, msg}, :nostate} end, :nostate)
end
defp do_format(formatter, metric, name) when is_function(formatter) do
formatter.(metric, name)
end
defp do_format(formatter, metric, name) do
formatter.format(metric, name)
end
end
| 27.234177 | 88 | 0.675343 |
ff86ed339cb05da0e8119d9b22099e194189bacb | 10,625 | ex | Elixir | lib/iex/lib/iex/evaluator.ex | QuentinDanjou/elixir | 09d59d4d19cb11b96bdc5786c70f6a0ca48050c8 | [
"Apache-2.0"
] | 1 | 2019-10-11T01:36:26.000Z | 2019-10-11T01:36:26.000Z | lib/iex/lib/iex/evaluator.ex | hiro-riveros/elixir | c6da1cfaa83e420726be25617440fc09f118de52 | [
"Apache-2.0"
] | null | null | null | lib/iex/lib/iex/evaluator.ex | hiro-riveros/elixir | c6da1cfaa83e420726be25617440fc09f118de52 | [
"Apache-2.0"
] | null | null | null | defmodule IEx.Evaluator do
@moduledoc false
@doc """
Eval loop for an IEx session. Its responsibilities include:
* loading of .iex files
* evaluating code
* trapping exceptions in the code being evaluated
* keeping expression history
"""
def init(command, server, leader, opts) do
old_leader = Process.group_leader()
Process.group_leader(self(), leader)
old_server = Process.get(:iex_server)
Process.put(:iex_server, server)
evaluator = Process.get(:iex_evaluator)
Process.put(:iex_evaluator, command)
state = loop_state(server, IEx.History.init(), opts)
command == :ack && :proc_lib.init_ack(self())
try do
loop(state)
after
Process.group_leader(self(), old_leader)
if old_server do
Process.put(:iex_server, old_server)
else
Process.delete(:iex_server)
end
cond do
is_nil(evaluator) ->
Process.delete(:iex_evaluator)
evaluator != :ack ->
# Ensure propagation to non-root level evaluators
send(self(), {:done, server})
true ->
:ok
end
:ok
end
end
@doc """
Gets a value out of the binding, using the provided
variable name and map key path.
"""
@spec value_from_binding(pid, pid, atom, [atom]) :: {:ok, any} | :error
def value_from_binding(evaluator, server, var_name, map_key_path) do
ref = make_ref()
send(evaluator, {:value_from_binding, server, ref, self(), var_name, map_key_path})
receive do
{^ref, result} -> result
after
5000 -> :error
end
end
@doc """
Gets a list of variables out of the binding that match the passed
variable prefix.
"""
@spec variables_from_binding(pid, pid, String.t()) :: [String.t()]
def variables_from_binding(evaluator, server, variable_prefix) do
ref = make_ref()
send(evaluator, {:variables_from_binding, server, ref, self(), variable_prefix})
receive do
{^ref, result} -> result
after
5000 -> []
end
end
@doc """
Returns the named fields from the current session environment.
"""
@spec fields_from_env(pid, pid, [atom]) :: %{optional(atom) => term}
def fields_from_env(evaluator, server, fields) do
ref = make_ref()
send(evaluator, {:fields_from_env, server, ref, self(), fields})
receive do
{^ref, result} -> result
after
5000 -> %{}
end
end
defp loop(%{server: server} = state) do
receive do
{:eval, ^server, code, iex_state} ->
{result, state} = eval(code, iex_state, state)
send(server, {:evaled, self(), result})
loop(state)
{:fields_from_env, ^server, ref, receiver, fields} ->
send(receiver, {ref, Map.take(state.env, fields)})
loop(state)
{:value_from_binding, ^server, ref, receiver, var_name, map_key_path} ->
value = traverse_binding(state.binding, var_name, map_key_path)
send(receiver, {ref, value})
loop(state)
{:variables_from_binding, ^server, ref, receiver, var_prefix} ->
value = find_matched_variables(state.binding, var_prefix)
send(receiver, {ref, value})
loop(state)
{:done, ^server} ->
:ok
end
end
defp traverse_binding(binding, var_name, map_key_path) do
accumulator = Keyword.fetch(binding, var_name)
Enum.reduce(map_key_path, accumulator, fn
key, {:ok, map} when is_map(map) -> Map.fetch(map, key)
_key, _acc -> :error
end)
end
defp find_matched_variables(binding, var_prefix) do
for {var_name, _value} <- binding,
is_atom(var_name),
var_name = Atom.to_string(var_name),
String.starts_with?(var_name, var_prefix),
do: var_name
end
defp loop_state(server, history, opts) do
env = opts[:env] || :elixir.env_for_eval(file: "iex")
env = %{env | prematch_vars: :apply}
{_, _, env, scope} = :elixir.eval_quoted(quote(do: import(IEx.Helpers)), [], env)
stacktrace = opts[:stacktrace]
binding = opts[:binding] || []
state = %{
binding: binding,
scope: scope,
env: env,
server: server,
history: history,
stacktrace: stacktrace
}
case opts[:dot_iex_path] do
"" -> state
path -> load_dot_iex(state, path)
end
end
defp load_dot_iex(state, path) do
candidates =
if path do
[path]
else
Enum.map([".iex.exs", "~/.iex.exs"], &Path.expand/1)
end
path = Enum.find(candidates, &File.regular?/1)
if is_nil(path) do
state
else
eval_dot_iex(state, path)
end
end
defp eval_dot_iex(state, path) do
try do
code = File.read!(path)
quoted = :elixir.string_to_quoted!(String.to_charlist(code), 1, path, [])
# Evaluate the contents in the same environment server_loop will run in
env = :elixir.env_for_eval(state.env, file: path, line: 1)
Process.put(:iex_imported_paths, MapSet.new([path]))
{_result, binding, env, _scope} = :elixir.eval_forms(quoted, state.binding, env)
%{state | binding: binding, env: :elixir.env_for_eval(env, file: "iex", line: 1)}
catch
kind, error ->
io_result("Error while evaluating: #{path}")
print_error(kind, error, __STACKTRACE__)
state
after
Process.delete(:iex_imported_paths)
end
end
# Instead of doing just :elixir.eval, we first parse the expression to see
# if it's well formed. If parsing succeeds, we evaluate the AST as usual.
#
# If parsing fails, this might be a TokenMissingError which we treat in
# a special way (to allow for continuation of an expression on the next
# line in IEx).
#
# Returns updated state.
#
# The first two clauses provide support for the break-trigger allowing to
# break out from a pending incomplete expression. See
# https://github.com/elixir-lang/elixir/issues/1089 for discussion.
@break_trigger '#iex:break\n'
defp eval(code, iex_state, state) do
try do
do_eval(String.to_charlist(code), iex_state, state)
catch
kind, error ->
print_error(kind, error, __STACKTRACE__)
{%{iex_state | cache: ''}, state}
end
end
defp do_eval(@break_trigger, %IEx.State{cache: ''} = iex_state, state) do
{iex_state, state}
end
defp do_eval(@break_trigger, iex_state, _state) do
:elixir_errors.parse_error(iex_state.counter, "iex", "incomplete expression", "")
end
defp do_eval(latest_input, iex_state, state) do
code = iex_state.cache ++ latest_input
line = iex_state.counter
put_history(state)
put_whereami(state)
quoted = Code.string_to_quoted(code, line: line, file: "iex")
handle_eval(quoted, code, line, iex_state, state)
after
Process.delete(:iex_history)
Process.delete(:iex_whereami)
end
defp put_history(%{history: history}) do
Process.put(:iex_history, history)
end
defp put_whereami(%{env: %{file: "iex"}}) do
:ok
end
defp put_whereami(%{env: %{file: file, line: line}, stacktrace: stacktrace}) do
Process.put(:iex_whereami, {file, line, stacktrace})
end
defp handle_eval({:ok, forms}, code, line, iex_state, state) do
{result, binding, env, scope} =
:elixir.eval_forms(forms, state.binding, state.env, state.scope)
unless result == IEx.dont_display_result() do
io_inspect(result)
end
iex_state = %{iex_state | cache: '', counter: iex_state.counter + 1}
state = %{state | env: env, scope: scope, binding: binding}
{iex_state, update_history(state, line, code, result)}
end
defp handle_eval({:error, {_, _, ""}}, code, _line, iex_state, state) do
# Update iex_state.cache so that IEx continues to add new input to
# the unfinished expression in "code"
{%{iex_state | cache: code}, state}
end
defp handle_eval({:error, {line, error, token}}, _code, _line, _iex_state, _state) do
# Encountered malformed expression
:elixir_errors.parse_error(line, "iex", error, token)
end
defp update_history(state, counter, _cache, result) do
history_size = IEx.Config.history_size()
update_in(state.history, &IEx.History.append(&1, {counter, result}, history_size))
end
defp io_inspect(result) do
io_result(inspect(result, IEx.inspect_opts()))
end
defp io_result(result) do
IO.puts(:stdio, IEx.color(:eval_result, result))
end
## Error handling
defp print_error(kind, reason, stacktrace) do
{blamed, stacktrace} = Exception.blame(kind, reason, stacktrace)
ansidata =
case blamed do
%FunctionClauseError{} ->
{_, inspect_opts} = pop_in(IEx.inspect_opts()[:syntax_colors][:reset])
banner = Exception.format_banner(kind, reason, stacktrace)
blame = FunctionClauseError.blame(blamed, &inspect(&1, inspect_opts), &blame_match/2)
[IEx.color(:eval_error, banner), pad(blame)]
_ ->
[IEx.color(:eval_error, Exception.format_banner(kind, blamed, stacktrace))]
end
stackdata = Exception.format_stacktrace(prune_stacktrace(stacktrace))
IO.write(:stdio, [ansidata, ?\n, IEx.color(:stack_info, stackdata)])
end
defp pad(string) do
" " <> String.replace(string, "\n", "\n ")
end
defp blame_match(%{match?: true, node: node}, _), do: Macro.to_string(node)
defp blame_match(%{match?: false, node: node}, _), do: blame_ansi(:blame_diff, "-", node)
defp blame_match(_, string), do: string
defp blame_ansi(color, no_ansi, node) do
case IEx.Config.color(color) do
nil ->
no_ansi <> Macro.to_string(node) <> no_ansi
ansi ->
[ansi | Macro.to_string(node)]
|> IO.ANSI.format(true)
|> IO.iodata_to_binary()
end
end
@elixir_internals [:elixir, :elixir_expand, :elixir_compiler, :elixir_module] ++
[:elixir_clauses, :elixir_lexical, :elixir_def, :elixir_map] ++
[:elixir_erl, :elixir_erl_clauses, :elixir_erl_pass]
defp prune_stacktrace(stacktrace) do
# The order in which each drop_while is listed is important.
# For example, the user may call Code.eval_string/2 in IEx
# and if there is an error we should not remove erl_eval
# and eval_bits information from the user stacktrace.
stacktrace
|> Enum.reverse()
|> Enum.drop_while(&(elem(&1, 0) == :proc_lib))
|> Enum.drop_while(&(elem(&1, 0) == __MODULE__))
|> Enum.drop_while(&(elem(&1, 0) == :elixir))
|> Enum.drop_while(&(elem(&1, 0) in [:erl_eval, :eval_bits]))
|> Enum.reverse()
|> Enum.reject(&(elem(&1, 0) in @elixir_internals))
end
end
| 29.929577 | 95 | 0.644141 |
ff8705186ed9339d6b303aa853acfc724becadc8 | 8,965 | ex | Elixir | lib/phoenix/token.ex | joshchernoff/phoenix | cd1541a8bc12cdb2501be6b08403558e82c5b72b | [
"MIT"
] | 1 | 2020-04-14T09:49:46.000Z | 2020-04-14T09:49:46.000Z | lib/phoenix/token.ex | joshchernoff/phoenix | cd1541a8bc12cdb2501be6b08403558e82c5b72b | [
"MIT"
] | 1 | 2020-11-08T08:30:10.000Z | 2020-11-08T08:30:10.000Z | lib/phoenix/token.ex | joshchernoff/phoenix | cd1541a8bc12cdb2501be6b08403558e82c5b72b | [
"MIT"
] | null | null | null | defmodule Phoenix.Token do
@moduledoc """
Tokens provide a way to generate and verify bearer
tokens for use in Channels or API authentication.
The data stored in the token is signed to prevent tampering
but not encrypted. This means it is safe to store identification
information (such as user IDs) but should not be used to store
confidential information (such as credit card numbers).
## Example
When generating a unique token for use in an API or Channel
it is advised to use a unique identifier for the user, typically
the id from a database. For example:
iex> user_id = 1
iex> token = Phoenix.Token.sign(MyApp.Endpoint, "user salt", user_id)
iex> Phoenix.Token.verify(MyApp.Endpoint, "user salt", token, max_age: 86400)
{:ok, 1}
In that example we have a user's id, we generate a token and
verify it using the secret key base configured in the given
`endpoint`. We guarantee the token will only be valid for one day
by setting a max age (recommended).
The first argument to both `sign/4` and `verify/4` can be one of:
* the module name of a Phoenix endpoint (shown above) - where
the secret key base is extracted from the endpoint
* `Plug.Conn` - where the secret key base is extracted from the
endpoint stored in the connection
* `Phoenix.Socket` - where the secret key base is extracted from
the endpoint stored in the socket
* a string, representing the secret key base itself. A key base
with at least 20 randomly generated characters should be used
to provide adequate entropy
The second argument is a [cryptographic salt](https://en.wikipedia.org/wiki/Salt_(cryptography))
which must be the same in both calls to `sign/4` and `verify/4`.
For instance, it may be called "user auth" when generating a token
that will be used to authenticate users on channels or on your APIs.
The third argument can be any term (string, int, list, etc.)
that you wish to codify into the token. Upon valid verification,
this same term will be extracted from the token.
## Usage
Once a token is signed, we can send it to the client in multiple ways.
One is via the meta tag:
<%= tag :meta, name: "channel_token",
content: Phoenix.Token.sign(@conn, "user salt", @current_user.id) %>
Or an endpoint that returns it:
def create(conn, params) do
user = User.create(params)
render(conn, "user.json",
%{token: Phoenix.Token.sign(conn, "user salt", user.id), user: user})
end
Once the token is sent, the client may now send it back to the server
as an authentication mechanism. For example, we can use it to authenticate
a user on a Phoenix channel:
defmodule MyApp.UserSocket do
use Phoenix.Socket
def connect(%{"token" => token}, socket, _connect_info) do
case Phoenix.Token.verify(socket, "user salt", token, max_age: 86400) do
{:ok, user_id} ->
socket = assign(socket, :user, Repo.get!(User, user_id))
{:ok, socket}
{:error, _} ->
:error
end
end
def connect(_params, _socket, _connect_info), do: :error
end
In this example, the phoenix.js client will send the token in the
`connect` command which is then validated by the server.
`Phoenix.Token` can also be used for validating APIs, handling
password resets, e-mail confirmation and more.
"""
require Logger
@doc """
Encodes and signs data into a token you can send to clients.
## Options
* `:key_iterations` - option passed to `Plug.Crypto.KeyGenerator`
when generating the encryption and signing keys. Defaults to 1000
* `:key_length` - option passed to `Plug.Crypto.KeyGenerator`
when generating the encryption and signing keys. Defaults to 32
* `:key_digest` - option passed to `Plug.Crypto.KeyGenerator`
when generating the encryption and signing keys. Defaults to `:sha256`
* `:signed_at` - set the timestamp of the token in seconds.
Defaults to `System.system_time(:second)`
"""
def sign(context, salt, data, opts \\ []) when is_binary(salt) do
context
|> get_key_base()
|> Plug.Crypto.sign(salt, data, opts)
end
@doc """
Encodes, encrypts, and signs data into a token you can send to clients.
## Options
* `:key_iterations` - option passed to `Plug.Crypto.KeyGenerator`
when generating the encryption and signing keys. Defaults to 1000
* `:key_length` - option passed to `Plug.Crypto.KeyGenerator`
when generating the encryption and signing keys. Defaults to 32
* `:key_digest` - option passed to `Plug.Crypto.KeyGenerator`
when generating the encryption and signing keys. Defaults to `:sha256`
* `:signed_at` - set the timestamp of the token in seconds.
Defaults to `System.system_time(:second)`
"""
def encrypt(context, secret, data, opts \\ []) when is_binary(secret) do
context
|> get_key_base()
|> Plug.Crypto.encrypt(secret, data, opts)
end
@doc """
Decodes the original data from the token and verifies its integrity.
## Examples
In this scenario we will create a token, sign it, then provide it to a client
application. The client will then use this token to authenticate requests for
resources from the server. See `Phoenix.Token` summary for more info about
creating tokens.
iex> user_id = 99
iex> secret = "kjoy3o1zeidquwy1398juxzldjlksahdk3"
iex> user_salt = "user salt"
iex> token = Phoenix.Token.sign(secret, user_salt, user_id)
The mechanism for passing the token to the client is typically through a
cookie, a JSON response body, or HTTP header. For now, assume the client has
received a token it can use to validate requests for protected resources.
When the server receives a request, it can use `verify/4` to determine if it
should provide the requested resources to the client:
iex> Phoenix.Token.verify(secret, user_salt, token, max_age: 86400)
{:ok, 99}
In this example, we know the client sent a valid token because `verify/4`
returned a tuple of type `{:ok, user_id}`. The server can now proceed with
the request.
However, if the client had sent an expired or otherwise invalid token
`verify/4` would have returned an error instead:
iex> Phoenix.Token.verify(secret, user_salt, expired, max_age: 86400)
{:error, :expired}
iex> Phoenix.Token.verify(secret, user_salt, invalid, max_age: 86400)
{:error, :invalid}
## Options
* `:max_age` - verifies the token only if it has been generated
"max age" ago in seconds. A reasonable value is 1 day (86400
seconds)
* `:key_iterations` - option passed to `Plug.Crypto.KeyGenerator`
when generating the encryption and signing keys. Defaults to 1000
* `:key_length` - option passed to `Plug.Crypto.KeyGenerator`
when generating the encryption and signing keys. Defaults to 32
* `:key_digest` - option passed to `Plug.Crypto.KeyGenerator`
when generating the encryption and signing keys. Defaults to `:sha256`
"""
def verify(context, salt, token, opts \\ []) when is_binary(salt) do
context
|> get_key_base()
|> Plug.Crypto.verify(salt, token, opts)
end
@doc """
Decrypts the original data from the token and verifies its integrity.
## Options
* `:max_age` - verifies the token only if it has been generated
"max age" ago in seconds. A reasonable value is 1 day (86400
seconds)
* `:key_iterations` - option passed to `Plug.Crypto.KeyGenerator`
when generating the encryption and signing keys. Defaults to 1000
* `:key_length` - option passed to `Plug.Crypto.KeyGenerator`
when generating the encryption and signing keys. Defaults to 32
* `:key_digest` - option passed to `Plug.Crypto.KeyGenerator`
when generating the encryption and signing keys. Defaults to `:sha256`
"""
def decrypt(context, secret, token, opts \\ []) when is_binary(secret) do
context
|> get_key_base()
|> Plug.Crypto.decrypt(secret, token, opts)
end
## Helpers
defp get_key_base(%Plug.Conn{} = conn),
do: conn |> Phoenix.Controller.endpoint_module() |> get_endpoint_key_base()
defp get_key_base(%Phoenix.Socket{} = socket),
do: get_endpoint_key_base(socket.endpoint)
defp get_key_base(endpoint) when is_atom(endpoint),
do: get_endpoint_key_base(endpoint)
defp get_key_base(string) when is_binary(string) and byte_size(string) >= 20,
do: string
defp get_endpoint_key_base(endpoint) do
endpoint.config(:secret_key_base) ||
raise """
no :secret_key_base configuration found in #{inspect(endpoint)}.
Ensure your environment has the necessary mix configuration. For example:
config :my_app, MyApp.Endpoint,
secret_key_base: ...
"""
end
end
| 37.19917 | 98 | 0.691578 |
ff870692d7387006a3d1a89b9001a1f04f45ed27 | 7,387 | ex | Elixir | lib/membrane_ffmpeg_video_filter/text_overlay.ex | membraneframework/membrane_ffmpeg_video_filter_plugin | b9585d3830ce66c3657989c6edee0dc9c067287c | [
"Apache-2.0"
] | null | null | null | lib/membrane_ffmpeg_video_filter/text_overlay.ex | membraneframework/membrane_ffmpeg_video_filter_plugin | b9585d3830ce66c3657989c6edee0dc9c067287c | [
"Apache-2.0"
] | null | null | null | lib/membrane_ffmpeg_video_filter/text_overlay.ex | membraneframework/membrane_ffmpeg_video_filter_plugin | b9585d3830ce66c3657989c6edee0dc9c067287c | [
"Apache-2.0"
] | null | null | null | defmodule Membrane.FFmpeg.VideoFilter.TextOverlay do
@moduledoc """
Element adding text overlay to raw video frames - using 'drawtext' video filter from FFmpeg Library.
(https://ffmpeg.org/ffmpeg-filters.html#drawtext-1).
Element allows for specifying most commonly used 'drawtext' settings (such as fontsize, fontcolor) through element options.
The element expects each frame to be received in a separate buffer.
Additionally, the element has to receive proper caps with picture format and dimensions.
"""
use Membrane.Filter
require Membrane.Logger
alias __MODULE__.Native
alias Membrane.{Buffer, RawVideo}
def_options text: [
type: :binary,
description:
"Text to be displayed on video. Either text or text_intervals must be provided",
default: nil
],
text_intervals: [
type: :list,
spec: [{{Time.t(), Time.t() | :infinity}, String.t()}],
description:
"List of time intervals when each given text should appear. Intervals should not overlap.
Either text or text_intervals must be provided",
default: []
],
font_size: [
type: :int,
description: "Size of the displayed font",
default: 12
],
font_color: [
type: :binary,
description:
"Choose font color according to the ffmpeg color syntax (https://ffmpeg.org/ffmpeg-utils.html#color-syntax)",
default: "black"
],
font_file: [
type: :binary,
description:
"Path to the file with the desired font. If not set, default font fallback from fontconfig is used",
default: nil
],
box?: [
type: :boolean,
description: "Set to true if a box is to be displayed behind the text",
default: false
],
box_color: [
type: :binary,
description: "If the box? is set to true, display a box in the given color",
default: "white"
],
border_width: [
type: :int,
description: "Set the width of the border around the text",
default: 0
],
border_color: [
type: :binary,
description: "Set the color of the border, if exists",
default: "black"
],
horizontal_align: [
type: :atom,
spec: :left | :right | :center,
description: "Horizontal position of the displayed text",
default: :left
],
vertical_align: [
type: :atom,
spec: :top | :bottom | :center,
description: "Vertical position of the displayed text",
default: :bottom
]
def_input_pad :input,
demand_mode: :auto,
demand_unit: :buffers,
caps: {RawVideo, aligned: true}
def_output_pad :output,
demand_mode: :auto,
caps: {RawVideo, aligned: true}
@impl true
def handle_init(options) do
text_intervals = convert_to_text_intervals(options)
state =
options
|> Map.from_struct()
|> Map.delete(:text)
|> Map.put(:text_intervals, text_intervals)
|> Map.put(:native_state, nil)
{:ok, state}
end
defp convert_to_text_intervals(%{text: nil, text_intervals: []}) do
Membrane.Logger.warn("No text or text_intervals provided, no text will be added to video")
[]
end
defp convert_to_text_intervals(%{text: nil, text_intervals: text_intervals}) do
text_intervals
end
defp convert_to_text_intervals(%{text: text, text_intervals: []}) do
[{{0, :infinity}, text}]
end
defp convert_to_text_intervals(%{text: _text, text_intervals: _text_intervals}) do
raise("Both 'text' and 'text_intervals' have been provided - choose one input method.")
end
@impl true
def handle_caps(:input, caps, _context, state) do
state = init_new_filter_if_needed(caps, state)
{{:ok, caps: {:output, caps}}, state}
end
@impl true
def handle_process(
:input,
%Buffer{pts: nil} = buffer,
_ctx,
%{text_intervals: intervals} = state
) do
case intervals do
[{{0, :infinity}, _text}] ->
buffer = Native.apply_filter!(buffer, state.native_state)
{{:ok, buffer: {:output, buffer}}, state}
_intervals ->
raise(
"Received stream without pts - cannot apply filter according to provided `text_intervals`"
)
end
end
def handle_process(:input, buffer, ctx, state) do
{buffer, state} = apply_filter_if_needed(buffer, ctx, state)
{{:ok, [buffer: {:output, buffer}]}, state}
end
# no text left to render
defp apply_filter_if_needed(buffer, _ctx, %{text_intervals: []} = state) do
{buffer, state}
end
defp apply_filter_if_needed(
buffer,
ctx,
%{native_state: native_state, text_intervals: [{interval, _text} | intervals]} = state
) do
cond do
frame_before_interval?(buffer, interval) ->
{buffer, state}
frame_after_interval?(buffer, interval) ->
state = %{state | text_intervals: intervals}
state = init_new_filter_if_needed(ctx.pads.input.caps, state)
apply_filter_if_needed(buffer, ctx, state)
frame_in_interval?(buffer, interval) ->
buffer = Native.apply_filter!(buffer, native_state)
{buffer, state}
end
end
defp init_new_filter_if_needed(_caps, %{text_intervals: []} = state), do: state
defp init_new_filter_if_needed(caps, %{text_intervals: [text_interval | _intervals]} = state) do
{_interval, text} = text_interval
case Native.create(
text,
caps.width,
caps.height,
caps.pixel_format,
state.font_size,
state.font_color,
font_file_to_native_format(state.font_file),
state.box?,
state.box_color,
state.border_width,
state.border_color,
state.horizontal_align,
state.vertical_align
) do
{:ok, native_state} ->
%{state | native_state: native_state}
{:error, reason} ->
raise inspect(reason)
end
end
defp frame_before_interval?(%Buffer{pts: pts}, {from, _to}) do
pts < from
end
defp frame_after_interval?(_buffer, {_from, :infinity}), do: false
defp frame_after_interval?(%Buffer{pts: pts}, {_from, to}) do
pts >= to
end
defp frame_in_interval?(%Buffer{pts: pts}, {from, :infinity}) do
pts >= from
end
defp frame_in_interval?(%Buffer{pts: pts}, {from, to}) do
pts < to and pts >= from
end
@impl true
def handle_end_of_stream(:input, _context, state) do
{{:ok, end_of_stream: :output, notify: {:end_of_stream, :input}}, state}
end
@impl true
def handle_prepared_to_stopped(_context, state) do
{:ok, %{state | native_state: nil}}
end
defp font_file_to_native_format(nil), do: ""
defp font_file_to_native_format(font_file), do: font_file
end
| 31.434043 | 127 | 0.5863 |
ff871082248a84560473f56c6606f31f9909bafa | 2,355 | ex | Elixir | web/controllers/api/v1/auth_controller.ex | AstridMN/elixir1 | f62347179628937cdb63fc14db0b0a32c689e0ae | [
"MIT"
] | 3 | 2017-04-18T06:23:18.000Z | 2018-01-05T04:14:57.000Z | web/controllers/api/v1/auth_controller.ex | AstridMN/elixir1 | f62347179628937cdb63fc14db0b0a32c689e0ae | [
"MIT"
] | 27 | 2016-11-04T19:56:11.000Z | 2017-03-26T22:34:55.000Z | web/controllers/api/v1/auth_controller.ex | AstridMN/elixir1 | f62347179628937cdb63fc14db0b0a32c689e0ae | [
"MIT"
] | 3 | 2016-10-05T11:56:42.000Z | 2017-03-05T14:37:10.000Z | defmodule MicrocrawlerWebapp.API.V1.AuthController do
use MicrocrawlerWebapp.Web, :controller
require Logger
alias MicrocrawlerWebapp.User
alias MicrocrawlerWebapp.Users
alias Comeonin.Bcrypt
alias Guardian.Plug
def sign_in(conn, %{"email" => email, "password" => password}) do
case Users.get(email) do
{:ok, user} ->
case Bcrypt.checkpw(password, user.password_hashed) do
true ->
new_conn = Plug.api_sign_in(conn, user)
client_jwt = Plug.current_token(new_conn)
new_conn
|> put_resp_header("authorization", "Bearer #{client_jwt}")
|> json(profile(user))
false ->
failure(conn)
end
error ->
Logger.debug inspect(error)
Bcrypt.dummy_checkpw()
conn
|> put_status(:unauthorized)
|> json(%{"error": "Invalid username or password"})
end
end
def sign_out(conn, _params) do
jwt = Plug.current_token(conn)
case jwt do
{:ok, _} ->
conn
|> json(%{"user": nil})
_ ->
conn
|> json(%{"user": nil})
end
end
def sign_up(conn, %{"email" => email, "password" => password}) do
data = %{
"email" => email,
"password" => password,
"password_confirmation" => password
}
case Users.insert(User.changeset(%User{}, data)) do
{:ok, user} -> {}
conn
|> json(%{"user": %{email: user.email}})
{:error, changeset} ->
Logger.debug inspect(changeset)
conn
|> put_status(400)
|> json(%{"errors": ["Some error ocurred"]})
end
end
def user_details(conn, _params) do
conn
|> json(profile(Plug.current_resource(conn)))
end
def renew_worker_jwt(conn, _params) do
{:ok, user} = Users.renew_token(Plug.current_resource(conn))
conn
|> Plug.api_sign_in(user)
|> json(profile(user))
end
defp profile(user) do
{:ok, worker_jwt, _} = Guardian.encode_and_sign(user, :worker)
%{"user": %{email: user.email, "workerJWT": worker_jwt}}
end
defp failure(conn) do
conn
|> put_status(:unauthorized)
|> json(%{message: "Authentication failed"})
end
def unauthenticated(conn, _params) do
conn
|> put_status(:unauthorized)
|> json(%{message: "Authentication required"})
end
end
| 25.053191 | 71 | 0.590658 |
ff87778c35c7d97ef293dac23edde33fbfc38888 | 3,946 | exs | Elixir | test/receiver_test.exs | Fritzelblitz/elixir-mllp | 8b1af9674a2f93a035f2849b04557c9d7e6b2d5e | [
"Apache-2.0"
] | null | null | null | test/receiver_test.exs | Fritzelblitz/elixir-mllp | 8b1af9674a2f93a035f2849b04557c9d7e6b2d5e | [
"Apache-2.0"
] | null | null | null | test/receiver_test.exs | Fritzelblitz/elixir-mllp | 8b1af9674a2f93a035f2849b04557c9d7e6b2d5e | [
"Apache-2.0"
] | null | null | null | defmodule ReceiverTest do
use ExUnit.Case, async: false
import ExUnit.CaptureLog
import Mox
setup :verify_on_exit!
setup :set_mox_global
alias MLLP.{FramingContext, Receiver}
require Logger
doctest Receiver
describe "Starting and stopping a receiver" do
test "creates and removes a receiver process" do
port = 8130
{:ok, %{pid: pid}} = Receiver.start(port)
assert Process.alive?(pid)
:ok = Receiver.stop(port)
refute Process.alive?(pid)
end
test "opens a port that can be connected to" do
port = 8131
{:ok, %{pid: pid}} = Receiver.start(port)
assert Process.alive?(pid)
log =
capture_log(fn ->
tcp_connect_send_and_close(port, "Hello? Anyone there?")
Process.sleep(100)
end)
assert log =~ "The DefaultPacketFramer is discarding unexpected data: Hello? Anyone there?"
assert Process.alive?(pid)
:ok = Receiver.stop(port)
end
test "on the same port twice returns error" do
port = 8132
{:ok, _} = Receiver.start(port)
assert capture_log(fn -> Receiver.start(port) end) =~
"port: 8132]) for reason :eaddrinuse (address already in use)"
end
end
describe "Receiver accepts non-default framer" do
test "non-default framer is given packets" do
message = "<testing>123</testing>"
test_pid = self()
MLLP.PacketFramerMock
|> expect(:handle_packet, fn ^message,
%FramingContext{dispatcher_module: MLLP.DispatcherMock} = state ->
Process.send(test_pid, :got_it, [])
{:ok, state}
end)
port = 8133
{:ok, %{pid: _pid}} = Receiver.start(port, MLLP.DispatcherMock, MLLP.PacketFramerMock)
tcp_connect_send_and_close(port, message)
assert_receive :got_it
end
end
describe "Receiver receiving data" do
test "frames and dispatches" do
port = 8134
{:ok, _} = Receiver.start(port)
msg = HL7.Examples.wikipedia_sample_hl7() |> MLLP.Envelope.wrap_message()
capture_log(fn ->
assert tcp_connect_send_receive_and_close(port, msg) =~ "MSA|AR|01052901"
end)
end
test "via process mailbox discards unhandled messages" do
port = 8135
{:ok, %{pid: pid}} = Receiver.start(port)
assert Process.alive?(pid)
log =
capture_log(fn ->
Process.send(pid, "junky junk", [])
Process.sleep(100)
end)
assert log =~ "unexpected message: \"junky junk\""
end
test "opens a port that can be connected to by two senders" do
port = 8136
{:ok, %{pid: pid}} = Receiver.start(port)
log =
capture_log(fn ->
{:ok, sock1} =
:gen_tcp.connect({127, 0, 0, 1}, port, [:binary, {:packet, 0}, {:active, false}])
{:ok, sock2} =
:gen_tcp.connect({127, 0, 0, 1}, port, [:binary, {:packet, 0}, {:active, false}])
:ok = :gen_tcp.send(sock1, "AAAA")
:ok = :gen_tcp.send(sock2, "BBBB")
:ok = :gen_tcp.send(sock1, "CCCC")
:ok = :gen_tcp.send(sock2, "DDDD")
Process.sleep(100)
end)
assert log =~ "AAAA"
assert log =~ "BBBB"
assert log =~ "CCCC"
assert log =~ "DDDD"
assert Process.alive?(pid)
:ok = Receiver.stop(port)
end
end
defp tcp_connect_send_receive_and_close(port, data_to_send) do
{:ok, sock} =
:gen_tcp.connect({127, 0, 0, 1}, port, [:binary, {:packet, 0}, {:active, false}])
:ok = :gen_tcp.send(sock, data_to_send)
{:ok, data} = :gen_tcp.recv(sock, 0, 1000)
:ok = :gen_tcp.close(sock)
data
end
defp tcp_connect_send_and_close(port, data_to_send) do
{:ok, sock} = :gen_tcp.connect({127, 0, 0, 1}, port, [:binary, {:packet, 0}])
:ok = :gen_tcp.send(sock, data_to_send |> String.to_charlist())
:ok = :gen_tcp.close(sock)
end
end
| 26.483221 | 101 | 0.595793 |
ff8792810ef2bfaa81c6311f39e70d3c6360b3ae | 9,329 | exs | Elixir | apps/site/test/site_web/controllers/event_controller_test.exs | mbta/crispy-spoon | 7ef28a1a6adc73899b007e334b9220f7a48a60fa | [
"MIT"
] | null | null | null | apps/site/test/site_web/controllers/event_controller_test.exs | mbta/crispy-spoon | 7ef28a1a6adc73899b007e334b9220f7a48a60fa | [
"MIT"
] | null | null | null | apps/site/test/site_web/controllers/event_controller_test.exs | mbta/crispy-spoon | 7ef28a1a6adc73899b007e334b9220f7a48a60fa | [
"MIT"
] | null | null | null | defmodule SiteWeb.EventControllerTest do
use SiteWeb.ConnCase
import SiteWeb.EventController
import Mock
@current_date ~D[2019-04-15]
setup_with_mocks([
{SiteWeb.Plugs.Date, [],
[
call: fn conn, _ -> Plug.Conn.assign(conn, :date, @current_date) end
]}
]) do
:ok
end
describe "GET index" do
test "assigns month and year based on query params, defaulting to current", %{conn: conn} do
conn = get(conn, event_path(conn, :index))
assert %{year: 2019, month: 4} = conn.assigns
conn = get(conn, event_path(conn, :index, month: 5, year: 2020))
assert %{year: 2020, month: 5} = conn.assigns
end
test "renders a list of events", %{conn: conn} do
conn = get(conn, event_path(conn, :index))
assert conn.assigns.year == 2019
events_hub = html_response(conn, 200) |> Floki.find(".m-events-hub")
assert Floki.text(events_hub) =~ "MassDOT Finance and Audit Committee"
event_links = Floki.find(events_hub, ".m-event__title")
assert Enum.count(event_links) > 0
end
test "renders the calendar view", %{conn: conn} do
conn = get(conn, event_path(conn, :index, calendar: true))
events_calendar = html_response(conn, 200) |> Floki.find(".m-event-calendar")
refute is_nil(events_calendar)
end
test "scopes events based on provided dates", %{conn: conn} do
conn = get(conn, event_path(conn, :index, month: 6, year: 2018))
events_hub = html_response(conn, 200) |> Floki.find(".m-events-hub")
refute Floki.text(events_hub) =~ "MassDOT Finance and Audit Committee"
end
test "does not include an unavailable_after x-robots-tag HTTP header", %{conn: conn} do
conn = get(conn, event_path(conn, :index))
refute Enum.find(conn.resp_headers, fn {key, value} ->
key == "x-robots-tag" && String.contains?(value, "unavailable_after")
end)
end
test "renders the toggle for calendar view", %{conn: conn} do
conn = get(conn, event_path(conn, :index, calendar: true))
events_hub = html_response(conn, 200) |> Floki.find(".m-events-hub__nav--navigation-toggle")
assert [{"div", [{"class", "m-events-hub__nav--navigation-toggle"}], _}] = events_hub
event_icons = Floki.find(events_hub, ".m-nav-toggle-icon")
assert Enum.count(event_icons) == 2
end
end
@tag todo: "Replacing with events_hub_redesign"
describe "GET show" do
test "renders and does not rewrite an unaliased event response", %{conn: conn} do
event = event_factory(0, path_alias: nil)
assert event.path_alias == nil
assert event.title == "Fiscal & Management Control Board Meeting"
path = event_path(conn, :show, event)
assert path == "/node/3268"
conn = get(conn, path)
assert html_response(conn, 200) =~
"(FMCB) closely monitors the T’s finances, management, and operations.</p>"
end
test "disambiguation: renders an event whose alias pattern is /events/:title instead of /events/:date/:title",
%{conn: conn} do
conn = get(conn, event_path(conn, :show, "incorrect-pattern"))
assert html_response(conn, 200) =~ "Senior CharlieCard Event"
end
test "renders the given event with a path_alias", %{conn: conn} do
event = event_factory(1)
assert event.path_alias == "/events/date/title"
conn = get(conn, event_path(conn, :show, event))
assert html_response(conn, 200) =~ "Senior CharlieCard Event"
end
test "renders a preview of the requested event", %{conn: conn} do
event = event_factory(1)
conn = get(conn, event_path(conn, :show, event) <> "?preview&vid=112&nid=5")
assert html_response(conn, 200) =~ "Senior CharlieCard Event 112"
assert %{"preview" => "", "vid" => "112", "nid" => "5"} == conn.query_params
end
test "retains params (except _format) and redirects when CMS returns a native redirect", %{
conn: conn
} do
conn = get(conn, event_path(conn, :show, "redirected-url") <> "?preview&vid=999")
assert conn.status == 301
assert Plug.Conn.get_resp_header(conn, "location") == [
"/events/date/title?preview=&vid=999"
]
end
test "includes an unavailable_after x-robots-tag HTTP header", %{conn: conn} do
event = event_factory(0, path_alias: nil)
path = event_path(conn, :show, event)
conn = get(conn, path)
assert Enum.find(conn.resp_headers, fn {key, value} ->
key == "x-robots-tag" && String.contains?(value, "unavailable_after")
end)
end
test "renders a 404 given an valid id but mismatching content type", %{conn: conn} do
conn = get(conn, event_path(conn, :show, "1"))
assert conn.status == 404
end
test "renders a 404 when event does not exist", %{conn: conn} do
conn = get(conn, event_path(conn, :show, "2018", "invalid-event"))
assert conn.status == 404
end
end
describe "GET show (events_hub_redesign)" do
test "renders show.html", %{conn: conn} do
event = event_factory(0, path_alias: nil)
conn = get(conn, event_path(conn, :show, event))
assert conn.status == 200
refute html_response(conn, 200) =~ "<h3>Agenda</h3>"
end
end
describe "GET icalendar" do
test "returns an icalendar file as an attachment when event does not have an alias", %{
conn: conn
} do
event = event_factory(0)
assert event.path_alias == nil
assert event.title == "Fiscal & Management Control Board Meeting"
conn = get(conn, event_icalendar_path(conn, :show, event))
assert conn.status == 200
assert Plug.Conn.get_resp_header(conn, "content-type") == ["text/calendar; charset=utf-8"]
assert Plug.Conn.get_resp_header(conn, "content-disposition") == [
"attachment; filename=fiscal_&_management_control_board_meeting.ics"
]
end
test "returns an icalendar file as an attachment when event has a valid alias", %{conn: conn} do
event = event_factory(1)
assert event.path_alias == "/events/date/title"
assert event.title == "Senior CharlieCard Event"
conn = get(conn, event_icalendar_path(conn, :show, event))
assert conn.status == 200
assert Plug.Conn.get_resp_header(conn, "content-type") == ["text/calendar; charset=utf-8"]
assert Plug.Conn.get_resp_header(conn, "content-disposition") == [
"attachment; filename=senior_charliecard_event.ics"
]
end
test "returns an icalendar file when only the path_alias is passed", %{conn: conn} do
event = event_factory(1)
assert event.path_alias == "/events/date/title"
conn = get(conn, event_icalendar_path(conn, event.path_alias))
assert conn.status == 200
assert Plug.Conn.get_resp_header(conn, "content-type") == ["text/calendar; charset=utf-8"]
assert Plug.Conn.get_resp_header(conn, "content-disposition") == [
"attachment; filename=senior_charliecard_event.ics"
]
end
test "returns an icalendar file as an attachment when event has a non-conforming alias", %{
conn: conn
} do
event = event_factory(0, path_alias: "/events/incorrect-pattern")
assert event.path_alias == "/events/incorrect-pattern"
conn = get(conn, event_icalendar_path(conn, :show, event))
assert conn.status == 200
assert Plug.Conn.get_resp_header(conn, "content-type") == ["text/calendar; charset=utf-8"]
assert Plug.Conn.get_resp_header(conn, "content-disposition") == [
"attachment; filename=senior_charliecard_event.ics"
]
end
test "renders a 404 given an invalid id", %{conn: conn} do
event = event_factory(0, id: 999)
conn = get(conn, event_icalendar_path(conn, :show, event))
assert conn.status == 404
end
test "renders an icalendar file for a redirected event", %{conn: conn} do
event = event_factory(0, path_alias: "/events/redirected-url")
assert event.path_alias == "/events/redirected-url"
conn = get(conn, event_icalendar_path(conn, :show, event))
assert conn.status == 200
assert Plug.Conn.get_resp_header(conn, "content-type") == ["text/calendar; charset=utf-8"]
assert Plug.Conn.get_resp_header(conn, "content-disposition") == [
"attachment; filename=senior_charliecard_event.ics"
]
end
test "redirects old icalendar path to new icalendar path", %{conn: conn} do
event = event_factory(1)
old_path = Path.join(event_path(conn, :show, event), "icalendar")
assert old_path == "/events/date/title/icalendar"
conn = get(conn, old_path)
assert conn.status == 302
end
end
describe "year_options/1" do
test "year_options/1 returns a range of -4/+1 years", %{conn: conn} do
assigns_with_date = Map.put(conn.assigns, :date, ~D[2019-03-03])
conn = %{conn | assigns: assigns_with_date}
assert 2015..2020 = year_options(conn)
end
test "year_options/1 defaults to Util.now", %{conn: conn} do
with_mock Util, [:passthrough], now: fn -> ~N[2020-01-02T05:00:00] end do
assert 2016..2021 = year_options(conn)
end
end
end
end
| 37.465863 | 114 | 0.643692 |
ff879fa128d7e76c5bae225fb806ae7dfbfe2e55 | 7,578 | ex | Elixir | lib/mmdb2_decoder.ex | kianmeng/mmdb2_decoder | dbf65dd6e3de5804928e36c38c19aefe1a83f081 | [
"Apache-2.0"
] | 4 | 2018-03-03T18:59:49.000Z | 2019-09-10T07:59:22.000Z | lib/mmdb2_decoder.ex | kianmeng/mmdb2_decoder | dbf65dd6e3de5804928e36c38c19aefe1a83f081 | [
"Apache-2.0"
] | 1 | 2021-12-23T12:26:05.000Z | 2021-12-23T12:26:05.000Z | lib/mmdb2_decoder.ex | kianmeng/mmdb2_decoder | dbf65dd6e3de5804928e36c38c19aefe1a83f081 | [
"Apache-2.0"
] | 4 | 2018-06-21T16:45:56.000Z | 2021-08-30T11:31:19.000Z | defmodule MMDB2Decoder do
@moduledoc """
MMDB2 file format decoder.
## Usage
To prepare lookups in a given database you need to parse it
and hold the result available for later usage:
iex(1)> database = File.read!("/path/to/database.mmdb")
iex(2)> {:ok, meta, tree, data} = MMDB2Decoder.parse_database(database)
Using the returned database contents you can start looking up
individual entries:
iex(3)> {:ok, ip} = :inet.parse_address(String.to_charlist("127.0.0.1"))
iex(4)> MMDB2Decoder.lookup(ip, meta, tree, data)
{:ok, %{...}}
For more details on the lookup methods (and a function suitable for
direct piping) please see the individual function documentations.
## Lookup Options
The behaviour of the decoder can be adjusted by passing an option map as the
last argument to the lookup functions:
iex> MMDB2Decoder.lookup(ip, meta, tree, data, %{map_keys: :atoms!})
The following options are available:
- `:map_keys` defines the type of the keys in a decoded map:
- `:strings` is the default value
- `:atoms` uses `String.to_atom/1`
- `:atoms!` uses `String.to_existing_atom/1`
- `:double_precision` defines the precision of decoded Double values
- `nil` is the default for "unlimited" precision
- any value from `t:Float.precision_range/0` to round the precision to
- `:float_precision` defines the precision of decoded Float values
- `nil` is the default for "unlimited" precision
- any value from `t:Float.precision_range/0` to round the precision to
"""
alias MMDB2Decoder.Data
alias MMDB2Decoder.Database
alias MMDB2Decoder.LookupTree
alias MMDB2Decoder.Metadata
@type decode_options :: %{
optional(:double_precision) => nil | Float.precision_range(),
optional(:float_precision) => nil | Float.precision_range(),
optional(:map_keys) => nil | :atoms | :atoms! | :strings
}
@type decoded_value :: :cache_container | :end_marker | binary | boolean | list | map | number
@type lookup_value :: decoded_value | nil
@type lookup_result :: {:ok, lookup_value} | {:error, term}
@type parse_result :: {:ok, Metadata.t(), binary, binary} | {:error, term}
@type tree_result :: {:ok, non_neg_integer} | {:error, term}
@default_decode_options %{
double_precision: nil,
float_precision: nil,
map_keys: :strings
}
@doc """
Fetches the pointer of an IP in the data if available.
The pointer will be calculated to be relative to the start of the binary data.
## Usage
iex> MMDB2Decoder.find_pointer({127, 0, 0, 1}, meta, tree)
123456
"""
@spec find_pointer(:inet.ip_address(), Metadata.t(), binary) :: tree_result
def find_pointer(ip, meta, tree) do
case LookupTree.locate(ip, meta, tree) do
{:error, _} = error -> error
{:ok, pointer} -> {:ok, pointer - meta.node_count - 16}
end
end
@doc """
Calls `find_pointer/3` and raises if an error occurs.
"""
@spec find_pointer!(:inet.ip_address(), Metadata.t(), binary) :: non_neg_integer | no_return
def find_pointer!(ip, meta, tree) do
case find_pointer(ip, meta, tree) do
{:ok, pointer} -> pointer
{:error, error} -> raise Kernel.to_string(error)
end
end
@doc """
Looks up the data associated with an IP tuple.
This is probably the main function you will use. The `ip` address is expected
to be a 4- or 8-element tuple describing an IPv4 or IPv6 address. To obtain
this tuple from a string you can use `:inet.parse_address/1`.
## Usage
iex> MMDB2Decoder.lookup({127, 0, 0, 1}, meta, tree, data)
{
:ok,
%{
"continent" => %{...},
"country" => %{...},
"registered_country" => %{...}
}
}
The values for `meta`, `tree` and `data` can be obtained by
parsing the file contents of a database using `parse_database/1`.
"""
@spec lookup(:inet.ip_address(), Metadata.t(), binary, binary, decode_options) :: lookup_result
def lookup(ip, meta, tree, data, options \\ @default_decode_options) do
case find_pointer(ip, meta, tree) do
{:error, _} = error -> error
{:ok, pointer} -> lookup_pointer(pointer, data, options)
end
end
@doc """
Calls `lookup/4` and raises if an error occurs.
"""
@spec lookup!(:inet.ip_address(), Metadata.t(), binary, binary, decode_options) ::
lookup_value | no_return
def lookup!(ip, meta, tree, data, options \\ @default_decode_options) do
case lookup(ip, meta, tree, data, options) do
{:ok, result} -> result
{:error, error} -> raise Kernel.to_string(error)
end
end
@doc """
Fetches the data at a given pointer position.
The pointer is expected to be relative to the start of the binary data.
## Usage
iex> MMDB2Decoder.lookup_pointer(123456, data)
{
:ok,
%{
"continent" => %{...},
"country" => %{...},
"registered_country" => %{...}
}
}
"""
@spec lookup_pointer(non_neg_integer, binary, decode_options) :: {:ok, lookup_value}
def lookup_pointer(pointer, data, options \\ @default_decode_options) do
{:ok, Data.value(data, pointer, options)}
end
@doc """
Calls `lookup_pointer/3` and unrolls the return tuple.
"""
@spec lookup_pointer!(non_neg_integer, binary, decode_options) :: lookup_value
def lookup_pointer!(pointer, data, options \\ @default_decode_options) do
{:ok, value} = lookup_pointer(pointer, data, options)
value
end
@doc """
Parses a database binary and splits it into metadata, lookup tree and data.
It is expected that you pass the real contents of the file, not the name
of the database or the path to it.
## Usage
iex> MMDB2Decoder.parse_database(File.read!("/path/to/database.mmdb"))
{
:ok,
%MMDB2Decoder.Metadata{...},
<<...>>,
<<...>>
}
If parsing the database fails you will receive an appropriate error tuple:
iex> MMDB2Decoder.parse_database("invalid-database-contents")
{:error, :no_metadata}
"""
@spec parse_database(binary) :: parse_result
def parse_database(contents) do
case Database.split_contents(contents) do
[_] -> {:error, :no_metadata}
[data, meta] -> Database.split_data(meta, data)
end
end
@doc """
Utility method to pipe `parse_database/1` directly to `lookup/4`.
## Usage
Depending on how you handle the parsed database contents you may
want to pass the results directly to the lookup.
iex> "/path/to/database.mmdb"
...> |> File.read!()
...> |> MMDB2Decoder.parse_database()
...> |> MMDB2Decoder.pipe_lookup({127, 0, 0, 1})
{:ok, %{...}}
"""
@spec pipe_lookup(parse_result, :inet.ip_address(), decode_options) :: lookup_result
def pipe_lookup(parse_result, ip, options \\ @default_decode_options)
def pipe_lookup({:error, _} = error, _, _), do: error
def pipe_lookup({:ok, meta, tree, data}, ip, options),
do: lookup(ip, meta, tree, data, options)
@doc """
Calls `pipe_lookup/2` and raises if an error from `parse_database/1` is given
or occurs during `lookup/4`.
"""
@spec pipe_lookup!(parse_result, :inet.ip_address(), decode_options) ::
lookup_value | no_return
def pipe_lookup!(parse_result, ip, options \\ @default_decode_options)
def pipe_lookup!({:error, error}, _, _), do: raise(Kernel.to_string(error))
def pipe_lookup!({:ok, meta, tree, data}, ip, options),
do: lookup!(ip, meta, tree, data, options)
end
| 32.110169 | 97 | 0.651623 |
ff87c37baaaadd2a02ed945f0f3336a88adf9dc1 | 773 | ex | Elixir | lib/web/controllers/registration_controller.ex | oestrich/grapevine-legacy | 9d84f8e2d65dda5982686381ffa94a940142e1da | [
"MIT"
] | null | null | null | lib/web/controllers/registration_controller.ex | oestrich/grapevine-legacy | 9d84f8e2d65dda5982686381ffa94a940142e1da | [
"MIT"
] | null | null | null | lib/web/controllers/registration_controller.ex | oestrich/grapevine-legacy | 9d84f8e2d65dda5982686381ffa94a940142e1da | [
"MIT"
] | null | null | null | defmodule Web.RegistrationController do
use Web, :controller
alias Grapevine.Accounts
alias Web.SessionController
def new(conn, _params) do
changeset = Accounts.new()
conn
|> assign(:changeset, changeset)
|> render("new.html")
end
def create(conn, %{"user" => params}) do
case Accounts.register(params) do
{:ok, user} ->
conn
|> put_flash(:info, "Welcome to Grapevine!")
|> put_session(:user_token, user.token)
|> SessionController.after_sign_in_redirect()
{:error, changeset} ->
conn
|> put_flash(:error, "There was a problem registering. Please try again.")
|> put_status(422)
|> assign(:changeset, changeset)
|> render("new.html")
end
end
end
| 24.15625 | 82 | 0.617076 |
ff87cd07c8f610731dc107ccb3de6f8a8f10118c | 13,691 | exs | Elixir | apps/state/test/state/stops_on_route_test.exs | pacebus/mbta-api-fork | 6bf1d3a16e8917c9cfac0001b184c443be1f3abd | [
"MIT"
] | null | null | null | apps/state/test/state/stops_on_route_test.exs | pacebus/mbta-api-fork | 6bf1d3a16e8917c9cfac0001b184c443be1f3abd | [
"MIT"
] | null | null | null | apps/state/test/state/stops_on_route_test.exs | pacebus/mbta-api-fork | 6bf1d3a16e8917c9cfac0001b184c443be1f3abd | [
"MIT"
] | 1 | 2019-09-09T20:40:13.000Z | 2019-09-09T20:40:13.000Z | defmodule State.StopsOnRouteTest do
use ExUnit.Case
use Timex
import State.StopsOnRoute
@route %Model.Route{id: "route"}
@service %Model.Service{
id: "service",
start_date: Timex.today(),
end_date: Timex.today(),
added_dates: [Timex.today()]
}
@trip %Model.Trip{
id: "trip",
route_id: "route",
shape_id: "pattern",
direction_id: 1,
service_id: "service",
route_pattern_id: "route_pattern_id"
}
@other_trip %Model.Trip{
id: "other_trip",
route_id: "route",
shape_id: "other_pattern",
direction_id: 0,
service_id: "other_service",
route_pattern_id: "other_route_pattern_id"
}
@schedule %Model.Schedule{trip_id: "trip", stop_id: "stop", stop_sequence: 2}
@other_schedule %Model.Schedule{trip_id: "other_trip", stop_id: "other_stop", stop_sequence: 1}
setup do
State.Stop.new_state([%Model.Stop{id: "stop"}, %Model.Stop{id: "other_stop"}])
State.RoutePattern.new_state([
%Model.RoutePattern{id: "route_pattern_id", typicality: 1},
%Model.RoutePattern{id: "other_route_pattern_id", typicality: 2}
])
State.Route.new_state([@route])
State.Trip.new_state([@trip, @other_trip])
State.Service.new_state([@service])
State.Schedule.new_state([@schedule, @other_schedule])
State.Shape.new_state([])
update!()
end
describe "by_route_id/2" do
test "returns the stop IDs on a given route" do
assert by_route_id("route", direction_id: 1) == ["stop"]
assert by_route_id("route", direction_id: 0) == ["other_stop"]
assert by_route_id("route", service_ids: ["service"]) == ["stop"]
assert Enum.sort(by_route_id("route", service_ids: ["service", "other_service"])) == [
"other_stop",
"stop"
]
assert by_route_id(
"route",
direction_id: 1,
service_ids: ["service", "other_service"]
) == ["stop"]
assert by_route_id("route", shape_ids: ["pattern"]) == ["stop"]
assert Enum.sort(by_route_id("route")) == ["other_stop", "stop"]
assert by_route_id("unknown") == []
end
test "returns stop IDs in sequence order" do
other_schedule = %Model.Schedule{trip_id: "trip", stop_id: "other_stop", stop_sequence: 1}
State.Schedule.new_state([@schedule, other_schedule])
update!()
assert by_route_id("route") == ["other_stop", "stop"]
end
test "does not include alternate route trips unless asked" do
adjusted_trip = %Model.Trip{@other_trip | alternate_route: false}
alternate_trip = %Model.Trip{@trip | id: "alternate_trip", alternate_route: true}
alternate_schedule = %Model.Schedule{
@schedule
| trip_id: "alternate_trip",
stop_id: "alternate_stop"
}
State.Stop.new_state([%Model.Stop{id: "alternate_stop"} | State.Stop.all()])
State.Trip.new_state([@trip, adjusted_trip, alternate_trip])
State.Schedule.new_state([@schedule, @other_schedule, alternate_schedule])
update!()
assert by_route_id("route") == ["stop"]
assert Enum.sort(by_route_id("route", include_alternates?: true)) == [
"alternate_stop",
"other_stop",
"stop"
]
# if we don't have regular service, try alternate service
assert by_route_id("route", service_ids: ["other_service"]) == ["other_stop"]
end
test "does not include a parent station more than once" do
State.Stop.new_state([
%Model.Stop{id: "stop", parent_station: "parent"},
%Model.Stop{id: "other_stop", parent_station: "parent"}
])
update!()
assert by_route_id("route") == ["parent"]
end
test "keeps stops in a global order even if a single shape does not determine the order" do
# Stops go outbound 0 -> 3, and inbound 3 -> 0
# the "short" shapes go to either Stop 2 or Stop 3, but not both
stops =
for id <- 0..3 do
%Model.Stop{id: "stop-#{id}"}
end
trips =
for {trip_id, shape_id} <- [all: "all", first: "short", second: "short"] do
%Model.Trip{
id: "#{trip_id}",
direction_id: 0,
shape_id: "#{shape_id}",
route_id: @route.id
}
end ++
[
# Inbound trip
%Model.Trip{id: "reverse", direction_id: 1, shape_id: "other", route_id: @route.id}
]
schedules =
for {{trip_id, id}, stop_sequence} <-
Enum.with_index([
{"all", 0},
{"all", 1},
{"all", 2},
{"all", 3},
{"first", 0},
{"first", 1},
{"first", 3},
{"second", 0},
{"second", 2},
{"second", 3},
{"reverse", 3},
{"reverse", 2},
{"reverse", 1},
{"reverse", 0}
]) do
%Model.Schedule{
stop_id: "stop-#{id}",
trip_id: "#{trip_id}",
stop_sequence: stop_sequence
}
end
State.Stop.new_state(stops)
State.Trip.new_state(trips)
State.Schedule.new_state(schedules)
update!()
assert by_route_id(@route.id, shape_ids: ["short"]) == [
"stop-0",
"stop-1",
"stop-2",
"stop-3"
]
end
test "global order is not confused by shuttles" do
# Stops go outbound 0 -> 3
# the shuttle shape goes from 3 to 0
stops =
for id <- 0..3 do
%Model.Stop{id: "stop-#{id}"}
end
trips =
for {trip_id, shape_id, route_type} <- [
{"all", "all", nil},
{"express", "all", nil},
{"shuttle", "shuttle", 4}
] do
%Model.Trip{
id: trip_id,
direction_id: 0,
shape_id: shape_id,
route_type: route_type,
route_id: @route.id
}
end
# we need the "express" trip to have a different set of shapes from the
# "all" trip
schedules =
for {{trip_id, id}, stop_sequence} <-
Enum.with_index([
{"all", 0},
{"all", 1},
{"all", 2},
{"all", 3},
{"express", 0},
{"express", 3},
{"shuttle", 3},
{"shuttle", 2},
{"shuttle", 1},
{"shuttle", 0}
]) do
%Model.Schedule{
stop_id: "stop-#{id}",
trip_id: "#{trip_id}",
stop_sequence: stop_sequence
}
end
State.Stop.new_state(stops)
State.Trip.new_state(trips)
State.Schedule.new_state(schedules)
update!()
assert by_route_id(@route.id, direction_id: 0) == ["stop-0", "stop-1", "stop-2", "stop-3"]
end
test "if a shape has all the same stops not in the global order, keep the shape order" do
# Stops go outbound 0 -> 3, and inbound 3 -> 0
# the "short" shapes go to either Stop 2 or Stop 3, but not both
stops =
for id <- 0..2 do
%Model.Stop{id: "stop-#{id}"}
end
trips =
for {trip_id, shape_id} <- [first: "first", second: "second"] do
%Model.Trip{
id: "#{trip_id}",
direction_id: 0,
shape_id: "#{shape_id}",
route_id: @route.id
}
end
schedules =
for {{trip_id, id}, stop_sequence} <-
Enum.with_index([
{"first", 0},
{"first", 1},
{"first", 2},
{"second", 0},
{"second", 2},
{"second", 1}
]) do
%Model.Schedule{
stop_id: "stop-#{id}",
trip_id: "#{trip_id}",
stop_sequence: stop_sequence
}
end
State.Stop.new_state(stops)
State.Trip.new_state(trips)
State.Schedule.new_state(schedules)
update!()
first_ids = by_route_id(@route.id, shape_ids: ["first"])
second_ids = by_route_id(@route.id, shape_ids: ["second"])
refute first_ids == second_ids
end
test "if trip doesn't have a route pattern, it's not included" do
# "stop" is on this shape, "other_stop" is on a different shape
trip = %{@trip | route_type: 2}
State.Trip.new_state([trip, @other_trip])
update!()
assert by_route_id(@route.id) == ["other_stop"]
end
test "shows Plimptonville after Windsor Gardens even when they don't share a trip" do
State.Stop.new_state([
%Model.Stop{id: "place-sstat"},
%Model.Stop{id: "Windsor Gardens"},
%Model.Stop{id: "Plimptonville"},
%Model.Stop{id: "Walpole"},
%Model.Stop{id: "Franklin"}
])
State.Route.new_state([%Model.Route{id: "CR-Franklin"}])
State.Trip.new_state([
%Model.Trip{
id: "via-plimptonville",
route_id: "CR-Franklin",
direction_id: 0,
service_id: "service"
},
%Model.Trip{
id: "via-windsor-gardens",
route_id: "CR-Franklin",
direction_id: 0,
service_id: "service"
}
])
State.Schedule.new_state([
%Model.Schedule{trip_id: "via-plimptonville", stop_id: "place-sstat", stop_sequence: 1},
%Model.Schedule{trip_id: "via-plimptonville", stop_id: "Plimptonville", stop_sequence: 2},
%Model.Schedule{trip_id: "via-plimptonville", stop_id: "Franklin", stop_sequence: 3},
# Windsor Gardens trip has more stops because this bug only shows up when the merge
# has windor gardens on the left and plimptonville on the right.
# They're sorted by length before merging, so this forces them to be in the order to make the bug appear.
%Model.Schedule{trip_id: "via-windsor-gardens", stop_id: "place-sstat", stop_sequence: 1},
%Model.Schedule{
trip_id: "via-windsor-gardens",
stop_id: "Windsor Gardens",
stop_sequence: 2
},
%Model.Schedule{trip_id: "via-windsor-gardens", stop_id: "Walpole", stop_sequence: 3},
%Model.Schedule{trip_id: "via-windsor-gardens", stop_id: "Franklin", stop_sequence: 4}
])
update!()
stop_ids = by_route_id("CR-Franklin")
assert Enum.filter(stop_ids, &(&1 in ["Windsor Gardens", "Plimptonville"])) == [
"Windsor Gardens",
"Plimptonville"
]
end
end
describe "by_route_ids/2" do
test "takes multiple route_ids to match against" do
State.Stop.new_state([%Model.Stop{id: "new_stop"} | State.Stop.all()])
State.Route.new_state([
@route,
%{@route | id: "new_route"}
])
State.Trip.new_state([
@trip,
%{@trip | id: "new_trip", route_id: "new_route"}
])
State.Schedule.new_state([
@schedule,
%{@schedule | trip_id: "new_trip", stop_id: "new_stop"}
])
update!()
assert by_route_ids(["route"]) == by_route_id("route")
assert [_, _] = by_route_ids(["route", "new_route"])
end
end
describe "merge_ids/1" do
test "merges the lists, keeping a relative order" do
assert merge_ids([[1, 2, 4, 5], [2, 3, 4, 5], [3, 5, 6]]) == [1, 2, 3, 4, 5, 6]
assert merge_ids([]) == []
assert merge_ids([[], []]) == []
assert merge_ids([[1], []]) == [1]
assert merge_ids([[], [1]]) == [1]
end
test "handles lists with branches" do
# based on outbound Providence/Stoughton
stop_ids = [
[13, 14, 15],
[1, 2, 5, 7, 8],
[1, 2, 5, 9, 10, 11, 12, 13],
[1, 2, 5, 11],
[1, 2, 3, 5, 6, 9, 10, 11, 12, 13],
[1, 2, 5, 6, 7, 8],
[1, 2, 3, 5, 6, 9, 10, 11, 12, 13, 14, 15],
[1, 2, 3, 4, 5, 6, 7, 8]
]
# stoughton first, then prov
expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
assert merge_ids(stop_ids) == expected
end
test "puts the longer branch at the end" do
stop_ids = [
[1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15],
[3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15],
[8, 9, 10, 11, 12, 13, 14, 15]
]
assert merge_ids(stop_ids) == Enum.into(1..15, [])
assert merge_ids(Enum.map(stop_ids, &Enum.reverse/1)) == Enum.into(15..1, [])
end
test "puts the higher valued ID at the end with branches" do
stop_ids = [
[1, 2, 3, 4],
[1, 2, 5, 6]
]
assert merge_ids(stop_ids) == [1, 2, 3, 4, 5, 6]
assert merge_ids(Enum.map(stop_ids, &Enum.reverse/1)) == [6, 5, 4, 3, 2, 1]
end
test "does not include IDs multiple times" do
stop_ids = [
[1, 2, 3],
[1, 3, 2]
]
# There isn't a single defined order (that we can determine) but we
# know that there are only three items.
assert [_, _, _] = merge_ids(stop_ids)
end
test "can use an override to order individual stops" do
stop_ids =
Enum.shuffle([
[1, 2, 3, 5, 6],
[1, 2, 4, 5, 6]
])
overrides = [[2, 4, 3, 5]]
assert [1, 2, 4, 3, 5, 6] == merge_ids(stop_ids, overrides)
end
end
test "doesn't override itself if there are no schedules" do
assert by_route_id("route", direction_id: 1) == ["stop"]
State.Schedule.new_state([])
update!()
assert by_route_id("route", direction_id: 1) == ["stop"]
end
end
| 30.835586 | 113 | 0.533343 |
ff87e823aa2d30f6ccd32337904b08745d3a42d3 | 2,353 | ex | Elixir | clients/cloud_build/lib/google_api/cloud_build/v1/model/git_repo_source.ex | MMore/elixir-google-api | 0574ec1439d9bbfe22d63965be1681b0f45a94c9 | [
"Apache-2.0"
] | null | null | null | clients/cloud_build/lib/google_api/cloud_build/v1/model/git_repo_source.ex | MMore/elixir-google-api | 0574ec1439d9bbfe22d63965be1681b0f45a94c9 | [
"Apache-2.0"
] | null | null | null | clients/cloud_build/lib/google_api/cloud_build/v1/model/git_repo_source.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.CloudBuild.V1.Model.GitRepoSource do
@moduledoc """
GitRepoSource describes a repo and ref of a code repository.
## Attributes
* `bitbucketServerConfig` (*type:* `String.t`, *default:* `nil`) - The full resource name of the bitbucket server config. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{id}`.
* `githubEnterpriseConfig` (*type:* `String.t`, *default:* `nil`) - The full resource name of the github enterprise config. Format: `projects/{project}/locations/{location}/githubEnterpriseConfigs/{id}`. `projects/{project}/githubEnterpriseConfigs/{id}`.
* `ref` (*type:* `String.t`, *default:* `nil`) - The branch or tag to use. Must start with "refs/" (required).
* `repoType` (*type:* `String.t`, *default:* `nil`) - See RepoType below.
* `uri` (*type:* `String.t`, *default:* `nil`) - The URI of the repo (required).
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:bitbucketServerConfig => String.t() | nil,
:githubEnterpriseConfig => String.t() | nil,
:ref => String.t() | nil,
:repoType => String.t() | nil,
:uri => String.t() | nil
}
field(:bitbucketServerConfig)
field(:githubEnterpriseConfig)
field(:ref)
field(:repoType)
field(:uri)
end
defimpl Poison.Decoder, for: GoogleApi.CloudBuild.V1.Model.GitRepoSource do
def decode(value, options) do
GoogleApi.CloudBuild.V1.Model.GitRepoSource.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.CloudBuild.V1.Model.GitRepoSource do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 39.881356 | 258 | 0.702932 |
ff8819efb4aebbd6f0c85fe5c410764f3633006e | 201 | ex | Elixir | lib/phone/lt.ex | net/phone | 18e1356d2f8d32fe3f95638c3c44bceab0164fb2 | [
"Apache-2.0"
] | null | null | null | lib/phone/lt.ex | net/phone | 18e1356d2f8d32fe3f95638c3c44bceab0164fb2 | [
"Apache-2.0"
] | null | null | null | lib/phone/lt.ex | net/phone | 18e1356d2f8d32fe3f95638c3c44bceab0164fb2 | [
"Apache-2.0"
] | null | null | null | defmodule Phone.LT do
@moduledoc false
use Helper.Country
def regex, do: ~r/^(370)()(.{8})/
def country, do: "Lithuania"
def a2, do: "LT"
def a3, do: "LTU"
matcher :regex, ["370"]
end
| 15.461538 | 35 | 0.60199 |
ff8834b93e9b9da36bad421bbd03fe78ca25b92c | 3,892 | exs | Elixir | mix.exs | sthagen/elixir-ecto-ecto | a71dc13ba376663279f0c607ebec510018802b30 | [
"Apache-2.0"
] | null | null | null | mix.exs | sthagen/elixir-ecto-ecto | a71dc13ba376663279f0c607ebec510018802b30 | [
"Apache-2.0"
] | null | null | null | mix.exs | sthagen/elixir-ecto-ecto | a71dc13ba376663279f0c607ebec510018802b30 | [
"Apache-2.0"
] | null | null | null | defmodule Ecto.MixProject do
use Mix.Project
@source_url "https://github.com/elixir-ecto/ecto"
@version "3.8.1"
def project do
[
app: :ecto,
version: @version,
elixir: "~> 1.10",
deps: deps(),
consolidate_protocols: Mix.env() != :test,
elixirc_paths: elixirc_paths(Mix.env()),
# Hex
description: "A toolkit for data mapping and language integrated query for Elixir",
package: package(),
# Docs
name: "Ecto",
docs: docs()
]
end
def application do
[
extra_applications: [:logger, :crypto, :eex],
mod: {Ecto.Application, []}
]
end
defp deps do
[
{:telemetry, "~> 0.4 or ~> 1.0"},
{:decimal, "~> 1.6 or ~> 2.0"},
{:jason, "~> 1.0", optional: true},
{:ex_doc, "~> 0.20", only: :docs}
]
end
defp package do
[
maintainers: ["Eric Meadows-Jönsson", "José Valim", "James Fish", "Michał Muskała", "Felipe Stival"],
licenses: ["Apache-2.0"],
links: %{"GitHub" => @source_url},
files:
~w(.formatter.exs mix.exs README.md CHANGELOG.md lib) ++
~w(integration_test/cases integration_test/support)
]
end
defp docs do
[
main: "Ecto",
source_ref: "v#{@version}",
logo: "guides/images/e.png",
extra_section: "GUIDES",
source_url: @source_url,
skip_undefined_reference_warnings_on: ["CHANGELOG.md"],
extras: extras(),
groups_for_extras: groups_for_extras(),
groups_for_functions: [
group_for_function("Query API"),
group_for_function("Schema API"),
group_for_function("Transaction API"),
group_for_function("Runtime API"),
group_for_function("User callbacks")
],
groups_for_modules: [
# Ecto,
# Ecto.Changeset,
# Ecto.Multi,
# Ecto.Query,
# Ecto.Repo,
# Ecto.Schema,
# Ecto.Schema.Metadata,
# Mix.Ecto,
"Types": [
Ecto.Enum,
Ecto.ParameterizedType,
Ecto.Type,
Ecto.UUID
],
"Query APIs": [
Ecto.Query.API,
Ecto.Query.WindowAPI,
Ecto.Queryable,
Ecto.SubQuery
],
"Adapter specification": [
Ecto.Adapter,
Ecto.Adapter.Queryable,
Ecto.Adapter.Schema,
Ecto.Adapter.Storage,
Ecto.Adapter.Transaction
],
"Relation structs": [
Ecto.Association.BelongsTo,
Ecto.Association.Has,
Ecto.Association.HasThrough,
Ecto.Association.ManyToMany,
Ecto.Association.NotLoaded,
Ecto.Embedded
]
]
]
end
def extras() do
[
"guides/introduction/Getting Started.md",
"guides/introduction/Embedded Schemas.md",
"guides/introduction/Testing with Ecto.md",
"guides/howtos/Aggregates and subqueries.md",
"guides/howtos/Composable transactions with Multi.md",
"guides/howtos/Constraints and Upserts.md",
"guides/howtos/Data mapping and validation.md",
"guides/howtos/Dynamic queries.md",
"guides/howtos/Multi tenancy with query prefixes.md",
"guides/howtos/Multi tenancy with foreign keys.md",
"guides/howtos/Self-referencing many to many.md",
"guides/howtos/Polymorphic associations with many to many.md",
"guides/howtos/Replicas and dynamic repositories.md",
"guides/howtos/Schemaless queries.md",
"guides/howtos/Test factories.md",
"CHANGELOG.md"
]
end
defp group_for_function(group), do: {String.to_atom(group), &(&1[:group] == group)}
defp groups_for_extras do
[
"Introduction": ~r/guides\/introduction\/.?/,
"How-To's": ~r/guides\/howtos\/.?/
]
end
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
end
| 27.027778 | 107 | 0.583505 |
ff884bd65360886a9fe95603807bfb52ea9468a9 | 1,057 | ex | Elixir | lib/messaging/apns_message/config.ex | hippware/firebase-admin-ex | bca6f83a8ae94a7fdb0a447030913d03ea170bb1 | [
"MIT"
] | null | null | null | lib/messaging/apns_message/config.ex | hippware/firebase-admin-ex | bca6f83a8ae94a7fdb0a447030913d03ea170bb1 | [
"MIT"
] | null | null | null | lib/messaging/apns_message/config.ex | hippware/firebase-admin-ex | bca6f83a8ae94a7fdb0a447030913d03ea170bb1 | [
"MIT"
] | null | null | null | defmodule FirebaseAdminEx.Messaging.APNSMessage.Config do
@moduledoc """
This module is responsible for representing the
attributes of APNSMessage.Config.
"""
alias FirebaseAdminEx.Messaging.APNSMessage.Payload
@keys [
headers: %{},
payload: %Payload{
aps: %{},
custom_data: %{}
}
]
@type t :: %__MODULE__{
headers: map(),
payload: struct()
}
defstruct @keys
# Public API
def new(attributes \\ %{}) do
%__MODULE__{
headers: Map.get(attributes, :headers, %{}),
payload: Payload.new(Map.get(attributes, :payload))
}
end
def validate(%__MODULE__{headers: _, payload: nil}),
do: {:error, "[APNSMessage.Config] payload is missing"}
def validate(%__MODULE__{headers: _, payload: payload} = message_config) do
case Payload.validate(payload) do
{:ok, _} ->
{:ok, message_config}
{:error, error_message} ->
{:error, error_message}
end
end
def validate(_), do: {:error, "[APNSMessage.Config] Invalid payload"}
end
| 22.489362 | 77 | 0.622517 |
ff884f0186cefa950a6caca15b1abe1f856d0858 | 51 | exs | Elixir | apps/server_comms/test/server_comms_test.exs | paulanthonywilson/mcam | df9c5aaae00b568749dff22613636f5cb92f905a | [
"MIT"
] | null | null | null | apps/server_comms/test/server_comms_test.exs | paulanthonywilson/mcam | df9c5aaae00b568749dff22613636f5cb92f905a | [
"MIT"
] | 8 | 2020-11-16T09:59:12.000Z | 2020-11-16T10:13:07.000Z | apps/server_comms/test/server_comms_test.exs | paulanthonywilson/mcam | df9c5aaae00b568749dff22613636f5cb92f905a | [
"MIT"
] | null | null | null | defmodule ServerCommsTest do
use ExUnit.Case
end
| 12.75 | 28 | 0.823529 |
ff8859402fcb99678b3bf7c933180b36cc23ec32 | 1,185 | exs | Elixir | apps/language_server/mix.exs | kianmeng/elixir-ls | 3d7d8c3ae9361af1090805551ce59a5c17d586e0 | [
"Apache-2.0"
] | null | null | null | apps/language_server/mix.exs | kianmeng/elixir-ls | 3d7d8c3ae9361af1090805551ce59a5c17d586e0 | [
"Apache-2.0"
] | null | null | null | apps/language_server/mix.exs | kianmeng/elixir-ls | 3d7d8c3ae9361af1090805551ce59a5c17d586e0 | [
"Apache-2.0"
] | null | null | null | defmodule ElixirLS.LanguageServer.Mixfile do
use Mix.Project
def project do
[
app: :language_server,
version: "0.8.0",
elixir: ">= 1.10.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
aliases: aliases(),
elixirc_paths: elixirc_paths(Mix.env()),
build_embedded: false,
start_permanent: true,
build_per_environment: false,
consolidate_protocols: false,
deps: deps()
]
end
def application do
[mod: {ElixirLS.LanguageServer, []}, extra_applications: [:mix, :logger]]
end
defp deps do
[
{:elixir_ls_utils, in_umbrella: true},
{:elixir_sense, github: "elixir-lsp/elixir_sense"},
{:forms, "~> 0.0"},
{:erl2ex, github: "dazuma/erl2ex"},
{:dialyxir, "~> 1.0", runtime: false},
{:jason_vendored, github: "elixir-lsp/jason", branch: "vendored"},
{:stream_data, "~> 0.5", only: :test}
]
end
defp aliases do
[
test: "test --no-start"
]
end
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
end
| 24.6875 | 77 | 0.581435 |
ff886fbde46061dd9466be7c345d78f43dbdd356 | 159 | exs | Elixir | test/ex_leaky_limiter_test.exs | hongsw/ex_leaky_limiter | 84733f0e3176d0cbf4bca6e35c192baea0763ee3 | [
"MIT"
] | null | null | null | test/ex_leaky_limiter_test.exs | hongsw/ex_leaky_limiter | 84733f0e3176d0cbf4bca6e35c192baea0763ee3 | [
"MIT"
] | null | null | null | test/ex_leaky_limiter_test.exs | hongsw/ex_leaky_limiter | 84733f0e3176d0cbf4bca6e35c192baea0763ee3 | [
"MIT"
] | null | null | null | defmodule ExLeakyLimiterTest do
use ExUnit.Case
doctest ExLeakyLimiter
test "greets the world" do
assert ExLeakyLimiter.hello() == :world
end
end
| 17.666667 | 43 | 0.748428 |
ff88aa497dce95e3501c4855856719846eb24356 | 2,237 | ex | Elixir | apps/commuter_rail_boarding/lib/schedule_cache.ex | mbta/commuter_rail_boarding | 213eb4ac72e5c678b06f3298e98c36b9a9dbd1ff | [
"MIT"
] | 1 | 2022-01-30T20:53:07.000Z | 2022-01-30T20:53:07.000Z | apps/commuter_rail_boarding/lib/schedule_cache.ex | mbta/commuter_rail_boarding | 213eb4ac72e5c678b06f3298e98c36b9a9dbd1ff | [
"MIT"
] | 47 | 2021-05-05T10:31:05.000Z | 2022-03-30T22:18:14.000Z | apps/commuter_rail_boarding/lib/schedule_cache.ex | mbta/commuter_rail_boarding | 213eb4ac72e5c678b06f3298e98c36b9a9dbd1ff | [
"MIT"
] | 1 | 2021-05-14T00:35:08.000Z | 2021-05-14T00:35:08.000Z | defmodule ScheduleCache do
@moduledoc """
Caches information about GTFS schedule for later use.
"""
use GenServer
require Logger
@table __MODULE__.Table
@six_month_timeout :timer.hours(24 * 30 * 60)
def start_link(_args \\ []) do
GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
end
@doc """
Returns the stop_sequence for a trip/stop ID pair.
"""
@spec stop_sequence(trip_id, stop_id) :: {:ok, non_neg_integer} | :error
when trip_id: binary, stop_id: binary
def stop_sequence(trip_id, stop_id)
when is_binary(trip_id) and is_binary(stop_id) do
case :ets.lookup(@table, {trip_id, stop_id}) do
[{_, stop_sequence}] -> {:ok, stop_sequence}
[] -> insert_and_return_stop_sequence(trip_id, stop_id)
end
end
defp insert_and_return_stop_sequence(trip_id, stop_id) do
with {:ok, response} <-
HTTPClient.get(
"/schedules/",
[],
params: [
trip: trip_id,
stop: stop_id,
"fields[schedule]": "stop_sequence"
]
),
%{status_code: 200, body: body} <- response,
{:ok, stop_sequence} <- decode(body) do
_ = :ets.insert(@table, {{trip_id, stop_id}, stop_sequence})
# try to fetch from the table again
{:ok, stop_sequence}
else
_ -> :error
end
end
defp decode(%{"data" => [schedule | _]}) do
{:ok, schedule["attributes"]["stop_sequence"]}
end
defp decode(_) do
:error
end
# Server callbacks
def init(:ok) do
ets_options = [
:set,
:public,
:named_table,
{:read_concurrency, true},
{:write_concurrency, true}
]
_ = :ets.new(@table, ets_options)
# we have a timeout after six months so that on the off-chance this runs
# for a while, we won't use an infinite amount of memory
schedule_timeout()
{:ok, :state}
end
def handle_info(:timeout, state) do
_ =
Logger.info(fn ->
"#{__MODULE__} expiring cache"
end)
:ets.delete_all_objects(@table)
schedule_timeout()
{:noreply, state}
end
defp schedule_timeout do
Process.send_after(self(), :timeout, @six_month_timeout)
end
end
| 25.134831 | 76 | 0.60751 |
ff88b209a33693cd6fc9f7cb21f491b0d4391f45 | 2,030 | ex | Elixir | lib/nebulex/cache/cluster.ex | amplifiedai/nebulex | fa788d9ae71ef0e4aba73f98953e98d8a7644a29 | [
"MIT"
] | 1 | 2021-03-01T16:14:07.000Z | 2021-03-01T16:14:07.000Z | lib/nebulex/cache/cluster.ex | amplifiedai/nebulex | fa788d9ae71ef0e4aba73f98953e98d8a7644a29 | [
"MIT"
] | null | null | null | lib/nebulex/cache/cluster.ex | amplifiedai/nebulex | fa788d9ae71ef0e4aba73f98953e98d8a7644a29 | [
"MIT"
] | null | null | null | defmodule Nebulex.Cache.Cluster do
# The module used by cache adapters for
# distributed caching functionality.
@moduledoc false
@doc """
Joins the node where the cache `name`'s supervisor process is running to the
`name`'s node group.
"""
@spec join(name :: atom) :: :ok
def join(name) do
pid = Process.whereis(name) || self()
if pid in pg_members(name) do
:ok
else
:ok = pg_join(name, pid)
end
end
@doc """
Makes the node where the cache `name`'s supervisor process is running, leave
the `name`'s node group.
"""
@spec leave(name :: atom) :: :ok
def leave(name) do
pg_leave(name, Process.whereis(name) || self())
end
@doc """
Returns the list of nodes joined to given `name`'s node group.
"""
@spec get_nodes(name :: atom) :: [node]
def get_nodes(name) do
name
|> pg_members()
|> Enum.map(&node(&1))
|> :lists.usort()
end
@doc """
Selects one node based on the computation of the `key` slot.
"""
@spec get_node(name :: atom, Nebulex.Cache.key(), keyslot :: module) :: node
def get_node(name, key, keyslot) do
nodes = get_nodes(name)
index = keyslot.hash_slot(key, length(nodes))
Enum.at(nodes, index)
end
## PG
if Code.ensure_loaded?(:pg) do
defp pg_join(name, pid) do
:ok = :pg.join(__MODULE__, name, pid)
end
defp pg_leave(name, pid) do
:ok = :pg.leave(__MODULE__, name, pid)
end
defp pg_members(name) do
:pg.get_members(__MODULE__, name)
end
else
defp pg_join(name, pid) do
name
|> ensure_namespace()
|> :pg2.join(pid)
end
defp pg_leave(name, pid) do
name
|> ensure_namespace()
|> :pg2.leave(pid)
end
defp pg_members(name) do
name
|> ensure_namespace()
|> :pg2.get_members()
end
defp ensure_namespace(name) do
namespace = pg2_namespace(name)
:ok = :pg2.create(namespace)
namespace
end
defp pg2_namespace(name), do: {:nbx, name}
end
end
| 21.827957 | 78 | 0.609852 |
ff88bd7f9f27734d8906f3f8737daae698268893 | 1,137 | exs | Elixir | config/config.exs | youroff/flow_producers | 1e53cc630077a816b599bb62e2775a6f1b6b6c38 | [
"MIT"
] | 1 | 2019-03-23T17:49:12.000Z | 2019-03-23T17:49:12.000Z | config/config.exs | youroff/flow_producers | 1e53cc630077a816b599bb62e2775a6f1b6b6c38 | [
"MIT"
] | null | null | null | config/config.exs | youroff/flow_producers | 1e53cc630077a816b599bb62e2775a6f1b6b6c38 | [
"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 :flow_producers, key: :value
#
# and access this configuration in your application as:
#
# Application.get_env(:flow_producers, :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.677419 | 73 | 0.754617 |
ff88c567f294e5475b5ca850f9198bf83310cc10 | 17,527 | ex | Elixir | lib/mapail.ex | stephenmoloney/mapail | 70a426c4859cca46669914742338c098f95f7808 | [
"MIT"
] | 4 | 2017-05-29T14:24:48.000Z | 2018-08-18T21:56:18.000Z | lib/mapail.ex | stephenmoloney/mapail | 70a426c4859cca46669914742338c098f95f7808 | [
"MIT"
] | 3 | 2016-09-05T20:53:14.000Z | 2021-07-29T19:19:10.000Z | lib/mapail.ex | stephenmoloney/mapail | 70a426c4859cca46669914742338c098f95f7808 | [
"MIT"
] | 1 | 2020-09-28T20:19:54.000Z | 2020-09-28T20:19:54.000Z | defmodule Mapail do
@moduledoc ~S"""
Helper library to convert a map into a struct or a struct to a struct.
Convert string-keyed maps to structs by calling the
`map_to_struct/3` function.
Convert atom-keyed and atom/string mixed key maps to
structs by piping the `stringify_map/1` into the `map_to_struct/3` function.
Convert structs to structs by calling the `struct_to_struct/3` function.
## Note
- The [Maptu](https://github.com/lexhide/maptu) library already provides many of the
functions necessary for converting "encoded" maps to Elixir structs. Maptu may be
all you need - see [Maptu](https://github.com/lexhide/maptu). Mapail builds on top
of `Maptu` and incorporates it as a dependency.
- `Mapail` offers a few additional more lenient approaches to the conversion process
to a struct as explained in use cases. Maptu may be all you need though.
## Features
- String keyed maps: Convert maps with string keys to a corresponding struct.
- Transformations: Optionally, string manipulations can be applied to the key of the map so as to attempt to
force the key to match the key of the struct. Currently, the only transformation option is conversion to snake_case.
- Residual maps: Optionally, the part of the map leftover after the struct has been built can be retrieved
or merged back into the returned struct.
- Helper function for converting atom-keyed maps or string/atom mixed keyed maps to string-keyed only maps.
- Helper function for converting a struct to another struct.
## Limitations
- Currently, only converts one level deep, that is, it does not convert nested structs.
This is a potential TODO task.
## Use Cases
- Scenario 1:
Map and Struct has a perfect match on the keys.
map_to_struct(map, MODULE)` returns `{:ok, %MODULE{} = new_struct}
- Scenario 2:
Map and Struct has an imperfect match on the keys
map_to_struct(map, MODULE, rest: :true)` returns `{:ok, %MODULE{} = new_struct, rest}
- Scenario 3:
Map and Struct has an imperfect match on the keys and a struct with and additional
field named `:mapail` is returned. The value for the `:mapail` fields is a
nested map with all non-matching key-pairs.
map_to_struct(map, MODULE, rest: :merge)` returns `{:ok, %MODULE{} = new_struct}
where `new_struct.mapail` contains the non-mathing `key-value` pairs.
- Scenario 4:
Map and Struct has an imperfect match on the keys. After an initial attempt to
match the map keys to those of the struct keys, any non-matching keys are piped
through transformation function(s) which modify the key of the map in an attempt
to make a new match with the modified key. For now, the only transformations supported
are `[:snake_case]`. `:snake_case` converts the non-matching keys to snake_case.
***NOTE***: This approach is lenient and will make matches that
otherwise would not have matched. It might prove useful where a `json` encoded map
returned from a server uses camelcasing and matches are otherwise missed. ***Only
use this approach when it is explicitly desired behaviour***
map_to_struct(map, MODULE, transformations: [:snake_case], rest: :true)
returns `{:ok, new_struct, rest}`
- Scenario 5:
Map and Struct has a perfect match but the keys in the map are mixed case. Mapail
provides a utility function which can help in this situation.
stringify_map(map) |> map_to_struct(map, MODULE, rest: :false)
returns {:ok, %MODULE{} = new_struct}
- Scenario 6:
Struct and Struct has a perfect match but the __struct__ fields are non-matching.
struct_to_struct(%Notifications.Email{}, User.Email)` returns `{:ok, %User.Email{} = new_struct}
## Example - exact key matching (no transformations)
defmodule User do
defstruct [:first_name, :username, :password]
end
user = %{
"FirstName" => "John",
"Username" => "john",
"password" => "pass",
"age" => 30
}
Mapail.map_to_struct(user, User)
{:ok, %User{
first_name: :nil,
username: :nil,
password: "pass"
}
}
## Example - key matching with `transformations: [:snake_case]`
defmodule User do
defstruct [:first_name, :username, :password]
end
user = %{
"FirstName" => "John",
"Username" => "john",
"password" => "pass",
"age" => 30
}
Mapail.map_to_struct(user, User, transformations: [:snake_case])
{:ok, %User{
first_name: "John",
username: "john",
password: "pass"
}
}
## Example - getting unmatched elements in a separate map
defmodule User do
defstruct [:first_name, :username, :password]
end
user = %{
"FirstName" => "John",
"Username" => "john",
"password" => "pass",
"age" => 30
}
{:ok, user_struct, leftover} = Mapail.map_to_struct(user, User, rest: :true)
{:ok, %User{
first_name: :nil,
username: "pass",
password: :nil
},
%{
"FirstName" => "John",
"Username" => "john",
"age" => 30
}
}
## Example - getting unmatched elements in a merged nested map
defmodule User do
defstruct [:first_name, :username, :password]
end
user = %{
"FirstName" => "John",
"Username" => "john",
"password" => "pass",
"age" => 30
}
Mapail.map_to_struct(user, User, rest: :merge)
{:ok, %User{
first_name: :nil,
username: "pass",
password: :nil,
mapail: %{
"FirstName" => "John",
"Username" => "john",
"age" => 30
}
}
## Dependencies
This library has a dependency on the following library:
- [Maptu](https://hex.pm/packages/maptu) v1.0.0 library. For converting a matching map to a struct.
MIT © 2016 Andrea Leopardi, Aleksei Magusev. [Licence](https://github.com/lexhide/maptu/blob/master/LICENSE.txt)
"""
require Maptu.Extension
@transformations [:snake_case]
@doc """
Convert a map with atom only or atom/string mixed keys
to a map with string keys only.
"""
@spec stringify_map(map) :: {:ok, map} | {:error, String.t}
def stringify_map(map) do
Enum.reduce(map, %{}, fn({k,v}, acc) ->
try do
Map.put(acc, Atom.to_string(k), v)
rescue
_e in ArgumentError ->
is_binary(k) && Map.put(acc, k, v) || {:error, "the key is not an atom nor a binary"}
end
end)
end
@doc """
Convert one form of struct into another struct.
## opts
`[]` - same as `[rest: :false]`, `{:ok, struct}` is returned and any non-matching pairs
will be discarded.
`[rest: :true]`, `{:ok, struct, map}` is returned where map are the non-matching
key-value pairs.
`[rest: :false]`, `{:ok, struct}` is returned and any non-matching pairs
will be discarded.
"""
@spec struct_to_struct(map, atom, list) :: {:ok, struct} | {:ok, struct, map} | {:error, String.t}
def struct_to_struct(old_struct, module, opts \\ []) do
rest = Keyword.get(opts, :rest, :false)
with {:ok, new_struct} <- Map.from_struct(old_struct)
|> Mapail.stringify_map()
|> Mapail.map_to_struct(module, rest: rest) do
{:ok, new_struct}
else
{:ok, new_struct, rest} ->
rest = Enum.reduce(rest, %{}, fn({k,v}, acc) ->
{:ok, nk} = Maptu.Extension.to_existing_atom_safe(k)
Map.put(acc, nk, v)
end)
{:ok, new_struct, rest}
{:error, error} -> {:error, error}
end
end
@doc """
Convert one form of struct into another struct and raises an error on fail.
"""
@spec struct_to_struct!(map, atom) :: struct | no_return
def struct_to_struct!(old_struct, module) do
case struct_to_struct(old_struct, module, rest: :false) do
{:error, error} -> raise(ArgumentError, error)
{:ok, new_struct} -> new_struct
end
end
@doc ~s"""
Converts a string-keyed map to a struct.
## Arguments
- module: The module of the struct to be created.
- map: The map to be converted to a struct.
- opts: See below
- `transformations: [atom]`:
A list of transformations to apply to keys in the map where there are `non-matching`
keys after the inital attempt to match.
Defaults to `transformations: []` ie. no transformations are applied and only exactly matching keys are used to
build a struct.
If set to `transformations: [:snake_case]`, then after an initial run, non-matching keys are converted to
snake_case form and another attempt is made to match the keys with the snake_case keys. This
means less than exactly matching keys are considered a match when building the struct.
- `rest: atom`:
Defaults to `rest: :false`
By setting `rest: :true`, the 'leftover' unmatched key-value pairs of the original map
will also be returned in separate map with the keys in their original form.
Returns as a tuple in the format `{:ok, struct, rest}`
- By setting `rest: :merge`, the 'leftover' unmatched key-value pairs of the original map
will be merged into the struct as a nested map under the key `:mapail`.
Returns as a tuple in the format `{:ok, struct}`
- By setting `rest: :false`, unmatched keys are silently discarded and only the struct
is returned with matching keys. Returns as a tuple in the format `{:ok, struct}`.
Example (matching keys):
iex> Mapail.map_to_struct(%{"first" => 1, "last" => 5}, Range)
{:ok, 1..5}
Example (non-matching keys):
iex> Mapail.map_to_struct(%{"line_or_bytes" => [], "Raw" => :false}, File.Stream)
{:ok, %File.Stream{line_or_bytes: [], modes: [], path: nil, raw: true}}
Example (non-matching keys - with `snake_case` transformations):
iex> Mapail.map_to_struct(%{"first" => 1, "Last" => 5}, Range, transformations: [:snake_case])
{:ok, 1..5}
Example (non-matching keys):
iex> {:ok, r} = Mapail.map_to_struct(%{"first" => 1, "Last" => 5}, Range); Map.keys(r);
[:__struct__, :first, :last]
Example (non-matching keys - with transformations):
iex> {:ok, r} = Mapail.map_to_struct(%{"first" => 1, "Last" => 5}, Range, transformations: [:snake_case]); Map.values(r);
[Range, 1, 5]
Example (non-matching keys):
iex> Mapail.map_to_struct(%{"first" => 1, "last" => 5, "next" => 3}, Range)
{:ok, 1..5}
Example (non-matching keys - capturing excess key-value pairs in separate map called rest):
iex> Mapail.map_to_struct(%{"first" => 1, "last" => 5, "next" => 3}, Range, rest: :true)
{:ok, 1..5, %{"next" => 3}}
Example (non-matching keys - capturing excess key-value pairs and merging into struct under `:mapail` key):
iex> {:ok, r} = Mapail.map_to_struct(%{"first" => 1, "last" => 5, "next" => 3}, Range, rest: :merge); Map.values(r);
[Range, 1, 5, %{"next" => 3}]
iex> {:ok, r} = Mapail.map_to_struct(%{"first" => 1, "last" => 5, "next" => 3}, Range, rest: :merge); Map.keys(r);
[:__struct__, :first, :last, :mapail]
"""
@spec map_to_struct(map, atom, Keyword.t) :: {:error, Maptu.Extension.non_strict_error_reason} |
{:ok, struct} |
{:ok, struct, map}
def map_to_struct(map, module, opts \\ []) do
maptu_fn = if Keyword.get(opts, :rest, :false) in [:true, :merge], do: &Maptu.Extension.struct_rest/2, else: &Maptu.struct/2
map_to_struct(map, module, maptu_fn, opts)
end
@doc ~s"""
Converts a string-keyed map to a struct and raises if it fails.
See `map_to_struct/3`
Example (matching keys):
iex> Mapail.map_to_struct!(%{"first" => 1, "last" => 5}, Range)
1..5
Example (non-matching keys):
iex> Mapail.map_to_struct!(%{"line_or_bytes" => [], "Raw" => :false}, File.Stream)
%File.Stream{line_or_bytes: [], modes: [], path: nil, raw: true}
Example (non-matching keys - with `snake_case` transformations):
iex> Mapail.map_to_struct!(%{"first" => 1, "Last" => 5}, Range, transformations: [:snake_case])
1..5
Example (non-matching keys):
iex> Mapail.map_to_struct!(%{"first" => 1, "Last" => 5}, Range) |> Map.keys();
[:__struct__, :first, :last]
iex> Mapail.map_to_struct!(%{"first" => 1, "Last" => 5}, Range) |> Map.values();
[Range, 1, :nil]
Example (non-matching keys - with transformations):
iex> Mapail.map_to_struct!(%{"first" => 1, "Last" => 5}, Range, transformations: [:snake_case]) |> Map.values();
[Range, 1, 5]
Example (non-matching keys):
iex> Mapail.map_to_struct!(%{"first" => 1, "last" => 5, "next" => 3}, Range)
1..5
Example (non-matching keys - capturing excess key-value pairs in separate map):
iex> Mapail.map_to_struct!(%{"first" => 1, "last" => 5, "next" => 3}, Range, rest: :merge) |> Map.values();
[Range, 1, 5, %{"next" => 3}]
iex> Mapail.map_to_struct!(%{"first" => 1, "last" => 5, "next" => 3}, Range, rest: :merge) |> Map.keys();
[:__struct__, :first, :last, :mapail]
"""
@spec map_to_struct!(map, atom, Keyword.t) :: struct | no_return
def map_to_struct!(map, module, opts \\ []) do
maptu_fn = if Keyword.get(opts, :rest, :false) == :merge, do: &Maptu.Extension.struct_rest/2, else: &Maptu.struct/2
map_to_struct(map, module, maptu_fn, opts)
|> Maptu.Extension.raise_on_error()
end
# private
defp map_to_struct(map, module, maptu_fn, opts) do
map_bin_keys = Map.keys(map)
struct_bin_keys = module.__struct__() |> Map.keys() |> Enum.map(&Atom.to_string/1)
non_matching_keys = non_matching_keys(map_bin_keys, struct_bin_keys)
case non_matching_keys do
[] ->
try do
maptu_fn.(module, map)
rescue
e in FunctionClauseError ->
if e.function == :to_existing_atom_safe && e.module == Maptu && e.arity == 1 do
{:error, :atom_key_not_expected}
else
{:error, :unexpected_error}
end
end
_ ->
{transformed_map, keys_trace} = apply_transformations(map, non_matching_keys, opts)
unmatched_map = get_unmatched_map_with_original_keys(map, keys_trace)
merged_map = Map.merge(transformed_map, unmatched_map)
try do
maptu_fn.(module, merged_map)
rescue
e in FunctionClauseError ->
if e.function == :to_existing_atom_safe&& e.arity == 1 do
{:error, :atom_key_not_expected}
else
{:error, :unexpected_error}
end
end
|> remove_transformed_unmatched_keys(keys_trace)
end
|> case do
{:ok, res, rest} ->
if opts[:rest] == :merge do
{:ok, Map.put(res, :mapail, rest)}
else
{:ok, res, rest}
end
{:ok, res} -> {:ok, res}
{:error, reason} -> {:error, reason}
end
end
defp non_matching_keys(map_bin_keys, struct_bin_keys) do
matching = Enum.filter(struct_bin_keys,
fn(struct_key) -> Enum.member?(map_bin_keys, struct_key) end
)
non_matching = Enum.reject(map_bin_keys,
fn(map_key) -> Enum.member?(matching, map_key) end
)
non_matching
end
defp get_unmatched_map_with_original_keys(map, keys_trace) do
Enum.reduce(keys_trace, %{},
fn({k, v}, acc) ->
if k !== v do
Map.put(acc, k, Map.fetch!(map, k))
else
acc
end
end
)
end
defp apply_transformations(map, non_matching_keys, opts) do
transformations = Keyword.get(opts, :transformations, [])
Enum.any?(transformations, &(Enum.member?(@transformations, &1) == :false)) &&
(msg = "Unknown transformation in #{inspect(transformations)}, allowed transformations: #{inspect(@transformations)}"
raise(ArgumentError, msg))
{transformed_map, keys_trace} =
if :snake_case in transformations do
to_snake_case(map, non_matching_keys)
else
keys_trace = Enum.reduce(map, %{}, fn({k, _v}, acc) -> Map.put(acc, k, k) end)
{map, keys_trace}
end
{transformed_map, keys_trace}
end
defp to_snake_case(map, non_matching_keys) do
Enum.reduce(map, {map, %{}},
fn({k, v}, {mod_map, keys_trace}) ->
case k in non_matching_keys do
:true ->
key =
case is_atom(k) do
:true -> raise ArgumentError, "Mapail expects only maps with string keys."
:false -> Macro.underscore(k) |> String.downcase()
end
{
Map.delete(mod_map, k) |> Map.put(key, v),
Map.put(keys_trace, k, key),
}
:false ->
{
mod_map,
Map.put(keys_trace, k, k)
}
end
end
)
end
defp remove_transformed_unmatched_keys({:error, reason}, _keys_trace) do
{:error, reason}
end
defp remove_transformed_unmatched_keys({:ok, res}, _keys_trace) do
{:ok, res}
end
defp remove_transformed_unmatched_keys({:ok, res, rest}, keys_trace) do
rest =
Enum.reduce(keys_trace, rest,
fn({orig_k, trans_k}, acc) ->
if orig_k !== trans_k && Map.has_key?(acc, trans_k) do
Map.delete(acc, trans_k)
else
acc
end
end
)
{:ok, res, rest}
end
end
| 30.641608 | 128 | 0.616477 |
ff88e81b0bf44790d1652096e008aa34cb073f2a | 2,207 | exs | Elixir | test/controllers/square_controller_test.exs | JKGisMe/square_square_backend | 1b5237fff2c9dab0e03082ecf5a5a28a1133935b | [
"MIT"
] | null | null | null | test/controllers/square_controller_test.exs | JKGisMe/square_square_backend | 1b5237fff2c9dab0e03082ecf5a5a28a1133935b | [
"MIT"
] | null | null | null | test/controllers/square_controller_test.exs | JKGisMe/square_square_backend | 1b5237fff2c9dab0e03082ecf5a5a28a1133935b | [
"MIT"
] | null | null | null | defmodule SquareSquareBackend.SquareControllerTest do
use SquareSquareBackend.ConnCase
alias SquareSquareBackend.Square
@valid_attrs %{dimension: 42, tiles: []}
@invalid_attrs %{}
setup do
conn = conn() |> put_req_header("accept", "application/vnd.api+json")
{:ok, conn: conn}
end
test "lists all entries on index", %{conn: conn} do
conn = get conn, square_path(conn, :index)
assert json_response(conn, 200)["data"] == []
end
test "shows chosen resource", %{conn: conn} do
square = Repo.insert! %Square{}
conn = get conn, square_path(conn, :show, square)
assert json_response(conn, 200)["data"] == %{id: square.id,
dimension: square.dimension,
tiles: square.tiles}
end
test "does not show resource and instead throw error when id is nonexistent", %{conn: conn} do
assert_raise Ecto.NoResultsError, fn ->
get conn, square_path(conn, :show, -1)
end
end
test "creates and renders resource when data is valid", %{conn: conn} do
conn = post conn, square_path(conn, :create), square: @valid_attrs
assert json_response(conn, 201)["data"]["id"]
assert Repo.get_by(Square, @valid_attrs)
end
test "does not create resource and renders errors when data is invalid", %{conn: conn} do
conn = post conn, square_path(conn, :create), square: @invalid_attrs
assert json_response(conn, 422)["errors"] != %{}
end
test "updates and renders chosen resource when data is valid", %{conn: conn} do
square = Repo.insert! %Square{}
conn = put conn, square_path(conn, :update, square), square: @valid_attrs
assert json_response(conn, 200)["data"]["id"]
assert Repo.get_by(Square, @valid_attrs)
end
test "does not update chosen resource and renders errors when data is invalid", %{conn: conn} do
square = Repo.insert! %Square{}
conn = put conn, square_path(conn, :update, square), square: @invalid_attrs
assert json_response(conn, 422)["errors"] != %{}
end
test "deletes chosen resource", %{conn: conn} do
square = Repo.insert! %Square{}
conn = delete conn, square_path(conn, :delete, square)
assert response(conn, 204)
refute Repo.get(Square, square.id)
end
end
| 35.031746 | 98 | 0.680562 |
ff88f40ac2e579ca53a64c7926615e26db352c00 | 2,261 | ex | Elixir | clients/storage_transfer/lib/google_api/storage_transfer/v1/model/time_of_day.ex | pojiro/elixir-google-api | 928496a017d3875a1929c6809d9221d79404b910 | [
"Apache-2.0"
] | 1 | 2021-12-20T03:40:53.000Z | 2021-12-20T03:40:53.000Z | clients/storage_transfer/lib/google_api/storage_transfer/v1/model/time_of_day.ex | pojiro/elixir-google-api | 928496a017d3875a1929c6809d9221d79404b910 | [
"Apache-2.0"
] | 1 | 2020-08-18T00:11:23.000Z | 2020-08-18T00:44:16.000Z | clients/storage_transfer/lib/google_api/storage_transfer/v1/model/time_of_day.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.StorageTransfer.V1.Model.TimeOfDay do
@moduledoc """
Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may choose to allow leap seconds. Related types are google.type.Date and `google.protobuf.Timestamp`.
## Attributes
* `hours` (*type:* `integer()`, *default:* `nil`) - Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.
* `minutes` (*type:* `integer()`, *default:* `nil`) - Minutes of hour of day. Must be from 0 to 59.
* `nanos` (*type:* `integer()`, *default:* `nil`) - Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
* `seconds` (*type:* `integer()`, *default:* `nil`) - Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:hours => integer() | nil,
:minutes => integer() | nil,
:nanos => integer() | nil,
:seconds => integer() | nil
}
field(:hours)
field(:minutes)
field(:nanos)
field(:seconds)
end
defimpl Poison.Decoder, for: GoogleApi.StorageTransfer.V1.Model.TimeOfDay do
def decode(value, options) do
GoogleApi.StorageTransfer.V1.Model.TimeOfDay.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.StorageTransfer.V1.Model.TimeOfDay do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 40.375 | 214 | 0.704998 |
ff88f600c878bd067eb393ab3cd2861731b91f16 | 9,068 | ex | Elixir | lib/mail_slurp_api/api/group_controller.ex | mailslurp/mailslurp-client-elixir | 5b98b91bb327de5216e873cd45b4fbb3c1b55c90 | [
"MIT"
] | 1 | 2021-06-17T18:07:49.000Z | 2021-06-17T18:07:49.000Z | lib/mail_slurp_api/api/group_controller.ex | mailslurp/mailslurp-client-elixir | 5b98b91bb327de5216e873cd45b4fbb3c1b55c90 | [
"MIT"
] | null | null | null | lib/mail_slurp_api/api/group_controller.ex | mailslurp/mailslurp-client-elixir | 5b98b91bb327de5216e873cd45b4fbb3c1b55c90 | [
"MIT"
] | 1 | 2021-03-16T18:55:56.000Z | 2021-03-16T18:55:56.000Z | # NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# https://openapi-generator.tech
# Do not edit the class manually.
defmodule MailSlurpAPI.Api.GroupController do
@moduledoc """
API calls for all endpoints tagged `GroupController`.
"""
alias MailSlurpAPI.Connection
import MailSlurpAPI.RequestBuilder
@doc """
Add contacts to a group
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- group_id (String.t): groupId
- update_group_contacts_option (UpdateGroupContacts): updateGroupContactsOption
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.GroupContactsDto{}} on success
{:error, info} on failure
"""
@spec add_contacts_to_group(Tesla.Env.client, String.t, MailSlurpAPI.Model.UpdateGroupContacts.t, keyword()) :: {:ok, MailSlurpAPI.Model.GroupContactsDto.t} | {:error, Tesla.Env.t}
def add_contacts_to_group(connection, group_id, update_group_contacts_option, _opts \\ []) do
%{}
|> method(:put)
|> url("/groups/#{group_id}/contacts")
|> add_param(:body, :body, update_group_contacts_option)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.GroupContactsDto{}},
{ 201, false},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Create a group
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- create_group_options (CreateGroupOptions): createGroupOptions
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.GroupDto{}} on success
{:error, info} on failure
"""
@spec create_group(Tesla.Env.client, MailSlurpAPI.Model.CreateGroupOptions.t, keyword()) :: {:ok, MailSlurpAPI.Model.GroupDto.t} | {:error, Tesla.Env.t}
def create_group(connection, create_group_options, _opts \\ []) do
%{}
|> method(:post)
|> url("/groups")
|> add_param(:body, :body, create_group_options)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 201, %MailSlurpAPI.Model.GroupDto{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Delete group
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- group_id (String.t): groupId
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %{}} on success
{:error, info} on failure
"""
@spec delete_group(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
def delete_group(connection, group_id, _opts \\ []) do
%{}
|> method(:delete)
|> url("/groups/#{group_id}")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 204, false},
{ 401, false},
{ 403, false}
])
end
@doc """
Get all Contact Groups in paginated format
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :before (DateTime.t): Filter by created at before the given timestamp
- :page (integer()): Optional page index in list pagination
- :since (DateTime.t): Filter by created at after the given timestamp
- :size (integer()): Optional page size in list pagination
- :sort (String.t): Optional createdAt sort direction ASC or DESC
## Returns
{:ok, %MailSlurpAPI.Model.PageGroupProjection{}} on success
{:error, info} on failure
"""
@spec get_all_groups(Tesla.Env.client, keyword()) :: {:ok, MailSlurpAPI.Model.PageGroupProjection.t} | {:error, Tesla.Env.t}
def get_all_groups(connection, opts \\ []) do
optional_params = %{
:"before" => :query,
:"page" => :query,
:"since" => :query,
:"size" => :query,
:"sort" => :query
}
%{}
|> method(:get)
|> url("/groups/paginated")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.PageGroupProjection{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get group
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- group_id (String.t): groupId
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.GroupDto{}} on success
{:error, info} on failure
"""
@spec get_group(Tesla.Env.client, String.t, keyword()) :: {:ok, MailSlurpAPI.Model.GroupDto.t} | {:error, Tesla.Env.t}
def get_group(connection, group_id, _opts \\ []) do
%{}
|> method(:get)
|> url("/groups/#{group_id}")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.GroupDto{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get group and contacts belonging to it
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- group_id (String.t): groupId
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.GroupContactsDto{}} on success
{:error, info} on failure
"""
@spec get_group_with_contacts(Tesla.Env.client, String.t, keyword()) :: {:ok, MailSlurpAPI.Model.GroupContactsDto.t} | {:error, Tesla.Env.t}
def get_group_with_contacts(connection, group_id, _opts \\ []) do
%{}
|> method(:get)
|> url("/groups/#{group_id}/contacts")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.GroupContactsDto{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get group and paginated contacts belonging to it
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- group_id (String.t): groupId
- opts (KeywordList): [optional] Optional parameters
- :before (DateTime.t): Filter by created at before the given timestamp
- :page (integer()): Optional page index in group contact pagination
- :since (DateTime.t): Filter by created at after the given timestamp
- :size (integer()): Optional page size in group contact pagination
- :sort (String.t): Optional createdAt sort direction ASC or DESC
## Returns
{:ok, %MailSlurpAPI.Model.PageContactProjection{}} on success
{:error, info} on failure
"""
@spec get_group_with_contacts_paginated(Tesla.Env.client, String.t, keyword()) :: {:ok, MailSlurpAPI.Model.PageContactProjection.t} | {:error, Tesla.Env.t}
def get_group_with_contacts_paginated(connection, group_id, opts \\ []) do
optional_params = %{
:"before" => :query,
:"page" => :query,
:"since" => :query,
:"size" => :query,
:"sort" => :query
}
%{}
|> method(:get)
|> url("/groups/#{group_id}/contacts-paginated")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.PageContactProjection{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get all groups
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, [%GroupProjection{}, ...]} on success
{:error, info} on failure
"""
@spec get_groups(Tesla.Env.client, keyword()) :: {:ok, list(MailSlurpAPI.Model.GroupProjection.t)} | {:error, Tesla.Env.t}
def get_groups(connection, _opts \\ []) do
%{}
|> method(:get)
|> url("/groups")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, [%MailSlurpAPI.Model.GroupProjection{}]},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Remove contacts from a group
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- group_id (String.t): groupId
- update_group_contacts_option (UpdateGroupContacts): updateGroupContactsOption
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.GroupContactsDto{}} on success
{:error, info} on failure
"""
@spec remove_contacts_from_group(Tesla.Env.client, String.t, MailSlurpAPI.Model.UpdateGroupContacts.t, keyword()) :: {:ok, MailSlurpAPI.Model.GroupContactsDto.t} | {:error, Tesla.Env.t}
def remove_contacts_from_group(connection, group_id, update_group_contacts_option, _opts \\ []) do
%{}
|> method(:delete)
|> url("/groups/#{group_id}/contacts")
|> add_param(:body, :body, update_group_contacts_option)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.GroupContactsDto{}},
{ 204, false},
{ 401, false},
{ 403, false}
])
end
end
| 30.738983 | 187 | 0.642258 |
ff892dacb7918fb18f77931b7bd22b6d798e6805 | 773 | ex | Elixir | web/models/episode.ex | thluiz/yehudimtv | 71aba0ee537b4bba28474fb20d3209fc261a03d7 | [
"MIT"
] | null | null | null | web/models/episode.ex | thluiz/yehudimtv | 71aba0ee537b4bba28474fb20d3209fc261a03d7 | [
"MIT"
] | null | null | null | web/models/episode.ex | thluiz/yehudimtv | 71aba0ee537b4bba28474fb20d3209fc261a03d7 | [
"MIT"
] | null | null | null | defmodule Yehudimtv.Episode do
use Yehudimtv.Web, :model
schema "episodes" do
field :title, :string
field :rabbi, :string
field :identifier, :string
field :publication, Ecto.DateTime
field :order, :integer
field :spotlight, :boolean, default: false
has_many :videos, Yehudimtv.Video
belongs_to :tvshow, Yehudimtv.TvShow
timestamps
end
@required_fields ~w(title rabbi identifier tvshow_id publication order spotlight)
@optional_fields ~w()
@doc """
Creates a changeset based on the `model` and `params`.
If `params` are nil, an invalid changeset is returned
with no validation performed.
"""
def changeset(model, params \\ :empty) do
model
|> cast(params, @required_fields, @optional_fields)
end
end
| 24.15625 | 83 | 0.703752 |
ff894054aa688c98feded0de4ebbb43b819ed073 | 1,169 | exs | Elixir | 06-record.exs | lbiru/30-days-of-elixir | 8472b6bf4a2f0a12dc6aea930abde2d50867b460 | [
"MIT"
] | 1 | 2020-05-27T04:32:37.000Z | 2020-05-27T04:32:37.000Z | 06-record.exs | tifazxy/30-days-of-elixir | 1d3e5cc1580ecbfdf9bd8eafed6ed68cb681404a | [
"MIT"
] | null | null | null | 06-record.exs | tifazxy/30-days-of-elixir | 1d3e5cc1580ecbfdf9bd8eafed6ed68cb681404a | [
"MIT"
] | 1 | 2018-09-30T00:43:04.000Z | 2018-09-30T00:43:04.000Z | ExUnit.start
defmodule User do
defstruct email: nil, password: nil
end
defimpl String.Chars, for: User do
def to_string(%User{email: email}) do
email
end
end
defmodule RecordTest do
use ExUnit.Case
defmodule ScopeTest do
use ExUnit.Case
require Record
Record.defrecordp :person, first_name: nil, last_name: nil, age: nil
test "defrecordp" do
p = person(first_name: "Kai", last_name: "Morgan", age: 5) # regular function call
assert p == {:person, "Kai", "Morgan", 5} # just a tuple!
end
end
# CompileError
# test "defrecordp out of scope" do
# person()
# end
def sample do
%User{email: "kai@example.com", password: "trains"} # special % syntax for struct creation
end
test "defstruct" do
assert sample == %{__struct__: User, email: "kai@example.com", password: "trains"}
end
test "property" do
assert sample.email == "kai@example.com"
end
test "update" do
u = sample
u2 = %User{u | email: "tim@example.com"}
assert u2 == %User{email: "tim@example.com", password: "trains"}
end
test "protocol" do
assert to_string(sample) == "kai@example.com"
end
end
| 20.875 | 94 | 0.65355 |
ff89481d46bb7fdc5a0b8991ee1850df04e7e277 | 1,672 | ex | Elixir | apps/astarte_realm_management_api/lib/astarte_realm_management_api_web/views/error_helpers.ex | matt-mazzucato/astarte | 34d84941a5019efc42321052f7f34b7d907a38f2 | [
"Apache-2.0"
] | 191 | 2018-03-30T13:23:08.000Z | 2022-03-02T12:05:32.000Z | apps/astarte_realm_management_api/lib/astarte_realm_management_api_web/views/error_helpers.ex | matt-mazzucato/astarte | 34d84941a5019efc42321052f7f34b7d907a38f2 | [
"Apache-2.0"
] | 402 | 2018-03-30T13:37:00.000Z | 2022-03-31T16:47:10.000Z | apps/astarte_realm_management_api/lib/astarte_realm_management_api_web/views/error_helpers.ex | matt-mazzucato/astarte | 34d84941a5019efc42321052f7f34b7d907a38f2 | [
"Apache-2.0"
] | 24 | 2018-03-30T13:29:48.000Z | 2022-02-28T11:10:26.000Z | #
# This file is part of Astarte.
#
# Copyright 2017 Ispirata Srl
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
defmodule Astarte.RealmManagement.APIWeb.ErrorHelpers do
@moduledoc """
Conveniences for translating and building error messages.
"""
@doc """
Translates an error message using gettext.
"""
def translate_error({msg, opts}) do
# Because error messages were defined within Ecto, we must
# call the Gettext module passing our Gettext backend. We
# also use the "errors" domain as translations are placed
# in the errors.po file.
# Ecto will pass the :count keyword if the error message is
# meant to be pluralized.
# On your own code and templates, depending on whether you
# need the message to be pluralized or not, this could be
# written simply as:
#
# dngettext "errors", "1 file", "%{count} files", count
# dgettext "errors", "is invalid"
#
if count = opts[:count] do
Gettext.dngettext(Astarte.RealmManagement.APIWeb.Gettext, "errors", msg, msg, count, opts)
else
Gettext.dgettext(Astarte.RealmManagement.APIWeb.Gettext, "errors", msg, opts)
end
end
end
| 34.833333 | 96 | 0.710526 |
ff89551a4ce32f45f5b42140adfe15e5d5895529 | 1,844 | ex | Elixir | clients/dfa_reporting/lib/google_api/dfa_reporting/v33/model/date_range.ex | MasashiYokota/elixir-google-api | 975dccbff395c16afcb62e7a8e411fbb58e9ab01 | [
"Apache-2.0"
] | null | null | null | clients/dfa_reporting/lib/google_api/dfa_reporting/v33/model/date_range.ex | MasashiYokota/elixir-google-api | 975dccbff395c16afcb62e7a8e411fbb58e9ab01 | [
"Apache-2.0"
] | 1 | 2020-12-18T09:25:12.000Z | 2020-12-18T09:25:12.000Z | clients/dfa_reporting/lib/google_api/dfa_reporting/v33/model/date_range.ex | MasashiYokota/elixir-google-api | 975dccbff395c16afcb62e7a8e411fbb58e9ab01 | [
"Apache-2.0"
] | 1 | 2020-10-04T10:12:44.000Z | 2020-10-04T10:12:44.000Z | # Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.
defmodule GoogleApi.DFAReporting.V33.Model.DateRange do
@moduledoc """
Represents a date range.
## Attributes
* `endDate` (*type:* `Date.t`, *default:* `nil`) -
* `kind` (*type:* `String.t`, *default:* `nil`) - The kind of resource this is, in this case dfareporting#dateRange.
* `relativeDateRange` (*type:* `String.t`, *default:* `nil`) - The date range relative to the date of when the report is run.
* `startDate` (*type:* `Date.t`, *default:* `nil`) -
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:endDate => Date.t(),
:kind => String.t(),
:relativeDateRange => String.t(),
:startDate => Date.t()
}
field(:endDate, as: Date)
field(:kind)
field(:relativeDateRange)
field(:startDate, as: Date)
end
defimpl Poison.Decoder, for: GoogleApi.DFAReporting.V33.Model.DateRange do
def decode(value, options) do
GoogleApi.DFAReporting.V33.Model.DateRange.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.DFAReporting.V33.Model.DateRange do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 32.928571 | 129 | 0.694143 |
ff89b850ee7da31c6c3348198344b4d2829f4ad5 | 1,990 | exs | Elixir | lib/exercism/space-age/space_age_test.exs | sprql/experimentex | 6c8a37ea03b74c5bfece1b2bec21c163a2f2df2f | [
"MIT"
] | null | null | null | lib/exercism/space-age/space_age_test.exs | sprql/experimentex | 6c8a37ea03b74c5bfece1b2bec21c163a2f2df2f | [
"MIT"
] | null | null | null | lib/exercism/space-age/space_age_test.exs | sprql/experimentex | 6c8a37ea03b74c5bfece1b2bec21c163a2f2df2f | [
"MIT"
] | null | null | null | if !System.get_env("EXERCISM_TEST_EXAMPLES") do
Code.load_file("space_age.exs", __DIR__)
end
ExUnit.start
# ExUnit.configure exclude: :pending, trace: true
# You need to define a SpaceAge module containing a function age_on that given a
# planet (:earth, :saturn, etc) and a number of seconds returns the age in years
# on that planet as a floating point number.
defmodule SpageAgeTest do
use ExUnit.Case
@tag :pending
test "age on Earth" do
input = 1_000_000_000
assert_in_delta 31.69, SpaceAge.age_on(:earth, input), 0.005
end
@tag :pending
test "age on Mercury" do
input = 2_134_835_688
assert_in_delta 67.65, SpaceAge.age_on(:earth, input), 0.005
assert_in_delta 280.88, SpaceAge.age_on(:mercury, input), 0.005
end
@tag :pending
test "age on Venus" do
input = 189_839_836
assert_in_delta 6.02, SpaceAge.age_on(:earth, input), 0.005
assert_in_delta 9.78, SpaceAge.age_on(:venus, input), 0.005
end
@tag :pending
test "age on Mars" do
input = 2_329_871_239
assert_in_delta 73.83, SpaceAge.age_on(:earth, input), 0.005
assert_in_delta 39.25, SpaceAge.age_on(:mars, input), 0.005
end
@tag :pending
test "age on Jupiter" do
input = 901_876_382
assert_in_delta 28.58, SpaceAge.age_on(:earth, input), 0.005
assert_in_delta 2.41, SpaceAge.age_on(:jupiter, input), 0.005
end
@tag :pending
test "age on Saturn" do
input = 3_000_000_000
assert_in_delta 95.06, SpaceAge.age_on(:earth, input), 0.005
assert_in_delta 3.23, SpaceAge.age_on(:saturn, input), 0.005
end
@tag :pending
test "age on Uranus" do
input = 3_210_123_456
assert_in_delta 101.72, SpaceAge.age_on(:earth, input), 0.005
assert_in_delta 1.21, SpaceAge.age_on(:uranus, input), 0.005
end
@tag :pending
test "age on Neptune" do
input = 8_210_123_456
assert_in_delta 260.16, SpaceAge.age_on(:earth, input), 0.005
assert_in_delta 1.58, SpaceAge.age_on(:neptune, input), 0.005
end
end
| 28.428571 | 80 | 0.707538 |
ff89bb40a42531569d804074c806852c7a81f2da | 74 | exs | Elixir | plugins/one_settings/test/test_helper.exs | smpallen99/ucx_ucc | 47225f205a6ac4aacdb9bb4f7512dcf4092576ad | [
"MIT"
] | 11 | 2017-05-15T18:35:05.000Z | 2018-02-05T18:27:40.000Z | plugins/one_settings/test/test_helper.exs | anndream/infinity_one | 47225f205a6ac4aacdb9bb4f7512dcf4092576ad | [
"MIT"
] | 15 | 2017-11-27T10:38:05.000Z | 2018-02-09T20:42:08.000Z | plugins/one_settings/test/test_helper.exs | anndream/infinity_one | 47225f205a6ac4aacdb9bb4f7512dcf4092576ad | [
"MIT"
] | 4 | 2017-09-13T11:34:16.000Z | 2018-02-26T13:37:06.000Z | ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(InfinityOne.Repo, :manual)
| 18.5 | 57 | 0.783784 |
ff89e207d571ccf69bd6356b366f5f9a155443d2 | 272 | ex | Elixir | apps/score_saber/lib/score_saber/model/score.ex | insprac/beat_sync | 57444675bca3703c99c0051928f0020225283ffa | [
"MIT"
] | 1 | 2018-10-19T02:06:52.000Z | 2018-10-19T02:06:52.000Z | apps/score_saber/lib/score_saber/model/score.ex | insprac/beat_sync | 57444675bca3703c99c0051928f0020225283ffa | [
"MIT"
] | null | null | null | apps/score_saber/lib/score_saber/model/score.ex | insprac/beat_sync | 57444675bca3703c99c0051928f0020225283ffa | [
"MIT"
] | null | null | null | defmodule ScoreSaber.Model.Score do
defstruct(
rank: nil,
user: nil,
score: 0,
accuracy: 0,
pp: 0
)
@type t :: %__MODULE__{
rank: integer,
user: ScoreSaber.Model.User.t,
score: integer,
accuracy: integer,
pp: integer
}
end
| 15.111111 | 35 | 0.591912 |
ff8a0eaa62bccc9a5efd85baae4c3fc38509825b | 646 | exs | Elixir | youtube/elixir_casts/chat/config/test.exs | jim80net/elixir_tutorial_projects | db19901a9305b297faa90642bebcc08455621b52 | [
"Unlicense"
] | null | null | null | youtube/elixir_casts/chat/config/test.exs | jim80net/elixir_tutorial_projects | db19901a9305b297faa90642bebcc08455621b52 | [
"Unlicense"
] | 1 | 2021-03-28T13:57:15.000Z | 2021-03-29T12:42:21.000Z | youtube/elixir_casts/chat/config/test.exs | jim80net/elixir_tutorial_projects | db19901a9305b297faa90642bebcc08455621b52 | [
"Unlicense"
] | null | null | null | use Mix.Config
# Configure your database
#
# The MIX_TEST_PARTITION environment variable can be used
# to provide built-in test partitioning in CI environment.
# Run `mix help test` for more information.
config :chat, Chat.Repo,
username: "postgres",
password: "postgres",
database: "chat_test#{System.get_env("MIX_TEST_PARTITION")}",
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 :chat, ChatWeb.Endpoint,
http: [port: 4002],
server: false
# Print only warnings and errors during test
config :logger, level: :warn
| 28.086957 | 63 | 0.743034 |
ff8a2422bcfbc9443fc987c912ed4769d3eaf662 | 1,127 | ex | Elixir | apps/bytepack/lib/bytepack/application.ex | dashbitco/bytepack_archive | 79f8e62149d020f2afcc501592ed399f7ce7a60b | [
"Unlicense"
] | 313 | 2020-12-03T17:26:24.000Z | 2022-03-18T09:05:14.000Z | apps/bytepack/lib/bytepack/application.ex | dashbitco/bytepack_archive | 79f8e62149d020f2afcc501592ed399f7ce7a60b | [
"Unlicense"
] | null | null | null | apps/bytepack/lib/bytepack/application.ex | dashbitco/bytepack_archive | 79f8e62149d020f2afcc501592ed399f7ce7a60b | [
"Unlicense"
] | 57 | 2020-12-03T17:41:53.000Z | 2022-03-17T17:28:16.000Z | defmodule Bytepack.Application do
@moduledoc false
use Application
def start(_type, _args) do
topologies = Application.fetch_env!(:libcluster, :topologies)
children = [
{Cluster.Supervisor, [topologies, [name: Bytepack.ClusterSupervisor]]},
{Finch,
name: Bytepack.Finch,
pools: %{
:default => [size: 10, count: 2],
"https://api.postmarkapp.com" => [size: 10, count: 2],
"https://storage.googleapis.com" => [size: 20, count: 4]
}},
goth_spec(),
Bytepack.Repo,
{Phoenix.PubSub, name: Bytepack.PubSub},
Bytepack.Extensions.Plug.DevStore
]
Supervisor.start_link(children, strategy: :one_for_one, name: Bytepack.Supervisor)
end
defp goth_spec() do
name = Bytepack.Goth
case Application.fetch_env(:bytepack, :goth_credentials) do
{:ok, credentials} ->
{Goth,
name: name,
http_client: {Goth.HTTPClient.Finch, name: Bytepack.Finch},
credentials: Jason.decode!(credentials)}
:error ->
%{id: name, start: {Function, :identity, [:ignore]}}
end
end
end
| 26.833333 | 86 | 0.617569 |
ff8a2dd554ea73e11c2bef13ae75ddd4d1cda8ff | 2,095 | exs | Elixir | test/controllers/user_controller_test.exs | GoberInfinity/ExamplePhoenix | 4f2e016000a55dd4dbc28409dd214f0923e38e32 | [
"MIT"
] | null | null | null | test/controllers/user_controller_test.exs | GoberInfinity/ExamplePhoenix | 4f2e016000a55dd4dbc28409dd214f0923e38e32 | [
"MIT"
] | null | null | null | test/controllers/user_controller_test.exs | GoberInfinity/ExamplePhoenix | 4f2e016000a55dd4dbc28409dd214f0923e38e32 | [
"MIT"
] | null | null | null | defmodule Otherpool.UserControllerTest do
use Otherpool.ConnCase
alias Otherpool.User
@valid_attrs %{email: "some content", fullname: "some content"}
@invalid_attrs %{}
setup %{conn: conn} do
{:ok, conn: put_req_header(conn, "accept", "application/json")}
end
test "lists all entries on index", %{conn: conn} do
conn = get conn, user_path(conn, :index)
assert json_response(conn, 200)["data"] == []
end
test "shows chosen resource", %{conn: conn} do
user = Repo.insert! %User{}
conn = get conn, user_path(conn, :show, user)
assert json_response(conn, 200)["data"] == %{"id" => user.id,
"fullname" => user.fullname,
"email" => user.email}
end
test "renders page not found when id is nonexistent", %{conn: conn} do
assert_error_sent 404, fn ->
get conn, user_path(conn, :show, -1)
end
end
test "creates and renders resource when data is valid", %{conn: conn} do
conn = post conn, user_path(conn, :create), user: @valid_attrs
assert json_response(conn, 201)["data"]["id"]
assert Repo.get_by(User, @valid_attrs)
end
test "does not create resource and renders errors when data is invalid", %{conn: conn} do
conn = post conn, user_path(conn, :create), user: @invalid_attrs
assert json_response(conn, 422)["errors"] != %{}
end
test "updates and renders chosen resource when data is valid", %{conn: conn} do
user = Repo.insert! %User{}
conn = put conn, user_path(conn, :update, user), user: @valid_attrs
assert json_response(conn, 200)["data"]["id"]
assert Repo.get_by(User, @valid_attrs)
end
test "does not update chosen resource and renders errors when data is invalid", %{conn: conn} do
user = Repo.insert! %User{}
conn = put conn, user_path(conn, :update, user), user: @invalid_attrs
assert json_response(conn, 422)["errors"] != %{}
end
test "deletes chosen resource", %{conn: conn} do
user = Repo.insert! %User{}
conn = delete conn, user_path(conn, :delete, user)
assert response(conn, 204)
refute Repo.get(User, user.id)
end
end
| 33.790323 | 98 | 0.662053 |
ff8a3614d2a7148c4069b666dd0ca8d714dde85d | 2,261 | exs | Elixir | test/test_helper.exs | ybod/dicon | 9c83a6ed7562af4582eb55fc0f813f10fe5f3feb | [
"ISC"
] | null | null | null | test/test_helper.exs | ybod/dicon | 9c83a6ed7562af4582eb55fc0f813f10fe5f3feb | [
"ISC"
] | null | null | null | test/test_helper.exs | ybod/dicon | 9c83a6ed7562af4582eb55fc0f813f10fe5f3feb | [
"ISC"
] | null | null | null | ExUnit.start(refute_receive_timeout: 200)
Mix.shell(Mix.Shell.Process)
defmodule PathHelpers do
def fixtures_path() do
Path.expand("fixtures", __DIR__)
end
def fixture_path(extra) do
Path.join(fixtures_path(), extra)
end
end
defmodule DiconTest.Case do
use ExUnit.CaseTemplate
@behaviour Dicon.Executor
using _ do
quote do
import unquote(__MODULE__), only: [flush_reply: 1, on_exec: 2]
end
end
setup_all do
Application.put_env(:dicon, :executor, __MODULE__)
on_exit(fn ->
Application.delete_env(:dicon, :executor)
end)
end
setup do
Application.put_env(:dicon, __MODULE__, [test_pid: self()])
on_exit(fn ->
Application.delete_env(:dicon, __MODULE__)
end)
end
def connect(authority) do
conn = make_ref()
notify_test({:dicon, conn, :connect, [authority]})
{:ok, conn}
end
def exec(conn, command, device) do
command = List.to_string(command)
run_callback(command, device)
notify_test({:dicon, conn, :exec, [command]})
:ok
end
def write_file(conn, target, content, mode) do
content = IO.iodata_to_binary(content)
target = List.to_string(target)
notify_test({:dicon, conn, :write_file, [target, content, mode]})
:ok
end
def copy(conn, source, target) do
source = List.to_string(source)
target = List.to_string(target)
notify_test({:dicon, conn, :copy, [source, target]})
:ok
end
defp notify_test(message) do
:dicon
|> Application.fetch_env!(__MODULE__)
|> Keyword.fetch!(:test_pid)
|> send(message)
end
def on_exec(command, callback) do
env =
:dicon
|> Application.fetch_env!(__MODULE__)
|> Keyword.update(:exec_callbacks, %{command => callback}, &Map.put(&1, command, callback))
Application.put_env(:dicon, __MODULE__, env)
end
def flush_reply(conn) do
receive do
{:dicon, ^conn, _, _} ->
flush_reply(conn)
after
50 -> :ok
end
end
defp run_callback(command, device) do
env = Application.fetch_env!(:dicon, __MODULE__)
{callback, env} = pop_in(env, [:exec_callbacks, command])
if callback do
callback.(device)
Application.put_env(:dicon, __MODULE__, env)
end
:ok
end
end
| 22.386139 | 97 | 0.657674 |
ff8a3f011c001678d26ce30e2d66e19617de699f | 670 | exs | Elixir | elixir/protein-translation/protein_translation.exs | drm2/exercisms | 2b45c8fdff9c04cceae1875237c65ddb1acd2107 | [
"MIT"
] | null | null | null | elixir/protein-translation/protein_translation.exs | drm2/exercisms | 2b45c8fdff9c04cceae1875237c65ddb1acd2107 | [
"MIT"
] | null | null | null | elixir/protein-translation/protein_translation.exs | drm2/exercisms | 2b45c8fdff9c04cceae1875237c65ddb1acd2107 | [
"MIT"
] | null | null | null | defmodule ProteinTranslation do
@doc """
Given an RNA string, return a list of proteins specified by codons, in order.
"""
@spec of_rna(String.t()) :: { atom, list(String.t()) }
def of_rna(rna) do
end
@doc """
Given a codon, return the corresponding protein
UGU -> Cysteine
UGC -> Cysteine
UUA -> Leucine
UUG -> Leucine
AUG -> Methionine
UUU -> Phenylalanine
UUC -> Phenylalanine
UCU -> Serine
UCC -> Serine
UCA -> Serine
UCG -> Serine
UGG -> Tryptophan
UAU -> Tyrosine
UAC -> Tyrosine
UAA -> STOP
UAG -> STOP
UGA -> STOP
"""
@spec of_codon(String.t()) :: { atom, String.t() }
def of_codon(codon) do
end
end
| 19.142857 | 79 | 0.623881 |
ff8a4aa7aa80f5f02e86d82dc4876e14aa929128 | 370 | ex | Elixir | custom_upstream_proxy.ex | adaptunit/upstream_headers | a60842392d4e9df793c76b847a2e2044deaeadf6 | [
"MIT"
] | null | null | null | custom_upstream_proxy.ex | adaptunit/upstream_headers | a60842392d4e9df793c76b847a2e2044deaeadf6 | [
"MIT"
] | null | null | null | custom_upstream_proxy.ex | adaptunit/upstream_headers | a60842392d4e9df793c76b847a2e2044deaeadf6 | [
"MIT"
] | null | null | null | defmodule CustomUpstreamProxy do
@behaviour Plug
def init(opts) do
{UpstreamHeadersProxy.init(opts), ReverseProxyPlug.init(opts)}
end
def call(conn, {optsPlug1, optsPlug2}) do
with %{halted: false} = conn <- UpstreamHeaders.call(conn, optsPlug1),
%{halted: false} = conn <- ReverseProxyPlug.call(conn, optsPlug2),
do: conn
end
end
| 24.666667 | 75 | 0.683784 |
ff8a779f544fa3f7aec8a66382fd358e6afbece0 | 8,078 | ex | Elixir | lib/nadia/bot_graph.ex | lightcyphers/nadia | b44535138aac3c61a40816d9460a731127360f1e | [
"MIT"
] | null | null | null | lib/nadia/bot_graph.ex | lightcyphers/nadia | b44535138aac3c61a40816d9460a731127360f1e | [
"MIT"
] | null | null | null | lib/nadia/bot_graph.ex | lightcyphers/nadia | b44535138aac3c61a40816d9460a731127360f1e | [
"MIT"
] | null | null | null | defmodule Nadia.BotGraph do
@moduledoc """
Provides access to Telegra.ph API.
## Reference
http://telegra.ph/api
"""
alias Nadia.Graph.Model.{Account, Error}
import Nadia.Bot.GraphAPI
@doc """
Use this method to create a new Telegraph account. Most users only need one account, but this can be useful for channel administrators who would like to keep individual author names and profile links for each of their channels. On success, returns an Account object with the regular fields and an additional access_token field.
Args:
* `bot` - Bot name
* `short_name` - account name, helps users with several accounts remember which they are currently using. Displayed to the user above the "Edit/Publish" button on Telegra.ph, other users don't see this name. 1-32 characters
* `author_name` - default author name used when creating new articles. 0-128 characters
* `options` - orddict of options
Options:
* `:author_url` - default profile link, opened when users click on the author's name below the title. Can be any link, not necessarily to a Telegram profile or channel. 0-512 characters
"""
@spec create_account(atom, binary, binary, [{atom, any}]) ::
{:ok, Account.t()} | {:error, Error.t()}
def create_account(bot, short_name, author_name, options \\ []) do
request(bot, "createAccount", [short_name: short_name, author_name: author_name] ++ options)
end
@doc """
Use this method to update information about a Telegraph account. Pass only the parameters that you want to edit. On success, returns an Account object with the default fields.
Args:
* `bot` - Bot name
* `access_token` - access token of the Telegraph account
* `short_name` - new account name. 1-32 characters
* `author_name` - new default author name used when creating new articles. 0-128 characters
* `options` - orddict of options
Options:
* `:author_url` - new default profile link, opened when users click on the author's name below the title. Can be any link, not necessarily to a Telegram profile or channel. 0-512 characters
"""
@spec edit_account_info(atom, binary, binary, binary, [{atom, any}]) ::
{:ok, Account.t()} | {:error, Error.t()}
def edit_account_info(bot, access_token, short_name, author_name, options \\ []) do
request(
bot,
"editAccountInfo",
[access_token: access_token, short_name: short_name, author_name: author_name] ++ options
)
end
@doc """
Use this method to get information about a Telegraph account. Returns an Account object on success.
Args:
* `bot` - Bot name
* `access_token` - access token of the Telegraph account
* `fields` - list of account fields to return. Available fields: short_name, author_name, author_url, auth_url, page_count
"""
@spec get_account_info(atom, binary, [binary]) :: {:ok, Account.t()} | {:error, Error.t()}
def get_account_info(bot, access_token, fields \\ ["short_name", "author_name", "author_url"]) do
request(bot, "getAccountInfo", access_token: access_token, fields: fields)
end
@doc """
Use this method to revoke access_token and generate a new one, for example, if the user would like to reset all connected sessions, or you have reasons to believe the token was compromised. On success, returns an Account object with new access_token and auth_url fields.
Args:
* `bot` - Bot name
* `access_token` - access token of the Telegraph account
"""
@spec revoke_access_token(atom, binary) :: {:ok, Account.t()} | {:error, Error.t()}
def revoke_access_token(bot, access_token) do
request(bot, "revokeAccessToken", access_token: access_token)
end
@doc """
Use this method to get a list of pages belonging to a Telegraph account. Returns a PageList object, sorted by most recently created pages first.
Args:
* `bot` - Bot name
* `access_token` - access token of the Telegraph account
* `offset` - sequential number of the first page to be returned
* `limit` - limits the number of pages to be retrieved. 0-200
"""
@spec get_page_list(atom, binary, integer, integer) ::
{:ok, [[PageList.t()]]} | {:error, Error.t()}
def get_page_list(bot, access_token, offset \\ 0, limit \\ 50) do
request(bot, "getPageList", access_token: access_token, offset: offset, limit: limit)
end
@doc """
Use this method to create a new Telegraph page. On success, returns a Page object.
Args:
* `bot` - Bot name
* `access_token` - (String) Access token of the Telegraph account.
* `title` - (String, 1-256 characters) Page title.
* `content` - (Array of Node, up to 64 KB)` Content of the page.
* `options` - orddict of options
Options:
* `:author_name` - (String, 0-128 characters) Author name, displayed below the article's title.
* `:author_url` - (String, 0-512 characters) Profile link, opened when users click on the author's name below the title. Can be any link, not necessarily to a Telegram profile or channel.
* `:return_content` - (Boolean, default = false) If true, a content field will be returned in the Page object (see: Content format).
"""
@spec create_page(atom, binary, binary, binary, [{atom, any}]) ::
{:ok, Page.t()} | {:error, Error.t()}
def create_page(bot, access_token, title, content, options \\ []) do
request(
bot,
"createPage",
[access_token: access_token, title: title, content: content] ++ options
)
end
@doc """
Use this method to edit an existing Telegraph page. On success, returns a Page object.
Args:
* `bot` - Bot name
* `access_token` - (String) Access token of the Telegraph account.
* `path` - (String) Path to the page.
* `title` - (String, 1-256 characters) Page title.
* `content` - (Array of Node, up to 64 KB) Content of the page.
* `options` - orddict of options
Options:
* `:author_name` - (String, 0-128 characters) Author name, displayed below the article's title.
* `:author_url` - (String, 0-512 characters) Profile link, opened when users click on the author's * `:name below` - the title. Can be any link, not necessarily to a Telegram profile or channel.
* `:return_content` - (Boolean, default = false) If true, a content field will be returned in the Page object.
"""
@spec edit_page(atom, binary, binary, binary, binary, [{atom, any}]) ::
{:ok, Page.t()} | {:error, Error.t()}
def edit_page(bot, access_token, path, title, content, options \\ []) do
request(
bot,
"editPage/" <> path,
[access_token: access_token, title: title, content: content] ++ options
)
end
@doc """
Use this method to get a Telegraph page. Returns a Page object on success.
Args:
* `bot` - Bot name
* `path` path to the Telegraph page (in the format Title-12-31, i.e. everything that comes after http://telegra.ph/)
* `return_content` - if true, content field will be returned in Page object
"""
@spec get_page(atom, binary, [atom]) :: {:ok, Page.t()} | {:error, Error.t()}
def get_page(bot, path, return_content \\ true) do
request(bot, "getPage/" <> path, return_content: return_content)
end
@doc """
Use this method to get the number of views for a Telegraph article. Returns a PageViews object on success. By default, the total number of page views will be returned.
Args:
* `bot` - Bot name
* `path` - path to the Telegraph page (in the format Title-12-31, where 12 is the month and 31 the day the article was first published)
* `filter_fields` - orddict of fields
Filter fields:
* `:year` - if passed, the number of page views for the requested year will be returned.
* `:month` - if passed, the number of page views for the requested month will be returned
* `:day` - if passed, the number of page views for the requested day will be returned.
* `:hour` - if passed, the number of page views for the requested hour will be returned.
"""
@spec get_views(atom, binary, [{atom, any}]) :: {:ok, PageViews.t()} | {:error, Error.t()}
def get_views(bot, path, filter_fields) do
request(bot, "getViews/" <> path, filter_fields)
end
end
| 49.864198 | 329 | 0.693241 |
ff8a9af3d4b84ee9fad278ca10d7e7dc6b1e06c0 | 1,348 | ex | Elixir | lib/jisho_elixir/v1/url.ex | szTheory/jisho_elixir | 14124626af134aa54a6ad36c074071dab84b625e | [
"MIT"
] | 20 | 2017-08-31T17:18:46.000Z | 2021-07-12T12:58:15.000Z | lib/jisho_elixir/v1/url.ex | szTheory/jisho_elixir | 14124626af134aa54a6ad36c074071dab84b625e | [
"MIT"
] | 1 | 2020-03-08T14:05:35.000Z | 2020-03-08T14:05:35.000Z | lib/jisho_elixir/v1/url.ex | szTheory/jisho_elixir | 14124626af134aa54a6ad36c074071dab84b625e | [
"MIT"
] | 3 | 2018-05-19T15:11:53.000Z | 2020-03-03T14:53:10.000Z | defmodule JishoElixir.V1.URL do
@moduledoc false
# Handles building the API request URL, Jisho V1
@base "http://jisho.org/api/v1/search/"
@doc """
Build URL for searching a word.
## Examples
iex> JishoElixir.V1.URL.search_word(["eat","#verb"])
"http://jisho.org/api/v1/search/words?keyword=eat+%23verb"
"""
def search_word(items) do
"#{@base}words?keyword=#{uri_encode(items)}"
end
@doc """
Build URL for searching a word and page number.
## Examples
iex> JishoElixir.V1.URL.search_word_with_page(["eat","#verb"], 2)
"http://jisho.org/api/v1/search/words?keyword=eat+%23verb&page=2"
"""
def search_word_with_page(items, page) do
search_word(items)
|> append_page(page)
end
@doc """
Encode single item.
## Examples
iex> JishoElixir.V1.URL.uri_encode("%term")
"%23term"
"""
def uri_encode(item) when is_binary(item) do
URI.encode_www_form(item)
end
@doc """
Encode list of items after inserting a space between.
## Examples
iex> JishoElixir.V1.URL.uri_encode(["term","#tag","#tag2"])
"term+%23tag+%23tag2"
"""
def uri_encode(items) when is_list(items) do
Enum.join(items, " ")
|> URI.encode_www_form
end
# Add page param to url string.
defp append_page(url, page) when is_integer(page) do
"#{url}&page=#{page}"
end
end
| 20.119403 | 67 | 0.654303 |
ff8ac4e9f927e2fef21841d14f85050a72d7610c | 2,053 | ex | Elixir | lib/vintage_net/to_elixir/server.ex | takasehideki/vintage_net | 40678fc9d74df5ff9f9f36c6378b62e981ceaf31 | [
"Apache-2.0"
] | null | null | null | lib/vintage_net/to_elixir/server.ex | takasehideki/vintage_net | 40678fc9d74df5ff9f9f36c6378b62e981ceaf31 | [
"Apache-2.0"
] | null | null | null | lib/vintage_net/to_elixir/server.ex | takasehideki/vintage_net | 40678fc9d74df5ff9f9f36c6378b62e981ceaf31 | [
"Apache-2.0"
] | null | null | null | defmodule VintageNet.ToElixir.Server do
use GenServer
require Logger
alias VintageNet.ToElixir.{UdhcpcHandler, UdhcpdHandler}
@moduledoc """
This GenServer routes messages from C and shell scripts to the appropriate
places in VintageNet.
"""
@doc """
Start the GenServer.
"""
@spec start_link(Path.t()) :: GenServer.on_start()
def start_link(path) do
GenServer.start_link(__MODULE__, path, name: __MODULE__)
end
@impl true
def init(path) do
# Blindly try to remove an old file just in case it exists from a previous run
_ = File.rm(path)
_ = File.mkdir_p(Path.dirname(path))
{:ok, socket} = :gen_udp.open(0, [:local, :binary, {:active, true}, {:ip, {:local, path}}])
state = %{path: path, socket: socket}
{:ok, state}
end
@impl true
def handle_info({:udp, socket, _, 0, data}, %{socket: socket} = state) do
data
|> :erlang.binary_to_term()
|> normalize_argv0()
|> dispatch()
{:noreply, state}
end
@impl true
def terminate(_reason, state) do
# Try to clean up
_ = File.rm(state.path)
end
defp normalize_argv0({[argv0 | args], env}) do
{[Path.basename(argv0) | args], env}
end
defp dispatch({["udhcpc_handler", command], %{interface: interface} = env}) do
UdhcpcHandler.dispatch(udhcpc_command(command), interface, env)
:ok
end
defp dispatch({["udhcpd_handler", lease_file], _env}) do
[_, interface, "leases"] = String.split(lease_file, ".")
UdhcpdHandler.dispatch(:lease_update, interface, lease_file)
end
defp dispatch({["to_elixir" | args], _env}) do
message = Enum.join(args, " ")
Logger.debug("Got a generic message: #{message}")
:ok
end
defp dispatch(unknown) do
Logger.error("to_elixir: dropping unknown report '#{inspect(unknown)}''")
:ok
end
defp udhcpc_command("deconfig"), do: :deconfig
defp udhcpc_command("leasefail"), do: :leasefail
defp udhcpc_command("nak"), do: :nak
defp udhcpc_command("renew"), do: :renew
defp udhcpc_command("bound"), do: :bound
end
| 25.987342 | 95 | 0.661471 |
ff8b3641939aaae6b39c3f4fd9bc85713540eeba | 842 | ex | Elixir | apps/astarte_pairing_api/lib/astarte_pairing_api_web/plug/log_hwid.ex | matt-mazzucato/astarte | 34d84941a5019efc42321052f7f34b7d907a38f2 | [
"Apache-2.0"
] | 191 | 2018-03-30T13:23:08.000Z | 2022-03-02T12:05:32.000Z | apps/astarte_pairing_api/lib/astarte_pairing_api_web/plug/log_hwid.ex | matt-mazzucato/astarte | 34d84941a5019efc42321052f7f34b7d907a38f2 | [
"Apache-2.0"
] | 402 | 2018-03-30T13:37:00.000Z | 2022-03-31T16:47:10.000Z | apps/astarte_pairing_api/lib/astarte_pairing_api_web/plug/log_hwid.ex | matt-mazzucato/astarte | 34d84941a5019efc42321052f7f34b7d907a38f2 | [
"Apache-2.0"
] | 24 | 2018-03-30T13:29:48.000Z | 2022-02-28T11:10:26.000Z | #
# This file is part of Astarte.
#
# Copyright 2019 Ispirata Srl
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
defmodule Astarte.Pairing.APIWeb.Plug.LogHwId do
def init(opts) do
opts
end
def call(conn, _opts) do
with %{"hw_id" => hw_id} <- conn.path_params do
Logger.metadata(hw_id: hw_id)
end
conn
end
end
| 26.3125 | 74 | 0.725653 |
ff8b410cf2f57a06792d3cec3ced36a700b11dac | 57 | ex | Elixir | lib/fish_web/views/layout_view.ex | wdiechmann/fish | b63fe109bbfc1cbe515ac31f9adcd9b57c6b21c8 | [
"MIT"
] | 1 | 2021-02-09T23:49:40.000Z | 2021-02-09T23:49:40.000Z | lib/fish_web/views/layout_view.ex | wdiechmann/fish | b63fe109bbfc1cbe515ac31f9adcd9b57c6b21c8 | [
"MIT"
] | null | null | null | lib/fish_web/views/layout_view.ex | wdiechmann/fish | b63fe109bbfc1cbe515ac31f9adcd9b57c6b21c8 | [
"MIT"
] | null | null | null | defmodule FishWeb.LayoutView do
use FishWeb, :view
end
| 14.25 | 31 | 0.789474 |
ff8b77ba71b9e347000c080cb037c13a5b3a5021 | 34,493 | ex | Elixir | lib/ecto/type.ex | Anber/ecto | 2b903c8c6acb924f87746fe4d40cb4b42a7f0491 | [
"Apache-2.0"
] | null | null | null | lib/ecto/type.ex | Anber/ecto | 2b903c8c6acb924f87746fe4d40cb4b42a7f0491 | [
"Apache-2.0"
] | null | null | null | lib/ecto/type.ex | Anber/ecto | 2b903c8c6acb924f87746fe4d40cb4b42a7f0491 | [
"Apache-2.0"
] | null | null | null | defmodule Ecto.Type do
@moduledoc """
Defines functions and the `Ecto.Type` behaviour for implementing
custom types.
A custom type expects 4 functions to be implemented, all documented
and described below. We also provide two examples of how custom
types can be used in Ecto to augment existing types or providing
your own types.
Note: `nil` values are always bypassed and cannot be handled by
custom types.
## Example
Imagine you want to store an URI struct as part of a schema in an
url-shortening service. There isn't an Ecto field type to support
that value at runtime, therefore a custom one is needed.
You also want to query not only by the full url, but for example
by specific ports used. This is possible by putting the URI data
into a map field instead of just storing the plain
string representation.
from s in ShortUrl,
where: fragment("?->>? ILIKE ?", s.original_url, "port", "443")
So the custom type does need to handle the conversion from
external data to runtime data (`c:cast/1`) as well as
transforming that runtime data into the `:map` Ecto native type and
back (`c:dump/1` and `c:load/1`).
defmodule EctoURI do
@behaviour Ecto.Type
def type, do: :map
# Provide custom casting rules.
# Cast strings into the URI struct to be used at runtime
def cast(uri) when is_binary(uri) do
{:ok, URI.parse(uri)}
end
# Accept casting of URI structs as well
def cast(%URI{} = uri), do: {:ok, uri}
# Everything else is a failure though
def cast(_), do: :error
# When loading data from the database, we are guaranteed to
# receive a map (as databases are strict) and we will
# just put the data back into an URI struct to be stored
# in the loaded schema struct.
def load(data) when is_map(data) do
data =
for {key, val} <- data do
{String.to_existing_atom(key), val}
end
{:ok, struct!(URI, data)}
end
# When dumping data to the database, we *expect* an URI struct
# but any value could be inserted into the schema struct at runtime,
# so we need to guard against them.
def dump(%URI{} = uri), do: {:ok, Map.from_struct(uri)}
def dump(_), do: :error
end
Now we can use our new field type above in our schemas:
defmodule ShortUrl do
use Ecto.Schema
schema "posts" do
field :original_url, EctoURI
end
end
"""
import Kernel, except: [match?: 2]
@typedoc "An Ecto type, primitive or custom."
@type t :: primitive | custom
@typedoc "Primitive Ecto types (handled by Ecto)."
@type primitive :: base | composite
@typedoc "Custom types are represented by user-defined modules."
@type custom :: module
@typep base :: :integer | :float | :boolean | :string | :map |
:binary | :decimal | :id | :binary_id |
:utc_datetime | :naive_datetime | :date | :time | :any |
:utc_datetime_usec | :naive_datetime_usec | :time_usec
@typep composite :: {:array, t} | {:map, t} | {:embed, Ecto.Embedded.t} | {:in, t}
@base ~w(
integer float decimal boolean string map binary id binary_id any
utc_datetime naive_datetime date time
utc_datetime_usec naive_datetime_usec time_usec
)a
@composite ~w(array map in embed)a
@doc """
Returns the underlying schema type for the custom type.
For example, if you want to provide your own date
structures, the type function should return `:date`.
Note this function is not required to return Ecto primitive
types, the type is only required to be known by the adapter.
"""
@callback type :: t
@doc """
Casts the given input to the custom type.
This callback is called on external input and can return any type,
as long as the `dump/1` function is able to convert the returned
value into an Ecto native type. There are two situations where
this callback is called:
1. When casting values by `Ecto.Changeset`
2. When passing arguments to `Ecto.Query`
"""
@callback cast(term) :: {:ok, term} | :error
@doc """
Loads the given term into a custom type.
This callback is called when loading data from the database and
receive an Ecto native type. It can return any type, as long as
the `dump/1` function is able to convert the returned value back
into an Ecto native type.
"""
@callback load(term) :: {:ok, term} | :error
@doc """
Dumps the given term into an Ecto native type.
This callback is called with any term that was stored in the struct
and it needs to validate them and convert it to an Ecto native type.
"""
@callback dump(term) :: {:ok, term} | :error
@doc """
Checks if two terms are semantically equal.
"""
@callback equal?(term, term) :: boolean
@optional_callbacks [equal?: 2]
## Functions
@doc """
Checks if we have a primitive type.
iex> primitive?(:string)
true
iex> primitive?(Another)
false
iex> primitive?({:array, :string})
true
iex> primitive?({:array, Another})
true
"""
@spec primitive?(t) :: boolean
def primitive?({composite, _}) when composite in @composite, do: true
def primitive?(base) when base in @base, do: true
def primitive?(_), do: false
@doc """
Checks if the given atom can be used as composite type.
iex> composite?(:array)
true
iex> composite?(:string)
false
"""
@spec composite?(atom) :: boolean
def composite?(atom), do: atom in @composite
@doc """
Checks if the given atom can be used as base type.
iex> base?(:string)
true
iex> base?(:array)
false
iex> base?(Custom)
false
"""
@spec base?(atom) :: boolean
def base?(atom), do: atom in @base
@doc """
Retrieves the underlying schema type for the given, possibly custom, type.
iex> type(:string)
:string
iex> type(Ecto.UUID)
:uuid
iex> type({:array, :string})
{:array, :string}
iex> type({:array, Ecto.UUID})
{:array, :uuid}
iex> type({:map, Ecto.UUID})
{:map, :uuid}
"""
@spec type(t) :: t
def type(type)
def type({:array, type}), do: {:array, type(type)}
def type({:map, type}), do: {:map, type(type)}
def type(type) do
if primitive?(type) do
type
else
type.type
end
end
@doc """
Checks if a given type matches with a primitive type
that can be found in queries.
iex> match?(:string, :any)
true
iex> match?(:any, :string)
true
iex> match?(:string, :string)
true
iex> match?({:array, :string}, {:array, :any})
true
iex> match?(Ecto.UUID, :uuid)
true
iex> match?(Ecto.UUID, :string)
false
"""
@spec match?(t, primitive) :: boolean
def match?(schema_type, query_type) do
if primitive?(schema_type) do
do_match?(schema_type, query_type)
else
do_match?(schema_type.type, query_type)
end
end
defp do_match?(_left, :any), do: true
defp do_match?(:any, _right), do: true
defp do_match?({outer, left}, {outer, right}), do: match?(left, right)
defp do_match?({:array, :any}, {:embed, %{cardinality: :many}}), do: true
defp do_match?(:decimal, type) when type in [:float, :integer], do: true
defp do_match?(:binary_id, :binary), do: true
defp do_match?(:id, :integer), do: true
defp do_match?(type, type), do: true
defp do_match?(_, _), do: false
@doc """
Dumps a value to the given type.
Opposite to casting, dumping requires the returned value
to be a valid Ecto type, as it will be sent to the
underlying data store.
iex> dump(:string, nil)
{:ok, nil}
iex> dump(:string, "foo")
{:ok, "foo"}
iex> dump(:integer, 1)
{:ok, 1}
iex> dump(:integer, "10")
:error
iex> dump(:binary, "foo")
{:ok, "foo"}
iex> dump(:binary, 1)
:error
iex> dump({:array, :integer}, [1, 2, 3])
{:ok, [1, 2, 3]}
iex> dump({:array, :integer}, [1, "2", 3])
:error
iex> dump({:array, :binary}, ["1", "2", "3"])
{:ok, ["1", "2", "3"]}
"""
@spec dump(t, term) :: {:ok, term} | :error
def dump(_type, nil) do
{:ok, nil}
end
def dump(type, value) do
dump_fun(type).(value)
end
@doc """
Dumps a value to the given type.
This function behaves the same as `dump/2`, except for composite types
the given `dumper` function is used.
"""
@spec dump(t, term, (t, term -> {:ok, term} | :error)) :: {:ok, term} | :error
def dump(_type, nil, _dumper) do
{:ok, nil}
end
def dump({:embed, embed}, value, dumper) do
dump_embed(embed, value, dumper)
end
def dump({:in, type}, value, dumper) do
case dump({:array, type}, value, dumper) do
{:ok, value} -> {:ok, {:in, value}}
:error -> :error
end
end
def dump({:map, type}, value, dumper) when is_map(value) do
map(Map.to_list(value), type, dumper, %{})
end
def dump({:array, type}, value, dumper) do
array(value, type, dumper, [])
end
def dump(type, value, _) do
dump_fun(type).(value)
end
defp dump_fun(:integer), do: &dump_integer/1
defp dump_fun(:float), do: &dump_float/1
defp dump_fun(:boolean), do: &dump_boolean/1
defp dump_fun(:map), do: &dump_map/1
defp dump_fun(:string), do: &dump_binary/1
defp dump_fun(:binary), do: &dump_binary/1
defp dump_fun(:id), do: &dump_integer/1
defp dump_fun(:binary_id), do: &dump_binary/1
defp dump_fun(:any), do: &{:ok, &1}
defp dump_fun(:decimal), do: &dump_decimal/1
defp dump_fun(:date), do: &dump_date/1
defp dump_fun(:time), do: &dump_time/1
defp dump_fun(:time_usec), do: &dump_time_usec/1
defp dump_fun(:naive_datetime), do: &dump_naive_datetime/1
defp dump_fun(:naive_datetime_usec), do: &dump_naive_datetime_usec/1
defp dump_fun(:utc_datetime), do: &dump_utc_datetime/1
defp dump_fun(:utc_datetime_usec), do: &dump_utc_datetime_usec/1
defp dump_fun({:array, type}), do: &array(&1, dump_fun(type), [])
defp dump_fun({:map, type}), do: &map(&1, dump_fun(type), %{})
defp dump_fun(mod) when is_atom(mod), do: &mod.dump(&1)
defp dump_integer(term) when is_integer(term), do: {:ok, term}
defp dump_integer(_), do: :error
defp dump_float(term) when is_float(term), do: {:ok, term}
defp dump_float(_), do: :error
defp dump_boolean(term) when is_boolean(term), do: {:ok, term}
defp dump_boolean(_), do: :error
defp dump_binary(term) when is_binary(term), do: {:ok, term}
defp dump_binary(_), do: :error
defp dump_map(term) when is_map(term), do: {:ok, term}
defp dump_map(_), do: :error
defp dump_decimal(term) when is_integer(term), do: {:ok, Decimal.new(term)}
defp dump_decimal(term) when is_float(term), do: {:ok, Decimal.from_float(term)}
defp dump_decimal(%Decimal{coef: coef}) when coef in [:inf, :qNaN, :sNaN], do: :error
defp dump_decimal(%Decimal{} = term), do: {:ok, term}
defp dump_decimal(_), do: :error
defp dump_date(%Date{} = term), do: {:ok, term}
defp dump_date(_), do: :error
defp dump_time(%Time{microsecond: {0, 0}} = term), do: {:ok, term}
defp dump_time(_), do: :error
defp dump_time_usec(%Time{microsecond: {_, 6}} = term), do: {:ok, term}
defp dump_time_usec(_), do: :error
defp dump_naive_datetime(%NaiveDateTime{microsecond: {0, 0}} = term), do: {:ok, term}
defp dump_naive_datetime(_), do: :error
defp dump_naive_datetime_usec(%NaiveDateTime{microsecond: {_, 6}} = term), do: {:ok, term}
defp dump_naive_datetime_usec(_), do: :error
defp dump_utc_datetime(%DateTime{time_zone: time_zone, microsecond: {0, 0}} = term) do
if time_zone != "Etc/UTC" do
message = ":utc_datetime expects the time zone to be \"Etc/UTC\", got `#{inspect(term)}`"
raise ArgumentError, message
end
{:ok, DateTime.to_naive(term)}
end
defp dump_utc_datetime(_), do: :error
defp dump_utc_datetime_usec(%DateTime{time_zone: time_zone, microsecond: {_, 6}} = datetime) do
if time_zone != "Etc/UTC" do
message = ":utc_datetime_usec expects the time zone to be \"Etc/UTC\", got `#{inspect(datetime)}`"
raise ArgumentError, message
end
{:ok, DateTime.to_naive(datetime)}
end
defp dump_utc_datetime_usec(_), do: :error
defp dump_embed(%{cardinality: :one, related: schema, field: field},
value, fun) when is_map(value) do
{:ok, dump_embed(field, schema, value, schema.__schema__(:dump), fun)}
end
defp dump_embed(%{cardinality: :many, related: schema, field: field},
value, fun) when is_list(value) do
types = schema.__schema__(:dump)
{:ok, Enum.map(value, &dump_embed(field, schema, &1, types, fun))}
end
defp dump_embed(_embed, _value, _fun) do
:error
end
defp dump_embed(_field, schema, %{__struct__: schema} = struct, types, dumper) do
Enum.reduce(types, %{}, fn {field, {source, type}}, acc ->
value = Map.get(struct, field)
case dumper.(type, value) do
{:ok, value} ->
Map.put(acc, source, value)
:error ->
raise ArgumentError, "cannot dump `#{inspect value}` as type #{inspect type} " <>
"for field `#{field}` in schema #{inspect schema}"
end
end)
end
defp dump_embed(field, _schema, value, _types, _fun) do
raise ArgumentError, "cannot dump embed `#{field}`, invalid value: #{inspect value}"
end
@doc """
Loads a value with the given type.
iex> load(:string, nil)
{:ok, nil}
iex> load(:string, "foo")
{:ok, "foo"}
iex> load(:integer, 1)
{:ok, 1}
iex> load(:integer, "10")
:error
"""
@spec load(t, term) :: {:ok, term} | :error
def load({:embed, embed}, value) do
load_embed(embed, value, &load/2)
end
def load(_type, nil) do
{:ok, nil}
end
def load(type, value) do
load_fun(type).(value)
end
@doc """
Loads a value with the given type.
This function behaves the same as `load/2`, except for composite types
the given `loader` function is used.
"""
@spec load(t, term, (t, term -> {:ok, term} | :error)) :: {:ok, term} | :error
def load({:embed, embed}, value, loader) do
load_embed(embed, value, loader)
end
def load(_type, nil, _loader) do
{:ok, nil}
end
def load(type, value, _loader) do
load_fun(type).(value)
end
defp load_fun(:integer), do: &dump_integer/1
defp load_fun(:float), do: &load_float/1
defp load_fun(:boolean), do: &dump_boolean/1
defp load_fun(:map), do: &dump_map/1
defp load_fun(:string), do: &dump_binary/1
defp load_fun(:binary), do: &dump_binary/1
defp load_fun(:id), do: &dump_integer/1
defp load_fun(:binary_id), do: &dump_binary/1
defp load_fun(:any), do: &{:ok, &1}
defp load_fun(:decimal), do: &dump_decimal/1
defp load_fun(:date), do: &dump_date/1
defp load_fun(:time), do: &load_time/1
defp load_fun(:time_usec), do: &load_time_usec/1
defp load_fun(:naive_datetime), do: &load_naive_datetime/1
defp load_fun(:naive_datetime_usec), do: &load_naive_datetime_usec/1
defp load_fun(:utc_datetime), do: &load_utc_datetime/1
defp load_fun(:utc_datetime_usec), do: &load_utc_datetime_usec/1
defp load_fun({:array, type}), do: &array(&1, load_fun(type), [])
defp load_fun({:map, type}), do: &map(&1, load_fun(type), %{})
defp load_fun(mod) when is_atom(mod), do: &mod.load(&1)
defp load_float(term) when is_float(term), do: {:ok, term}
defp load_float(term) when is_integer(term), do: {:ok, :erlang.float(term)}
defp load_float(_), do: :error
defp load_time(%Time{} = time), do: {:ok, truncate_usec(time)}
defp load_time(_), do: :error
defp load_time_usec(%Time{} = time), do: {:ok, pad_usec(time)}
defp load_time_usec(_), do: :error
defp load_naive_datetime(%NaiveDateTime{} = naive_datetime), do: {:ok, truncate_usec(naive_datetime)}
defp load_naive_datetime(_), do: :error
defp load_naive_datetime_usec(%NaiveDateTime{} = naive_datetime), do: {:ok, pad_usec(naive_datetime)}
defp load_naive_datetime_usec(_), do: :error
defp load_utc_datetime(%DateTime{} = datetime),
do: {:ok, truncate_usec(datetime)}
defp load_utc_datetime(%NaiveDateTime{} = naive_datetime),
do: naive_datetime |> truncate_usec() |> DateTime.from_naive("Etc/UTC")
defp load_utc_datetime(_),
do: :error
defp load_utc_datetime_usec(%DateTime{} = datetime),
do: {:ok, pad_usec(datetime)}
defp load_utc_datetime_usec(%NaiveDateTime{} = naive_datetime),
do: naive_datetime |> pad_usec() |> DateTime.from_naive("Etc/UTC")
defp load_utc_datetime_usec(_),
do: :error
defp load_embed(%{cardinality: :one}, nil, _fun), do: {:ok, nil}
defp load_embed(%{cardinality: :one, related: schema, field: field},
value, fun) when is_map(value) do
{:ok, load_embed(field, schema, value, fun)}
end
defp load_embed(%{cardinality: :many}, nil, _fun), do: {:ok, []}
defp load_embed(%{cardinality: :many, related: schema, field: field},
value, fun) when is_list(value) do
{:ok, Enum.map(value, &load_embed(field, schema, &1, fun))}
end
defp load_embed(_embed, _value, _fun) do
:error
end
defp load_embed(_field, schema, value, loader) when is_map(value) do
Ecto.Schema.Loader.unsafe_load(schema, value, loader)
end
defp load_embed(field, _schema, value, _fun) do
raise ArgumentError, "cannot load embed `#{field}`, invalid value: #{inspect value}"
end
@doc """
Casts a value to the given type.
`cast/2` is used by the finder queries and changesets to cast outside values to
specific types.
Note that nil can be cast to all primitive types as data stores allow nil to be
set on any column.
NaN and infinite decimals are not supported, use custom types instead.
iex> cast(:any, "whatever")
{:ok, "whatever"}
iex> cast(:any, nil)
{:ok, nil}
iex> cast(:string, nil)
{:ok, nil}
iex> cast(:integer, 1)
{:ok, 1}
iex> cast(:integer, "1")
{:ok, 1}
iex> cast(:integer, "1.0")
:error
iex> cast(:id, 1)
{:ok, 1}
iex> cast(:id, "1")
{:ok, 1}
iex> cast(:id, "1.0")
:error
iex> cast(:float, 1.0)
{:ok, 1.0}
iex> cast(:float, 1)
{:ok, 1.0}
iex> cast(:float, "1")
{:ok, 1.0}
iex> cast(:float, "1.0")
{:ok, 1.0}
iex> cast(:float, "1-foo")
:error
iex> cast(:boolean, true)
{:ok, true}
iex> cast(:boolean, false)
{:ok, false}
iex> cast(:boolean, "1")
{:ok, true}
iex> cast(:boolean, "0")
{:ok, false}
iex> cast(:boolean, "whatever")
:error
iex> cast(:string, "beef")
{:ok, "beef"}
iex> cast(:binary, "beef")
{:ok, "beef"}
iex> cast(:decimal, Decimal.new("1.0"))
{:ok, Decimal.new("1.0")}
iex> cast({:array, :integer}, [1, 2, 3])
{:ok, [1, 2, 3]}
iex> cast({:array, :integer}, ["1", "2", "3"])
{:ok, [1, 2, 3]}
iex> cast({:array, :string}, [1, 2, 3])
:error
iex> cast(:string, [1, 2, 3])
:error
"""
@spec cast(t, term) :: {:ok, term} | :error
def cast({:embed, type}, value), do: cast_embed(type, value)
def cast({:in, _type}, nil), do: :error
def cast(_type, nil), do: {:ok, nil}
def cast(type, value) do
cast_fun(type).(value)
end
defp cast_fun(:integer), do: &cast_integer/1
defp cast_fun(:float), do: &cast_float/1
defp cast_fun(:boolean), do: &cast_boolean/1
defp cast_fun(:map), do: &cast_map/1
defp cast_fun(:string), do: &cast_binary/1
defp cast_fun(:binary), do: &cast_binary/1
defp cast_fun(:id), do: &cast_integer/1
defp cast_fun(:binary_id), do: &cast_binary/1
defp cast_fun(:any), do: &{:ok, &1}
defp cast_fun(:decimal), do: &cast_decimal/1
defp cast_fun(:date), do: &cast_date/1
defp cast_fun(:time), do: &maybe_truncate_usec(cast_time(&1))
defp cast_fun(:time_usec), do: &maybe_pad_usec(cast_time(&1))
defp cast_fun(:naive_datetime), do: &maybe_truncate_usec(cast_naive_datetime(&1))
defp cast_fun(:naive_datetime_usec), do: &maybe_pad_usec(cast_naive_datetime(&1))
defp cast_fun(:utc_datetime), do: &maybe_truncate_usec(cast_utc_datetime(&1))
defp cast_fun(:utc_datetime_usec), do: &maybe_pad_usec(cast_utc_datetime(&1))
defp cast_fun({:in, type}), do: &array(&1, cast_fun(type), [])
defp cast_fun({:array, type}), do: &array(&1, cast_fun(type), [])
defp cast_fun({:map, type}), do: &map(&1, cast_fun(type), %{})
defp cast_fun(mod) when is_atom(mod), do: &mod.cast(&1)
defp cast_integer(term) when is_binary(term) do
case Integer.parse(term) do
{integer, ""} -> {:ok, integer}
_ -> :error
end
end
defp cast_integer(term) when is_integer(term), do: {:ok, term}
defp cast_integer(_), do: :error
defp cast_float(term) when is_binary(term) do
case Float.parse(term) do
{float, ""} -> {:ok, float}
_ -> :error
end
end
defp cast_float(term) when is_float(term), do: {:ok, term}
defp cast_float(term) when is_integer(term), do: {:ok, :erlang.float(term)}
defp cast_float(_), do: :error
defp cast_boolean(term) when term in ~w(true 1), do: {:ok, true}
defp cast_boolean(term) when term in ~w(false 0), do: {:ok, false}
defp cast_boolean(term) when is_boolean(term), do: {:ok, term}
defp cast_boolean(_), do: :error
defp cast_binary(term) when is_binary(term), do: {:ok, term}
defp cast_binary(_), do: :error
defp cast_map(term) when is_map(term), do: {:ok, term}
defp cast_map(_), do: :error
def cast_decimal(term) when is_binary(term) do
case Decimal.parse(term) do
{:ok, decimal} -> dump_decimal(decimal)
:error -> :error
end
end
def cast_decimal(term) do
dump_decimal(term)
end
defp cast_embed(%{cardinality: :one}, nil), do: {:ok, nil}
defp cast_embed(%{cardinality: :one, related: schema}, %{__struct__: schema} = struct) do
{:ok, struct}
end
defp cast_embed(%{cardinality: :many}, nil), do: {:ok, []}
defp cast_embed(%{cardinality: :many, related: schema}, value) when is_list(value) do
if Enum.all?(value, &Kernel.match?(%{__struct__: ^schema}, &1)) do
{:ok, value}
else
:error
end
end
defp cast_embed(_embed, _value) do
:error
end
## Adapter related
@doc false
def adapter_autogenerate(adapter, type) do
type
|> type()
|> adapter.autogenerate()
end
def adapter_load(_adapter, {:embed, embed}, nil) do
load_embed(embed, nil, &load/2)
end
def adapter_load(_adapter, _type, nil) do
{:ok, nil}
end
def adapter_load(adapter, type, value) do
if of_base_type?(type, value) do
{:ok, value}
else
process_loaders(adapter.loaders(type(type), type), {:ok, value}, adapter)
end
end
defp process_loaders(_, :error, _adapter),
do: :error
defp process_loaders([fun|t], {:ok, value}, adapter) when is_function(fun),
do: process_loaders(t, fun.(value), adapter)
defp process_loaders([type|t], {:ok, value}, adapter),
do: process_loaders(t, load(type, value, &adapter_load(adapter, &1, &2)), adapter)
defp process_loaders([], {:ok, _} = acc, _adapter),
do: acc
@doc false
def adapter_dump(_adapter, type, nil),
do: dump(type, nil)
def adapter_dump(adapter, type, value),
do: process_dumpers(adapter.dumpers(type(type), type), {:ok, value}, adapter)
defp process_dumpers(_, :error, _adapter),
do: :error
defp process_dumpers([fun|t], {:ok, value}, adapter) when is_function(fun),
do: process_dumpers(t, fun.(value), adapter)
defp process_dumpers([type|t], {:ok, value}, adapter),
do: process_dumpers(t, dump(type, value, &adapter_dump(adapter, &1, &2)), adapter)
defp process_dumpers([], {:ok, _} = acc, _adapter),
do: acc
## Date
defp cast_date(binary) when is_binary(binary) do
case Date.from_iso8601(binary) do
{:ok, _} = ok ->
ok
{:error, _} ->
case NaiveDateTime.from_iso8601(binary) do
{:ok, naive_datetime} -> {:ok, NaiveDateTime.to_date(naive_datetime)}
{:error, _} -> :error
end
end
end
defp cast_date(%{"year" => empty, "month" => empty, "day" => empty}) when empty in ["", nil],
do: {:ok, nil}
defp cast_date(%{year: empty, month: empty, day: empty}) when empty in ["", nil],
do: {:ok, nil}
defp cast_date(%{"year" => year, "month" => month, "day" => day}),
do: cast_date(to_i(year), to_i(month), to_i(day))
defp cast_date(%{year: year, month: month, day: day}),
do: cast_date(to_i(year), to_i(month), to_i(day))
defp cast_date(_),
do: :error
defp cast_date(year, month, day) when is_integer(year) and is_integer(month) and is_integer(day) do
case Date.new(year, month, day) do
{:ok, _} = ok -> ok
{:error, _} -> :error
end
end
defp cast_date(_, _, _),
do: :error
## Time
defp cast_time(<<hour::2-bytes, ?:, minute::2-bytes>>),
do: cast_time(to_i(hour), to_i(minute), 0, nil)
defp cast_time(binary) when is_binary(binary) do
case Time.from_iso8601(binary) do
{:ok, _} = ok -> ok
{:error, _} -> :error
end
end
defp cast_time(%{"hour" => empty, "minute" => empty}) when empty in ["", nil],
do: {:ok, nil}
defp cast_time(%{hour: empty, minute: empty}) when empty in ["", nil],
do: {:ok, nil}
defp cast_time(%{"hour" => hour, "minute" => minute} = map),
do: cast_time(to_i(hour), to_i(minute), to_i(Map.get(map, "second")), to_i(Map.get(map, "microsecond")))
defp cast_time(%{hour: hour, minute: minute, second: second, microsecond: {microsecond, precision}}),
do: cast_time(to_i(hour), to_i(minute), to_i(second), {to_i(microsecond), to_i(precision)})
defp cast_time(%{hour: hour, minute: minute} = map),
do: cast_time(to_i(hour), to_i(minute), to_i(Map.get(map, :second)), to_i(Map.get(map, :microsecond)))
defp cast_time(_),
do: :error
defp cast_time(hour, minute, sec, usec) when is_integer(usec) do
cast_time(hour, minute, sec, {usec, 6})
end
defp cast_time(hour, minute, sec, nil) do
cast_time(hour, minute, sec, {0, 0})
end
defp cast_time(hour, minute, sec, {usec, precision})
when is_integer(hour) and is_integer(minute) and
(is_integer(sec) or is_nil(sec)) and is_integer(usec) and is_integer(precision) do
case Time.new(hour, minute, sec || 0, {usec, precision}) do
{:ok, _} = ok -> ok
{:error, _} -> :error
end
end
defp cast_time(_, _, _, _) do
:error
end
## Naive datetime
defp cast_naive_datetime(binary) when is_binary(binary) do
case NaiveDateTime.from_iso8601(binary) do
{:ok, _} = ok -> ok
{:error, _} -> :error
end
end
defp cast_naive_datetime(%{"year" => empty, "month" => empty, "day" => empty,
"hour" => empty, "minute" => empty}) when empty in ["", nil],
do: {:ok, nil}
defp cast_naive_datetime(%{year: empty, month: empty, day: empty,
hour: empty, minute: empty}) when empty in ["", nil],
do: {:ok, nil}
defp cast_naive_datetime(%{} = map) do
with {:ok, date} <- cast_date(map),
{:ok, time} <- cast_time(map) do
case NaiveDateTime.new(date, time) do
{:ok, _} = ok -> ok
{:error, _} -> :error
end
end
end
defp cast_naive_datetime(_) do
:error
end
## UTC datetime
defp cast_utc_datetime(binary) when is_binary(binary) do
case DateTime.from_iso8601(binary) do
{:ok, datetime, _offset} -> {:ok, datetime}
{:error, :missing_offset} ->
case NaiveDateTime.from_iso8601(binary) do
{:ok, naive_datetime} -> {:ok, DateTime.from_naive!(naive_datetime, "Etc/UTC")}
{:error, _} -> :error
end
{:error, _} -> :error
end
end
defp cast_utc_datetime(%DateTime{time_zone: "Etc/UTC"} = datetime), do: {:ok, datetime}
defp cast_utc_datetime(%DateTime{} = datetime) do
case (datetime |> DateTime.to_unix() |> DateTime.from_unix()) do
{:ok, _} = ok -> ok
{:error, _} -> :error
end
end
defp cast_utc_datetime(value) do
case cast_naive_datetime(value) do
{:ok, %NaiveDateTime{} = naive_datetime} ->
{:ok, DateTime.from_naive!(naive_datetime, "Etc/UTC")}
{:ok, _} = ok ->
ok
:error ->
:error
end
end
@doc """
Checks if two terms are equal.
Depending on the given `type` performs a structural or semantical comparison.
## Examples
iex> equal?(:integer, 1, 1)
true
iex> equal?(:decimal, Decimal.new("1"), Decimal.new("1.00"))
true
"""
@spec equal?(t, term, term) :: boolean
def equal?(_, nil, nil), do: true
def equal?(type, term1, term2) do
if fun = equal_fun(type) do
fun.(term1, term2)
else
term1 == term2
end
end
defp equal_fun(nil), do: nil
defp equal_fun(:decimal), do: &equal_decimal?/2
defp equal_fun(t) when t in [:time, :time_usec], do: &equal_time?/2
defp equal_fun(t) when t in [:utc_datetime, :utc_datetime_usec], do: &equal_utc_datetime?/2
defp equal_fun(t) when t in [:naive_datetime, :naive_datetime_usec], do: &equal_naive_datetime?/2
defp equal_fun(t) when t in @base, do: nil
defp equal_fun({:array, type}) do
if fun = equal_fun(type) do
&equal_list?(fun, &1, &2)
end
end
defp equal_fun({:map, type}) do
if fun = equal_fun(type) do
&equal_map?(fun, &1, &2)
end
end
defp equal_fun(mod) when is_atom(mod) do
if loaded_and_exported?(mod, :equal?, 2) do
&mod.equal?/2
end
end
defp equal_decimal?(%Decimal{} = a, %Decimal{} = b), do: Decimal.equal?(a, b)
defp equal_decimal?(_, _), do: false
defp equal_time?(%Time{} = a, %Time{} = b), do: Time.compare(a, b) == :eq
defp equal_time?(_, _), do: false
defp equal_utc_datetime?(%DateTime{} = a, %DateTime{} = b), do: DateTime.compare(a, b) == :eq
defp equal_utc_datetime?(_, _), do: false
defp equal_naive_datetime?(%NaiveDateTime{} = a, %NaiveDateTime{} = b),
do: NaiveDateTime.compare(a, b) == :eq
defp equal_naive_datetime?(_, _),
do: false
defp equal_list?(fun, [nil | xs], [nil | ys]), do: equal_list?(fun, xs, ys)
defp equal_list?(fun, [x | xs], [y | ys]), do: fun.(x, y) and equal_list?(fun, xs, ys)
defp equal_list?(_fun, [], []), do: true
defp equal_list?(_fun, _, _), do: false
defp equal_map?(_fun, map1, map2) when map_size(map1) != map_size(map2) do
false
end
defp equal_map?(fun, %{} = map1, %{} = map2) do
equal_map?(fun, Map.to_list(map1), map2)
end
defp equal_map?(fun, [{key, nil} | tail], other_map) do
case other_map do
%{^key => nil} -> equal_map?(fun, tail, other_map)
_ -> false
end
end
defp equal_map?(fun, [{key, val} | tail], other_map) do
case other_map do
%{^key => other_val} -> fun.(val, other_val) and equal_map?(fun, tail, other_map)
_ -> false
end
end
defp equal_map?(_fun, [], _) do
true
end
defp equal_map?(_fun, _, _) do
false
end
## Helpers
# Checks if a value is of the given primitive type.
defp of_base_type?(:any, _), do: true
defp of_base_type?(:id, term), do: is_integer(term)
defp of_base_type?(:float, term), do: is_float(term)
defp of_base_type?(:integer, term), do: is_integer(term)
defp of_base_type?(:boolean, term), do: is_boolean(term)
defp of_base_type?(:binary, term), do: is_binary(term)
defp of_base_type?(:string, term), do: is_binary(term)
defp of_base_type?(:map, term), do: is_map(term) and not Map.has_key?(term, :__struct__)
defp of_base_type?(:decimal, value), do: Kernel.match?(%Decimal{}, value)
defp of_base_type?(:date, value), do: Kernel.match?(%Date{}, value)
defp of_base_type?(_, _), do: false
# nil always passes through
defp array([nil | t], fun, acc) do
array(t, fun, [nil | acc])
end
defp array([h | t], fun, acc) do
case fun.(h) do
{:ok, h} -> array(t, fun, [h | acc])
:error -> :error
end
end
defp array([], _fun, acc) do
{:ok, Enum.reverse(acc)}
end
defp array(_, _, _) do
:error
end
defp map(map, fun, acc) when is_map(map) do
map(Map.to_list(map), fun, acc)
end
# nil always passes through
defp map([{key, nil} | t], fun, acc) do
map(t, fun, Map.put(acc, key, nil))
end
defp map([{key, value} | t], fun, acc) do
case fun.(value) do
{:ok, value} -> map(t, fun, Map.put(acc, key, value))
:error -> :error
end
end
defp map([], _fun, acc) do
{:ok, acc}
end
defp map(_, _, _) do
:error
end
defp array([h | t], type, fun, acc) do
case fun.(type, h) do
{:ok, h} -> array(t, type, fun, [h | acc])
:error -> :error
end
end
defp array([], _type, _fun, acc) do
{:ok, Enum.reverse(acc)}
end
defp array(_, _, _, _) do
:error
end
defp map([{key, value} | t], type, fun, acc) do
case fun.(type, value) do
{:ok, value} -> map(t, type, fun, Map.put(acc, key, value))
:error -> :error
end
end
defp map([], _type, _fun, acc) do
{:ok, acc}
end
defp map(_, _, _, _) do
:error
end
defp to_i(nil), do: nil
defp to_i(int) when is_integer(int), do: int
defp to_i(bin) when is_binary(bin) do
case Integer.parse(bin) do
{int, ""} -> int
_ -> nil
end
end
defp loaded_and_exported?(module, fun, arity) do
# TODO: Rely only on Code.ensure_loaded? when targetting Erlang/OTP 21+
if :erlang.module_loaded(module) or Code.ensure_loaded?(module) do
function_exported?(module, fun, arity)
else
raise ArgumentError, "cannot use #{inspect(module)} as Ecto.Type, module is not available"
end
end
defp maybe_truncate_usec({:ok, struct}), do: {:ok, truncate_usec(struct)}
defp maybe_truncate_usec(:error), do: :error
defp maybe_pad_usec({:ok, struct}), do: {:ok, pad_usec(struct)}
defp maybe_pad_usec(:error), do: :error
defp truncate_usec(nil), do: nil
defp truncate_usec(%{microsecond: {0, 0}} = struct), do: struct
defp truncate_usec(struct), do: %{struct | microsecond: {0, 0}}
defp pad_usec(nil), do: nil
defp pad_usec(%{microsecond: {_, 6}} = struct), do: struct
defp pad_usec(%{microsecond: {microsecond, _}} = struct),
do: %{struct | microsecond: {microsecond, 6}}
end
| 30.310193 | 108 | 0.623953 |
ff8b846f4bd8c5baafd0cf70549432dfa4e825d1 | 3,057 | ex | Elixir | clients/ad_sense/lib/google_api/ad_sense/v14/model/adsense_reports_generate_response.ex | ericrwolfe/elixir-google-api | 3dc0f17edd5e2d6843580c16ddae3bf84b664ffd | [
"Apache-2.0"
] | null | null | null | clients/ad_sense/lib/google_api/ad_sense/v14/model/adsense_reports_generate_response.ex | ericrwolfe/elixir-google-api | 3dc0f17edd5e2d6843580c16ddae3bf84b664ffd | [
"Apache-2.0"
] | null | null | null | clients/ad_sense/lib/google_api/ad_sense/v14/model/adsense_reports_generate_response.ex | ericrwolfe/elixir-google-api | 3dc0f17edd5e2d6843580c16ddae3bf84b664ffd | [
"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.AdSense.V14.Model.AdsenseReportsGenerateResponse do
@moduledoc """
## Attributes
- averages (List[String]): The averages of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty. Defaults to: `null`.
- endDate (String): The requested end date in yyyy-mm-dd format. Defaults to: `null`.
- headers (List[AdsenseReportsGenerateResponseHeaders]): The header information of the columns requested in the report. This is a list of headers; one for each dimension in the request, followed by one for each metric in the request. Defaults to: `null`.
- kind (String): Kind this is, in this case adsense#report. Defaults to: `null`.
- rows (List[List[String]]): The output rows of the report. Each row is a list of cells; one for each dimension in the request, followed by one for each metric in the request. The dimension cells contain strings, and the metric cells contain numbers. Defaults to: `null`.
- startDate (String): The requested start date in yyyy-mm-dd format. Defaults to: `null`.
- totalMatchedRows (String): The total number of rows matched by the report request. Fewer rows may be returned in the response due to being limited by the row count requested or the report row limit. Defaults to: `null`.
- totals (List[String]): The totals of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty. Defaults to: `null`.
- warnings (List[String]): Any warnings associated with generation of the report. Defaults to: `null`.
"""
defstruct [
:averages,
:endDate,
:headers,
:kind,
:rows,
:startDate,
:totalMatchedRows,
:totals,
:warnings
]
end
defimpl Poison.Decoder, for: GoogleApi.AdSense.V14.Model.AdsenseReportsGenerateResponse do
import GoogleApi.AdSense.V14.Deserializer
def decode(value, options) do
value
|> deserialize(
:headers,
:list,
GoogleApi.AdSense.V14.Model.AdsenseReportsGenerateResponseHeaders,
options
)
end
end
defimpl Poison.Encoder, for: GoogleApi.AdSense.V14.Model.AdsenseReportsGenerateResponse do
def encode(value, options) do
GoogleApi.AdSense.V14.Deserializer.serialize_non_nil(value, options)
end
end
| 44.955882 | 273 | 0.745502 |
ff8ba8a0611d7f1afcacc4f55df1e256039dad8d | 1,227 | exs | Elixir | config/prod.secret.exs | mzgajner/smena | 6c0243ae1e8d1cef6e8a8e240f0f6b703ea638c9 | [
"Unlicense"
] | null | null | null | config/prod.secret.exs | mzgajner/smena | 6c0243ae1e8d1cef6e8a8e240f0f6b703ea638c9 | [
"Unlicense"
] | null | null | null | config/prod.secret.exs | mzgajner/smena | 6c0243ae1e8d1cef6e8a8e240f0f6b703ea638c9 | [
"Unlicense"
] | null | null | null | # In this file, we load production configuration and secrets
# from environment variables. You can also hardcode secrets,
# although such is generally not recommended and you have to
# remember to add this file to your .gitignore.
use Mix.Config
database_url =
System.get_env("DATABASE_URL") ||
raise """
environment variable DATABASE_URL is missing.
For example: ecto://USER:PASS@HOST/DATABASE
"""
config :app, Smena.Repo,
# ssl: true,
url: database_url,
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
secret_key_base =
System.get_env("SECRET_KEY_BASE") ||
raise """
environment variable SECRET_KEY_BASE is missing.
You can generate one by calling: mix phx.gen.secret
"""
config :app, SmenaWeb.Endpoint,
http: [
port: String.to_integer(System.get_env("PORT") || "4000"),
transport_options: [socket_opts: [:inet6]]
],
secret_key_base: secret_key_base
# ## Using releases (Elixir v1.9+)
#
# If you are doing OTP releases, you need to instruct Phoenix
# to start each relevant endpoint:
#
# config :app, SmenaWeb.Endpoint, server: true
#
# Then you can assemble a release by calling `mix release`.
# See `mix help release` for more information.
| 29.214286 | 67 | 0.714751 |
ff8bb626d5063d84f6cd8f35b2c0257fc5dd4f92 | 3,113 | exs | Elixir | test/unit/xsd/datatypes/double_test.exs | pukkamustard/rdf-ex | c459d8e7fa548fdfad82643338b68decf380a296 | [
"MIT"
] | 53 | 2017-06-25T22:20:44.000Z | 2020-04-27T17:27:51.000Z | test/unit/xsd/datatypes/double_test.exs | pukkamustard/rdf-ex | c459d8e7fa548fdfad82643338b68decf380a296 | [
"MIT"
] | 7 | 2017-06-25T00:29:11.000Z | 2020-03-11T00:23:47.000Z | test/unit/xsd/datatypes/double_test.exs | pukkamustard/rdf-ex | c459d8e7fa548fdfad82643338b68decf380a296 | [
"MIT"
] | 3 | 2020-07-03T13:25:36.000Z | 2021-04-04T12:33:51.000Z | defmodule RDF.XSD.DoubleTest do
use RDF.XSD.Datatype.Test.Case,
datatype: RDF.XSD.Double,
name: "double",
primitive: true,
comparable_datatypes: [RDF.XSD.Integer, RDF.XSD.Decimal],
applicable_facets: [
RDF.XSD.Facets.MinInclusive,
RDF.XSD.Facets.MaxInclusive,
RDF.XSD.Facets.MinExclusive,
RDF.XSD.Facets.MaxExclusive,
RDF.XSD.Facets.Pattern
],
facets: %{
min_inclusive: nil,
max_inclusive: nil,
min_exclusive: nil,
max_exclusive: nil,
pattern: nil
},
valid: RDF.XSD.TestData.valid_floats(),
invalid: RDF.XSD.TestData.invalid_floats()
describe "cast/1" do
test "casting a double returns the input as it is" do
assert XSD.double(3.14) |> XSD.Double.cast() == XSD.double(3.14)
assert XSD.double("NAN") |> XSD.Double.cast() == XSD.double("NAN")
assert XSD.double("-INF") |> XSD.Double.cast() == XSD.double("-INF")
end
test "casting a boolean" do
assert XSD.true() |> XSD.Double.cast() == XSD.double(1.0)
assert XSD.false() |> XSD.Double.cast() == XSD.double(0.0)
end
test "casting a string with a value from the lexical value space of xsd:double" do
assert XSD.string("1.0") |> XSD.Double.cast() == XSD.double("1.0E0")
assert XSD.string("3.14") |> XSD.Double.cast() == XSD.double("3.14E0")
assert XSD.string("3.14E0") |> XSD.Double.cast() == XSD.double("3.14E0")
end
test "casting a string with a value not in the lexical value space of xsd:double" do
assert XSD.string("foo") |> XSD.Double.cast() == nil
end
test "casting an integer" do
assert XSD.integer(0) |> XSD.Double.cast() == XSD.double(0.0)
assert XSD.integer(42) |> XSD.Double.cast() == XSD.double(42.0)
end
test "casting a decimal" do
assert XSD.decimal(0) |> XSD.Double.cast() == XSD.double(0)
assert XSD.decimal(1) |> XSD.Double.cast() == XSD.double(1)
assert XSD.decimal(3.14) |> XSD.Double.cast() == XSD.double(3.14)
end
test "casting a float" do
assert XSD.float(0) |> XSD.Double.cast() == XSD.double(0)
assert XSD.float(1) |> XSD.Double.cast() == XSD.double(1)
assert XSD.float(3.14) |> XSD.Double.cast() == XSD.double(3.14)
end
test "from derived types of xsd:double" do
assert DoubleUnitInterval.new(0.14) |> XSD.Double.cast() == XSD.double(0.14)
assert FloatUnitInterval.new(1.0) |> XSD.Double.cast() == XSD.double(1.0)
end
test "from derived types of the castable datatypes" do
assert DecimalUnitInterval.new(0.14) |> XSD.Double.cast() == XSD.double(0.14)
assert Age.new(42) |> XSD.Double.cast() == XSD.double(42)
end
test "with invalid literals" do
assert XSD.boolean("42") |> XSD.Double.cast() == nil
assert XSD.integer(3.14) |> XSD.Double.cast() == nil
assert XSD.decimal("NAN") |> XSD.Double.cast() == nil
assert XSD.double(true) |> XSD.Double.cast() == nil
end
test "with literals of unsupported datatypes" do
assert XSD.date("2020-01-01") |> XSD.Double.cast() == nil
end
end
end
| 36.623529 | 88 | 0.62512 |
ff8be22d1780a630bd239551901ae289a2cdf594 | 1,439 | exs | Elixir | test/tradehub/fee_test.exs | anhmv/tradehub-api-elixir | 6ec87c2b07188d4140506011e2b28db4d372ac6d | [
"MIT"
] | 5 | 2021-05-04T16:54:25.000Z | 2021-12-15T06:53:24.000Z | test/tradehub/fee_test.exs | anhmv/tradehub-api-elixir | 6ec87c2b07188d4140506011e2b28db4d372ac6d | [
"MIT"
] | 5 | 2021-05-19T04:49:00.000Z | 2021-06-01T13:36:50.000Z | test/tradehub/fee_test.exs | anhmv/tradehub-elixir | 6ec87c2b07188d4140506011e2b28db4d372ac6d | [
"MIT"
] | null | null | null | defmodule TradehubTest.FeeTest do
use ExUnit.Case, async: false
doctest Tradehub.Fee
setup do
env = Application.get_all_env(:tradehub)
on_exit(fn -> Application.put_all_env([{:tradehub, env}]) end)
end
test "GET txns_fees should responses a valid result" do
result = Tradehub.Fee.txns_fees!()
assert_txns_fees!(result)
end
test "GET current_fee should responses a valid result" do
result = Tradehub.Fee.current_fee!("swth")
assert_withdrawal_fee!(result)
end
test "GET current_fee should responses an error as string when param is incorrect" do
result = Tradehub.Fee.current_fee!("swth_hehe")
assert String.valid?(result)
end
test "expects failures" do
Application.put_env(:tradehub, :http_client, TradehubTest.NetTimeoutMock)
assert_raise HTTPoison.Error, fn ->
Tradehub.Fee.txns_fees!()
end
assert_raise HTTPoison.Error, fn ->
Tradehub.Fee.current_fee!("swth")
end
end
# Helper functions
defp assert_txns_fees!(obj) do
assert String.valid?(obj.height)
assert is_list(obj.result)
result = obj.result
result
|> Enum.each(fn x ->
assert String.valid?(x.msg_type)
assert String.valid?(x.fee)
end)
end
defp assert_withdrawal_fee!(obj) do
assert is_integer(obj.prev_update_time)
assert String.valid?(obj.details.deposit.fee)
assert String.valid?(obj.details.withdrawal.fee)
end
end
| 23.590164 | 87 | 0.703961 |
ff8bf3677381bbc67952c266938bb45b6db0c63e | 2,636 | ex | Elixir | lib/day11/hull_painter2.ex | anamba/adventofcode2019 | a5de43ddce8b40f67c3017f349d8563c73c94e20 | [
"MIT"
] | null | null | null | lib/day11/hull_painter2.ex | anamba/adventofcode2019 | a5de43ddce8b40f67c3017f349d8563c73c94e20 | [
"MIT"
] | null | null | null | lib/day11/hull_painter2.ex | anamba/adventofcode2019 | a5de43ddce8b40f67c3017f349d8563c73c94e20 | [
"MIT"
] | null | null | null | defmodule Day11.HullPainter2 do
def part2 do
pid = read_program() |> start_program
map = iterate(pid)
list = map |> Map.keys() |> Enum.sort()
end
def read_program do
"inputs/day11.txt"
|> File.stream!()
|> Enum.map(fn line ->
line |> String.trim() |> String.split(",") |> Enum.map(&String.to_integer/1)
end)
|> List.flatten()
end
def start_program(program) do
spawn(Day11.IntcodeInterpreter, :start_program, [program, [], self()])
end
def iterate(pid, dir \\ :up, pos \\ {0, 0}, hull_map \\ %{{0, 0} => 1}, iteration \\ 0) do
IO.inspect(iteration, label: "iteration")
# send current color
send(pid, {:input, Map.get(hull_map, pos, 0)})
# get back new color and next direction
if Process.alive?(pid) do
color =
receive do
{:output, color} ->
color
# |> IO.inspect(label: "color")
end
hull_map = Map.put(hull_map, pos, color)
hull_map
|> display_hull_map
# |> Map.keys()
# |> Enum.count()
# |> IO.inspect(label: "current count")
if Process.alive?(pid) do
receive do
{:output, turn} ->
# turn |> IO.inspect(label: "turn")
new_dir = next_direction(dir, turn)
new_pos = next_position(pos, new_dir)
if Process.alive?(pid), do: iterate(pid, new_dir, new_pos, hull_map, iteration + 1)
end
else
hull_map
end
else
hull_map
end
end
def display_hull_map(map) do
{{xmin, _}, {xmax, _}} =
map
|> Map.keys()
|> Enum.sort()
|> Enum.min_max_by(fn {x, _y} -> x end)
{{_, ymin}, {_, ymax}} =
map
|> Map.keys()
|> Enum.sort()
|> Enum.min_max_by(fn {_x, y} -> y end)
# aaaand the cartesian coordinate decision messed me up right here for a sec.
for y <- ymax..ymin do
for x <- xmin..xmax do
if map[{x, y}] == 1, do: "O", else: " "
end
|> IO.puts()
end
end
# let's choose to be sane and use cartesian coordinates today.
def next_position({x, y}, :up), do: {x, y + 1}
def next_position({x, y}, :right), do: {x + 1, y}
def next_position({x, y}, :down), do: {x, y - 1}
def next_position({x, y}, :left), do: {x - 1, y}
def next_direction(:up, 0), do: :left
def next_direction(:right, 0), do: :up
def next_direction(:down, 0), do: :right
def next_direction(:left, 0), do: :down
def next_direction(:up, 1), do: :right
def next_direction(:right, 1), do: :down
def next_direction(:down, 1), do: :left
def next_direction(:left, 1), do: :up
end
| 26.626263 | 95 | 0.556146 |
ff8c01f58c50064ac8484da92f6608028a97927c | 2,570 | ex | Elixir | lib/game/items.ex | stevegrossi/ex_venture | e02d5a63fdb882d92cfb4af3e15f7b48ad7054aa | [
"MIT"
] | 1 | 2019-02-10T10:22:39.000Z | 2019-02-10T10:22:39.000Z | lib/game/items.ex | stevegrossi/ex_venture | e02d5a63fdb882d92cfb4af3e15f7b48ad7054aa | [
"MIT"
] | null | null | null | lib/game/items.ex | stevegrossi/ex_venture | e02d5a63fdb882d92cfb4af3e15f7b48ad7054aa | [
"MIT"
] | null | null | null | defmodule Game.Items do
@moduledoc """
Agent for keeping track of items in the system
"""
use GenServer
import Ecto.Query
alias Data.Item
alias Data.Repo
@key :items
@doc false
def start_link() do
GenServer.start_link(__MODULE__, [], name: __MODULE__)
end
@doc """
Get an item from the cache
"""
@spec get(integer()) :: {:ok, Item.t()} | {:error, :not_found}
def get(id) do
case item(id) do
nil ->
{:error, :not_found}
item ->
{:ok, item}
end
end
@spec item(integer()) :: Item.t() | nil
def item(instance = %Item.Instance{}) do
item(instance.id)
end
def item(id) when is_integer(id) do
case Cachex.get(@key, id) do
{:ok, item} when item != nil ->
item
_ ->
nil
end
end
@spec items([Item.instance()]) :: [Item.t()]
def items(instances) do
instances
|> Enum.map(&item/1)
|> Enum.reject(&is_nil/1)
end
@spec items_keep_instance([Item.instance()]) :: [{Item.instance(), Item.t()}]
def items_keep_instance(instances) do
instances
|> Enum.map(fn instance ->
{instance, item(instance)}
end)
|> Enum.reject(fn {_, item} ->
is_nil(item)
end)
end
@doc """
Insert a new item into the loaded data
"""
@spec insert(Item.t()) :: :ok
def insert(item) do
members = :pg2.get_members(@key)
Enum.map(members, fn member ->
GenServer.call(member, {:insert, item})
end)
end
@doc """
Trigger an item reload
"""
@spec reload(Item.t()) :: :ok
def reload(item), do: insert(item)
@doc """
For testing only: clear the EST table
"""
def clear() do
GenServer.call(__MODULE__, :clear)
end
#
# Server
#
def init(_) do
:ok = :pg2.create(@key)
:ok = :pg2.join(@key, self())
GenServer.cast(self(), :load_items)
{:ok, %{}}
end
def handle_cast(:load_items, state) do
items =
Item
|> preload([:item_aspects])
|> Repo.all()
Enum.each(items, fn item ->
item = Item.compile(item)
Cachex.put(@key, item.id, item)
end)
{:noreply, state}
end
def handle_call({:insert, item = %Item{}}, _from, state) do
item =
item
|> Repo.preload([:item_aspects])
|> Item.compile()
Cachex.put(@key, item.id, item)
{:reply, :ok, state}
end
def handle_call({:insert, item}, _from, state) do
Cachex.put(@key, item.id, item)
{:reply, :ok, state}
end
def handle_call(:clear, _from, state) do
Cachex.clear(@key)
{:reply, :ok, state}
end
end
| 18.357143 | 79 | 0.573152 |
ff8c07bd50583b1c6fa5a12e7ab1e32a3dfc2f59 | 563 | exs | Elixir | 2017/elixir/day24/mix.exs | zakora/elixir-aoc2017 | 216e92cef370081cc0792102e0b40dd3a518d8bf | [
"Unlicense"
] | null | null | null | 2017/elixir/day24/mix.exs | zakora/elixir-aoc2017 | 216e92cef370081cc0792102e0b40dd3a518d8bf | [
"Unlicense"
] | null | null | null | 2017/elixir/day24/mix.exs | zakora/elixir-aoc2017 | 216e92cef370081cc0792102e0b40dd3a518d8bf | [
"Unlicense"
] | null | null | null | defmodule Day24.Mixfile do
use Mix.Project
def project do
[
app: :day24,
version: "0.1.0",
elixir: "~> 1.5",
start_permanent: Mix.env == :prod,
deps: deps()
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
]
end
end
| 19.413793 | 88 | 0.571936 |
ff8c35104e029b13b44137199caef4a8b895b130 | 1,989 | exs | Elixir | mix.exs | axelson/scenic_driver_glfw | 4e5b0d9408abac575812674ec2eee75b221c5f21 | [
"Apache-2.0"
] | 1 | 2020-05-16T05:01:48.000Z | 2020-05-16T05:01:48.000Z | mix.exs | GregMefford/scenic_driver_glfw | 4e5b0d9408abac575812674ec2eee75b221c5f21 | [
"Apache-2.0"
] | null | null | null | mix.exs | GregMefford/scenic_driver_glfw | 4e5b0d9408abac575812674ec2eee75b221c5f21 | [
"Apache-2.0"
] | null | null | null | defmodule Scenic.Driver.Glfw.MixProject do
use Mix.Project
@github "https://github.com/boydm/scenic_driver_glfw"
@version "0.10.0"
def project do
[
app: :scenic_driver_glfw,
version: @version,
build_path: "_build",
config_path: "config/config.exs",
deps_path: "deps",
lockfile: "mix.lock",
elixir: "~> 1.8",
description: description(),
build_embedded: true,
start_permanent: Mix.env() == :prod,
compilers: [:elixir_make] ++ Mix.compilers(),
make_env: %{"MIX_ENV" => to_string(Mix.env())},
make_clean: ["clean"],
deps: deps(),
dialyzer: [plt_add_deps: :transitive],
package: [
name: :scenic_driver_glfw,
contributors: ["Boyd Multerer"],
maintainers: ["Boyd Multerer"],
licenses: ["Apache 2"],
links: %{github: @github},
files: [
"c_src/**/*.[ch]",
"c_src/**/*.txt",
"config",
"priv/fonts/**/*.txt",
"priv/fonts/**/*.ttf.*",
"lib/**/*.ex",
"Makefile",
"mix.exs",
"README.md",
"LICENSE",
"changelist.md"
]
],
docs: [
extras: doc_guides(),
main: "overview",
source_ref: "v#{@version}",
source_url: "https://github.com/boydm/scenic_driver_glfw"
# homepage_url: "http://kry10.com",
]
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:elixir_make, "~> 0.5"},
{:scenic, "~> 0.10"},
{:ex_doc, ">= 0.0.0", only: [:dev]},
{:dialyxir, "~> 0.5", only: :dev, runtime: false}
]
end
defp description() do
"""
Scenic.Driver.Glfw - Main Scenic driver for MacOs and Ubuntu
"""
end
defp doc_guides do
[
"guides/overview.md"
]
end
end
| 23.963855 | 65 | 0.527401 |
ff8c3b3f195c25545a320ecb6a693948c21e459d | 70 | ex | Elixir | installer/phoenix/templates/phx_html/session_view.ex | elixircnx/sanction | 5b270fd6eef980d37c06429271f64ec14e0f622d | [
"BSD-3-Clause"
] | 130 | 2016-06-21T07:58:46.000Z | 2022-01-01T21:45:23.000Z | installer/phoenix/templates/phx_html/session_view.ex | elixircnx/sanction | 5b270fd6eef980d37c06429271f64ec14e0f622d | [
"BSD-3-Clause"
] | 50 | 2016-06-29T16:01:42.000Z | 2019-08-07T21:33:49.000Z | installer/phoenix/templates/phx_html/session_view.ex | elixircnx/sanction | 5b270fd6eef980d37c06429271f64ec14e0f622d | [
"BSD-3-Clause"
] | 20 | 2016-07-02T11:37:33.000Z | 2018-10-26T19:12:41.000Z | defmodule <%= base %>.SessionView do
use <%= base %>.Web, :view
end
| 17.5 | 36 | 0.614286 |
ff8c5511a94d3236ea15c4b7da9529be2bb0e7bf | 538 | exs | Elixir | config/test.exs | SparkPost/elixir-webhook-sample | 22d367b63f4995eb0ddb4b0aaf484790987b8491 | [
"Apache-2.0"
] | 1 | 2021-12-08T18:15:33.000Z | 2021-12-08T18:15:33.000Z | config/test.exs | SparkPost/elixir-webhook-sample | 22d367b63f4995eb0ddb4b0aaf484790987b8491 | [
"Apache-2.0"
] | null | null | null | config/test.exs | SparkPost/elixir-webhook-sample | 22d367b63f4995eb0ddb4b0aaf484790987b8491 | [
"Apache-2.0"
] | null | null | null | use Mix.Config
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :track_user_agents, TrackUserAgentsWeb.Endpoint,
http: [port: 4001],
server: false
# Print only warnings and errors during test
config :logger, level: :warn
# Configure your database
config :track_user_agents, TrackUserAgents.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "",
database: "track_user_agents_phx13_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox
| 26.9 | 56 | 0.756506 |
ff8c58a9d418ce15bba8f240336d585e3c10afff | 944 | ex | Elixir | lib/lightbridge/mqtt_handler.ex | jamesduncombe/lightbridge | c6b5fd54f5495ae12fefc0174ca95ebe2f69a1ce | [
"MIT"
] | null | null | null | lib/lightbridge/mqtt_handler.ex | jamesduncombe/lightbridge | c6b5fd54f5495ae12fefc0174ca95ebe2f69a1ce | [
"MIT"
] | null | null | null | lib/lightbridge/mqtt_handler.ex | jamesduncombe/lightbridge | c6b5fd54f5495ae12fefc0174ca95ebe2f69a1ce | [
"MIT"
] | null | null | null | defmodule Lightbridge.MqttHandler do
@moduledoc """
Implements `Tortoise.Handler` behaviour.
"""
require Logger
alias Lightbridge.Hs100
@behaviour Tortoise.Handler
def init(_args) do
{:ok, nil}
end
def connection(status, state) do
Logger.warn("Connection status: #{inspect(status)}")
{:ok, state}
end
def subscription(status, topic_filter, state) do
Logger.info("#{topic_filter}, #{status}")
{:ok, state}
end
def terminate(reason, _state) do
Logger.info(inspect(reason))
end
# Message handlers
def handle_message(_topic, _payload = "0", state) do
Logger.info("Turning light off")
Hs100.turn_off()
{:ok, state}
end
def handle_message(_topic, _payload = "1", state) do
Logger.info("Turning light on")
Hs100.turn_on()
{:ok, state}
end
def handle_message(topic, payload, state) do
Logger.info("#{topic}, #{payload}")
{:ok, state}
end
end
| 18.88 | 56 | 0.65572 |
ff8c67306a33e9cd902e0912751d535da0be24c9 | 12,708 | ex | Elixir | lib/mix/lib/mix/tasks/test.coverage.ex | doughsay/elixir | 7356a47047d0b54517bd6886603f09b1121dde2b | [
"Apache-2.0"
] | 19,291 | 2015-01-01T02:42:49.000Z | 2022-03-31T21:01:40.000Z | lib/mix/lib/mix/tasks/test.coverage.ex | doughsay/elixir | 7356a47047d0b54517bd6886603f09b1121dde2b | [
"Apache-2.0"
] | 8,082 | 2015-01-01T04:16:23.000Z | 2022-03-31T22:08:02.000Z | lib/mix/lib/mix/tasks/test.coverage.ex | doughsay/elixir | 7356a47047d0b54517bd6886603f09b1121dde2b | [
"Apache-2.0"
] | 3,472 | 2015-01-03T04:11:56.000Z | 2022-03-29T02:07:30.000Z | defmodule Mix.Tasks.Test.Coverage do
use Mix.Task
@moduledoc """
Build reports from exported test coverage.
In this moduledoc, we will describe how the default test
coverage works in Elixir and also explore how it is capable
of export coverage results to group reports from multiple
test runs.
## Line coverage
Elixir uses Erlang's [`:cover`](https://www.erlang.org/doc/man/cover.html)
for its default test coverage. Erlang coverage is done by tracking
*executable lines of code*. This implies blank lines, code comments,
function signatures, and patterns are not necessarily executable and
therefore won't be tracked ín coverage reports. Code in macros are
also often executed at compilation time, and therefore may not covered.
Similarly, Elixir AST literals, such as atoms, are not executable either.
Let's see an example:
if some_condition? do
do_this()
else
do_that()
end
In the example above, if your tests exercise both `some_condition? == true`
and `some_condition? == false`, all branches will be covered, as they all
have executable code. However, the following code
if some_condition? do
do_this()
else
:default
end
won't ever mark the `:default` branch as covered, as there is no executable
code in the `else` branch. Note, however, this issue does not happen on `case`
or `cond`, as Elixir is able to mark the clause operator `->` as executable in
such corner cases:
case some_condition? do
true ->
do_this()
false ->
:default
end
If the code above is tested with both conditions, you should see entries
in both branches marked as covered.
Finally, it is worth discussing that line coverage by itself has its own
limitations. For example, take the following code:
do_this() || do_that()
Line coverage is not capable of expressing that both `do_this()` and
`do_that()` have been executed, since as soon as `do_this()` is executed,
the whole line is covered. Other techniques, such as branch coverage,
can help spot those cases, but they are not currently supported by the
default coverage tool.
Overall, code coverage can be a great tool for finding out flaws in our
code (such as functions that haven't been covered) but it can also lead
teams into a false sense of security since 100% coverage never means all
different executions flows have been asserted, even with the most advanced
coverage techniques. It is up to you and your team to specify how much
emphasis you want to place on it.
## Exporting coverage
This task can be used when you need to group the coverage
across multiple test runs. Let's see some examples.
### Example: aggregating partitioned runs
If you partition your tests across multiple runs,
you can unify the report as shown below:
MIX_TEST_PARTITION=1 mix test --partitions 2 --cover
MIX_TEST_PARTITION=2 mix test --partitions 2 --cover
mix test.coverage
This works because the `--partitions` option
automatically exports the coverage results.
### Example: aggregating coverage reports from all umbrella children
If you run `mix test.coverage` inside an umbrella,
it will automatically gather exported cover results
from all umbrella children - as long as the coverage
results have been exported, like this:
# from the umbrella root
mix test --cover --export-coverage default
mix test.coverage
Of course, if you want to actually partition the tests,
you can also do:
# from the umbrella root
MIX_TEST_PARTITION=1 mix test --partitions 2 --cover
MIX_TEST_PARTITION=2 mix test --partitions 2 --cover
mix test.coverage
On the other hand, if you want partitioned tests but
per-app reports, you can do:
# from the umbrella root
MIX_TEST_PARTITION=1 mix test --partitions 2 --cover
MIX_TEST_PARTITION=2 mix test --partitions 2 --cover
mix cmd mix test.coverage
When running `test.coverage` from the umbrella root, it
will use the `:test_coverage` configuration from the umbrella
root.
Finally, note the coverage itself is not measured across
the projects themselves. For example, if project B depends
on A, and if there is code in A that is only executed from
project B, those lines will not be marked as covered, which
is important, as those projects should be developed and tested
in isolation.
### Other scenarios
There may be other scenarios where you want to export coverage.
For example, you may have broken your test suite into two, one
for unit tests and another for integration tests. In such scenarios,
you can explicitly use the `--export-coverage` command line option,
or the `:export` option under `:test_coverage` in your `mix.exs` file.
"""
@shortdoc "Build report from exported test coverage"
@preferred_cli_env :test
@default_threshold 90
@doc false
def run(_args) do
Mix.Task.run("compile")
config = Mix.Project.config()
test_coverage = config[:test_coverage] || []
{cover_paths, compile_paths} = apps_paths(config, test_coverage)
pid = cover_compile(compile_paths)
case Enum.flat_map(cover_paths, &Path.wildcard(Path.join(&1, "*.coverdata"))) do
[] ->
Mix.shell().error(
"Could not find .coverdata file in any of the paths: " <>
Enum.join(cover_paths, ", ")
)
entries ->
for entry <- entries do
Mix.shell().info("Importing cover results: #{entry}")
:ok = :cover.import(String.to_charlist(entry))
end
# Silence analyse import messages emitted by cover
{:ok, string_io} = StringIO.open("")
Process.group_leader(pid, string_io)
Mix.shell().info("")
generate_cover_results(test_coverage)
end
end
defp apps_paths(config, test_coverage) do
output = Keyword.get(test_coverage, :output, "cover")
if apps_paths = Mix.Project.apps_paths(config) do
build_path = Mix.Project.build_path(config)
compile_paths =
Enum.map(apps_paths, fn {app, _} ->
Path.join([build_path, "lib", Atom.to_string(app), "ebin"])
end)
{Enum.map(apps_paths, fn {_, path} -> Path.join(path, output) end), compile_paths}
else
{[output], [Mix.Project.compile_path(config)]}
end
end
@doc false
def start(compile_path, opts) do
Mix.shell().info("Cover compiling modules ...")
if Keyword.get(opts, :local_only, true) do
:cover.local_only()
end
cover_compile([compile_path])
if name = opts[:export] do
fn ->
Mix.shell().info("\nExporting cover results ...\n")
export_cover_results(name, opts)
end
else
fn ->
Mix.shell().info("\nGenerating cover results ...\n")
generate_cover_results(opts)
end
end
end
defp cover_compile(compile_paths) do
_ = :cover.stop()
{:ok, pid} = :cover.start()
for compile_path <- compile_paths do
case :cover.compile_beam(beams(compile_path)) do
results when is_list(results) ->
:ok
{:error, reason} ->
Mix.raise(
"Failed to cover compile directory #{inspect(Path.relative_to_cwd(compile_path))} " <>
"with reason: #{inspect(reason)}"
)
end
end
pid
end
# Pick beams from the compile_path but if by any chance it is a protocol,
# gets its path from the code server (which will most likely point to
# the consolidation directory as long as it is enabled).
defp beams(dir) do
consolidation_dir = Mix.Project.consolidation_path()
consolidated =
case File.ls(consolidation_dir) do
{:ok, files} -> files
_ -> []
end
for file <- File.ls!(dir), Path.extname(file) == ".beam" do
with true <- file in consolidated,
[_ | _] = path <- :code.which(file |> Path.rootname() |> String.to_atom()) do
path
else
_ -> String.to_charlist(Path.join(dir, file))
end
end
end
defp export_cover_results(name, opts) do
output = Keyword.get(opts, :output, "cover")
File.mkdir_p!(output)
case :cover.export('#{output}/#{name}.coverdata') do
:ok ->
Mix.shell().info("Run \"mix test.coverage\" once all exports complete")
{:error, reason} ->
Mix.shell().error("Export failed with reason: #{inspect(reason)}")
end
end
defp generate_cover_results(opts) do
{:result, ok, _fail} = :cover.analyse(:coverage, :line)
ignore = opts[:ignore_modules] || []
modules = Enum.reject(:cover.modules(), &ignored?(&1, ignore))
if summary_opts = Keyword.get(opts, :summary, true) do
summary(ok, modules, summary_opts)
end
html(modules, opts)
end
defp ignored?(mod, ignores) do
Enum.any?(ignores, &ignored_any?(mod, &1))
end
defp ignored_any?(mod, %Regex{} = re), do: Regex.match?(re, inspect(mod))
defp ignored_any?(mod, other), do: mod == other
defp html(modules, opts) do
output = Keyword.get(opts, :output, "cover")
File.mkdir_p!(output)
for mod <- modules do
{:ok, _} = :cover.analyse_to_file(mod, '#{output}/#{mod}.html', [:html])
end
Mix.shell().info("Generated HTML coverage results in #{inspect(output)} directory")
end
defp summary(results, keep, summary_opts) do
{module_results, totals} = gather_coverage(results, keep)
module_results = Enum.sort(module_results, :desc)
print_summary(module_results, totals, summary_opts)
if totals < get_threshold(summary_opts) do
print_failed_threshold(totals, get_threshold(summary_opts))
System.at_exit(fn _ -> exit({:shutdown, 3}) end)
end
:ok
end
defp gather_coverage(results, keep) do
keep_set = MapSet.new(keep)
# When gathering coverage results, we need to skip any
# entry with line equal to 0 as those are generated code.
#
# We may also have multiple entries on the same line.
# Each line is only considered once.
#
# We use ETS for performance, to avoid working with nested maps.
table = :ets.new(__MODULE__, [:set, :private])
try do
for {{module, line}, cov} <- results, module in keep_set, line != 0 do
case cov do
{1, 0} -> :ets.insert(table, {{module, line}, true})
{0, 1} -> :ets.insert_new(table, {{module, line}, false})
end
end
module_results = for module <- keep, do: {read_cover_results(table, module), module}
{module_results, read_cover_results(table, :_)}
after
:ets.delete(table)
end
end
defp read_cover_results(table, module) do
covered = :ets.select_count(table, [{{{module, :_}, true}, [], [true]}])
not_covered = :ets.select_count(table, [{{{module, :_}, false}, [], [true]}])
percentage(covered, not_covered)
end
defp percentage(0, 0), do: 100.0
defp percentage(covered, not_covered), do: covered / (covered + not_covered) * 100
defp print_summary(results, totals, true), do: print_summary(results, totals, [])
defp print_summary(results, totals, opts) when is_list(opts) do
threshold = get_threshold(opts)
Mix.shell().info("Percentage | Module")
Mix.shell().info("-----------|--------------------------")
results |> Enum.sort() |> Enum.each(&display(&1, threshold))
Mix.shell().info("-----------|--------------------------")
display({totals, "Total"}, opts)
Mix.shell().info("")
end
defp print_failed_threshold(totals, threshold) do
Mix.shell().info("Coverage test failed, threshold not met:\n")
Mix.shell().info(" Coverage: #{format_number(totals, 6)}%")
Mix.shell().info(" Threshold: #{format_number(threshold, 6)}%")
Mix.shell().info("")
end
defp display({percentage, name}, threshold) do
Mix.shell().info([
color(percentage, threshold),
format_number(percentage, 9),
"%",
:reset,
" | ",
format_name(name)
])
end
defp color(percentage, true), do: color(percentage, @default_threshold)
defp color(_, false), do: ""
defp color(percentage, threshold) when percentage >= threshold, do: :green
defp color(_, _), do: :red
defp format_number(number, length) when is_integer(number),
do: format_number(number / 1, length)
defp format_number(number, length), do: :io_lib.format("~#{length}.2f", [number])
defp format_name(name) when is_binary(name), do: name
defp format_name(mod) when is_atom(mod), do: inspect(mod)
defp get_threshold(true), do: @default_threshold
defp get_threshold(opts), do: Keyword.get(opts, :threshold, @default_threshold)
end
| 32.501279 | 98 | 0.663991 |
ff8c6c57aeb376b708101895401bcca40accae2e | 1,710 | ex | Elixir | apps/customer/lib/customer/web/models/user.ex | JaiMali/job_search-1 | 5fe1afcd80aa5d55b92befed2780cd6721837c88 | [
"MIT"
] | 102 | 2017-05-21T18:24:04.000Z | 2022-03-10T12:53:20.000Z | apps/customer/lib/customer/web/models/user.ex | JaiMali/job_search-1 | 5fe1afcd80aa5d55b92befed2780cd6721837c88 | [
"MIT"
] | 2 | 2017-05-21T01:53:30.000Z | 2017-12-01T00:27:06.000Z | apps/customer/lib/customer/web/models/user.ex | JaiMali/job_search-1 | 5fe1afcd80aa5d55b92befed2780cd6721837c88 | [
"MIT"
] | 18 | 2017-05-22T09:51:36.000Z | 2021-09-24T00:57:01.000Z | defmodule Customer.Web.User do
use Customer.Web, :model
alias Customer.Blank
schema "users" do
field :name, :string, null: false
field :email, :string
field :is_admin, :boolean, default: false
has_many :authorizations, Authorization
has_many :favorite_jobs, FavoriteJob
has_many :job_applications, JobApplication
timestamps()
end
@required_fields ~w(name email)a
@optional_fields ~w(is_admin)a
@doc """
Builds a changeset based on the `struct` and `params`.
"""
def changeset(model \\ %__MODULE__{}, params \\ %{}) do
model
|> cast(params, @required_fields ++ @optional_fields)
|> validate_required(@required_fields)
|> validate_format(:email, ~r/@/)
end
def registration_changeset(model \\ %__MODULE__{}, params \\ %{}) do
model
|> cast(params_with_name(params), @required_fields)
|> validate_required(@required_fields)
|> validate_format(:email, ~r/@/)
end
defp params_with_name(%{name: name, first_name: first_name, last_name: last_name, nickname: nickname, email: email} = _params) do
%{
name: name_from_auth(first_name, last_name, nickname, name),
email: email
}
end
defp name_from_auth(first_name, last_name, nickname, name) do
if Blank.blank?(name) do
name_from_auth([first_name, last_name], nickname)
else
name
end
end
defp name_from_auth(names, nickname) do
name = names |> Enum.filter(&(&1 != nil && &1 != ""))
if Enum.empty?(name) do
name_from_auth(nickname)
else
Enum.join(name, " ")
end
end
defp name_from_auth(nickname) do
if Blank.blank?(nickname) do
"no name"
else
nickname
end
end
end
| 24.782609 | 131 | 0.660234 |
ff8c8cf5385626dfab42c381fce6d67ca0982ff0 | 452 | exs | Elixir | priv/repo/migrations/20200816212935_create_shipping_address.exs | Wobblesday/JIT-Jerky | b60c52ee76cf9ae4836ee99f3deccda72fccc656 | [
"Apache-2.0"
] | null | null | null | priv/repo/migrations/20200816212935_create_shipping_address.exs | Wobblesday/JIT-Jerky | b60c52ee76cf9ae4836ee99f3deccda72fccc656 | [
"Apache-2.0"
] | null | null | null | priv/repo/migrations/20200816212935_create_shipping_address.exs | Wobblesday/JIT-Jerky | b60c52ee76cf9ae4836ee99f3deccda72fccc656 | [
"Apache-2.0"
] | null | null | null | defmodule JITJerky.Repo.Migrations.CreateShippingAddress do
use Ecto.Migration
def change do
create table(:shipping_address) do
add :country, :string
add :name, :string
add :address_line1, :string
add :address_line2, :string
add :city, :string
add :province, :string
add :postal_code, :string
add :telephone, :string
add :delivery_instructions, :map
timestamps()
end
end
end
| 21.52381 | 59 | 0.65708 |
ff8cc1f9271e1ebdbb711f0eafb724d161a9b21c | 9,074 | ex | Elixir | Microsoft.Azure.Management.Network/lib/microsoft/azure/management/network/api/route_filters.ex | chgeuer/ex_microsoft_azure_management | 99cd9f7f2ff1fdbe69ca5bac55b6e2af91ba3603 | [
"Apache-2.0"
] | 4 | 2018-09-29T03:43:15.000Z | 2021-04-01T18:30:46.000Z | Microsoft.Azure.Management.Network/lib/microsoft/azure/management/network/api/route_filters.ex | chgeuer/ex_microsoft_azure_management | 99cd9f7f2ff1fdbe69ca5bac55b6e2af91ba3603 | [
"Apache-2.0"
] | null | null | null | Microsoft.Azure.Management.Network/lib/microsoft/azure/management/network/api/route_filters.ex | chgeuer/ex_microsoft_azure_management | 99cd9f7f2ff1fdbe69ca5bac55b6e2af91ba3603 | [
"Apache-2.0"
] | null | null | null | # NOTE: This class is auto generated by the swagger code generator program.
# https://github.com/swagger-api/swagger-codegen.git
# Do not edit the class manually.
defmodule Microsoft.Azure.Management.Network.Api.RouteFilters do
@moduledoc """
API calls for all endpoints tagged `RouteFilters`.
"""
alias Microsoft.Azure.Management.Network.Connection
import Microsoft.Azure.Management.Network.RequestBuilder
@doc """
Creates or updates a route filter in a specified resource group.
## Parameters
- connection (Microsoft.Azure.Management.Network.Connection): Connection to server
- resource_group_name (String.t): The name of the resource group.
- route_filter_name (String.t): The name of the route filter.
- route_filter_parameters (RouteFilter): Parameters supplied to the create or update route filter operation.
- api_version (String.t): Client API version.
- subscription_id (String.t): The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %Microsoft.Azure.Management.Network.Model.RouteFilter{}} on success
{:error, info} on failure
"""
@spec route_filters_create_or_update(Tesla.Env.client, String.t, String.t, Microsoft.Azure.Management.Network.Model.RouteFilter.t, String.t, String.t, keyword()) :: {:ok, Microsoft.Azure.Management.Network.Model.RouteFilter.t} | {:error, Tesla.Env.t}
def route_filters_create_or_update(connection, resource_group_name, route_filter_name, route_filter_parameters, api_version, subscription_id, _opts \\ []) do
%{}
|> method(:put)
|> url("/subscriptions/#{subscription_id}/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/routeFilters/#{route_filter_name}")
|> add_param(:body, :body, route_filter_parameters)
|> add_param(:query, :"api-version", api_version)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Microsoft.Azure.Management.Network.Model.RouteFilter{})
end
@doc """
Deletes the specified route filter.
## Parameters
- connection (Microsoft.Azure.Management.Network.Connection): Connection to server
- resource_group_name (String.t): The name of the resource group.
- route_filter_name (String.t): The name of the route filter.
- api_version (String.t): Client API version.
- subscription_id (String.t): The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %{}} on success
{:error, info} on failure
"""
@spec route_filters_delete(Tesla.Env.client, String.t, String.t, String.t, String.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
def route_filters_delete(connection, resource_group_name, route_filter_name, api_version, subscription_id, _opts \\ []) do
%{}
|> method(:delete)
|> url("/subscriptions/#{subscription_id}/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/routeFilters/#{route_filter_name}")
|> add_param(:query, :"api-version", api_version)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(false)
end
@doc """
Gets the specified route filter.
## Parameters
- connection (Microsoft.Azure.Management.Network.Connection): Connection to server
- resource_group_name (String.t): The name of the resource group.
- route_filter_name (String.t): The name of the route filter.
- api_version (String.t): Client API version.
- subscription_id (String.t): The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
- opts (KeywordList): [optional] Optional parameters
- :__expand (String.t): Expands referenced express route bgp peering resources.
## Returns
{:ok, %Microsoft.Azure.Management.Network.Model.RouteFilter{}} on success
{:error, info} on failure
"""
@spec route_filters_get(Tesla.Env.client, String.t, String.t, String.t, String.t, keyword()) :: {:ok, Microsoft.Azure.Management.Network.Model.RouteFilter.t} | {:error, Tesla.Env.t}
def route_filters_get(connection, resource_group_name, route_filter_name, api_version, subscription_id, opts \\ []) do
optional_params = %{
:"$expand" => :query
}
%{}
|> method(:get)
|> url("/subscriptions/#{subscription_id}/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/routeFilters/#{route_filter_name}")
|> add_param(:query, :"api-version", api_version)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Microsoft.Azure.Management.Network.Model.RouteFilter{})
end
@doc """
Gets all route filters in a subscription.
## Parameters
- connection (Microsoft.Azure.Management.Network.Connection): Connection to server
- api_version (String.t): Client API version.
- subscription_id (String.t): The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %Microsoft.Azure.Management.Network.Model.RouteFilterListResult{}} on success
{:error, info} on failure
"""
@spec route_filters_list(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, Microsoft.Azure.Management.Network.Model.RouteFilterListResult.t} | {:error, Tesla.Env.t}
def route_filters_list(connection, api_version, subscription_id, _opts \\ []) do
%{}
|> method(:get)
|> url("/subscriptions/#{subscription_id}/providers/Microsoft.Network/routeFilters")
|> add_param(:query, :"api-version", api_version)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Microsoft.Azure.Management.Network.Model.RouteFilterListResult{})
end
@doc """
Gets all route filters in a resource group.
## Parameters
- connection (Microsoft.Azure.Management.Network.Connection): Connection to server
- resource_group_name (String.t): The name of the resource group.
- api_version (String.t): Client API version.
- subscription_id (String.t): The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %Microsoft.Azure.Management.Network.Model.RouteFilterListResult{}} on success
{:error, info} on failure
"""
@spec route_filters_list_by_resource_group(Tesla.Env.client, String.t, String.t, String.t, keyword()) :: {:ok, Microsoft.Azure.Management.Network.Model.RouteFilterListResult.t} | {:error, Tesla.Env.t}
def route_filters_list_by_resource_group(connection, resource_group_name, api_version, subscription_id, _opts \\ []) do
%{}
|> method(:get)
|> url("/subscriptions/#{subscription_id}/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/routeFilters")
|> add_param(:query, :"api-version", api_version)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Microsoft.Azure.Management.Network.Model.RouteFilterListResult{})
end
@doc """
Updates a route filter in a specified resource group.
## Parameters
- connection (Microsoft.Azure.Management.Network.Connection): Connection to server
- resource_group_name (String.t): The name of the resource group.
- route_filter_name (String.t): The name of the route filter.
- route_filter_parameters (PatchRouteFilter): Parameters supplied to the update route filter operation.
- api_version (String.t): Client API version.
- subscription_id (String.t): The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %Microsoft.Azure.Management.Network.Model.RouteFilter{}} on success
{:error, info} on failure
"""
@spec route_filters_update(Tesla.Env.client, String.t, String.t, Microsoft.Azure.Management.Network.Model.PatchRouteFilter.t, String.t, String.t, keyword()) :: {:ok, Microsoft.Azure.Management.Network.Model.RouteFilter.t} | {:error, Tesla.Env.t}
def route_filters_update(connection, resource_group_name, route_filter_name, route_filter_parameters, api_version, subscription_id, _opts \\ []) do
%{}
|> method(:patch)
|> url("/subscriptions/#{subscription_id}/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/routeFilters/#{route_filter_name}")
|> add_param(:body, :body, route_filter_parameters)
|> add_param(:query, :"api-version", api_version)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%Microsoft.Azure.Management.Network.Model.RouteFilter{})
end
end
| 48.265957 | 252 | 0.734737 |
ff8ccf4b9df7e4ad9be27b18f0f0c4f51e58e23c | 765 | exs | Elixir | config/test.exs | ConnorRigby/noven | 2c34953490585b77b6c7ae8dd772da5028f6a948 | [
"Apache-2.0"
] | 8 | 2020-09-10T09:18:17.000Z | 2022-03-25T03:43:25.000Z | config/test.exs | ConnorRigby/noven | 2c34953490585b77b6c7ae8dd772da5028f6a948 | [
"Apache-2.0"
] | null | null | null | config/test.exs | ConnorRigby/noven | 2c34953490585b77b6c7ae8dd772da5028f6a948 | [
"Apache-2.0"
] | 4 | 2020-12-28T06:13:51.000Z | 2021-04-27T18:00:06.000Z | use Mix.Config
# Only in tests, remove the complexity from the password hashing algorithm
config :bcrypt_elixir, :log_rounds, 1
# Configure your database
#
# The MIX_TEST_PARTITION environment variable can be used
# to provide built-in test partitioning in CI environment.
# Run `mix help test` for more information.
config :noven, Noven.Repo,
username: "postgres",
password: "postgres",
database: "noven_test#{System.get_env("MIX_TEST_PARTITION")}",
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 :noven, NovenWeb.Endpoint,
http: [port: 4002],
server: false
# Print only warnings and errors during test
config :logger, level: :warn
| 29.423077 | 74 | 0.752941 |
ff8d0b304135e0d57e23d3ee21b18198cde93ab8 | 741 | ex | Elixir | apps/mishka_user/lib/core_plugins/login/success_logout.ex | mojtaba-naseri/mishka-cms | 1fb35b49177b9b27f5e68c1b0bf9d72dc0ff9935 | [
"Apache-2.0"
] | null | null | null | apps/mishka_user/lib/core_plugins/login/success_logout.ex | mojtaba-naseri/mishka-cms | 1fb35b49177b9b27f5e68c1b0bf9d72dc0ff9935 | [
"Apache-2.0"
] | null | null | null | apps/mishka_user/lib/core_plugins/login/success_logout.ex | mojtaba-naseri/mishka-cms | 1fb35b49177b9b27f5e68c1b0bf9d72dc0ff9935 | [
"Apache-2.0"
] | null | null | null | defmodule MishkaUser.CorePlugin.Login.SuccessLogout do
alias MishkaInstaller.Reference.OnUserAfterLogout
use MishkaInstaller.Hook,
module: __MODULE__,
behaviour: OnUserAfterLogout,
event: :on_user_after_logout,
initial: []
@spec initial(list()) :: {:ok, OnUserAfterLogout.ref(), list()}
def initial(args) do
event = %PluginState{name: "MishkaUser.CorePlugin.Login.SuccessLogout", event: Atom.to_string(@ref), priority: 1}
Hook.register(event: event)
{:ok, @ref, args}
end
@spec call(OnUserAfterLogout.t()) :: {:reply, OnUserAfterLogout.t()}
def call(%OnUserAfterLogout{} = state) do
MishkaUser.Acl.AclManagement.stop(state.user_id)
{:reply, state}
end
end
| 32.217391 | 119 | 0.68556 |
ff8d102da274d7eb4f5ede6c874e9f59f111c074 | 2,639 | ex | Elixir | lib/charge_sessions.ex | Sebi55/ocpp-backend | e2c4920aa3d2986934a17e904d7836d4f2a91945 | [
"MIT"
] | 11 | 2019-03-06T12:44:46.000Z | 2022-01-20T10:41:30.000Z | lib/charge_sessions.ex | Sebi55/ocpp-backend | e2c4920aa3d2986934a17e904d7836d4f2a91945 | [
"MIT"
] | 3 | 2019-03-06T13:29:36.000Z | 2020-03-21T15:40:47.000Z | lib/charge_sessions.ex | Sebi55/ocpp-backend | e2c4920aa3d2986934a17e904d7836d4f2a91945 | [
"MIT"
] | 4 | 2019-03-06T13:24:13.000Z | 2021-12-22T09:17:56.000Z | defmodule Chargesessions do
use GenServer
use Agent
import Logger
import Ecto.Query, only: [from: 2]
alias Model.Session, as: Session
@moduledoc """
Provides access to charge sessions
"""
def init(args) do
{:ok, args}
end
def start_link(_) do
{:ok, pid} = GenServer.start_link(__MODULE__, %{}, name: __MODULE__)
info "Started #{__MODULE__} #{inspect(pid)}"
{:ok, pid}
end
# Client calls
def all(limit, offset) do
GenServer.call(Chargesessions, {:all, limit, offset})
end
def for_serial(serial, limit, offset) do
GenServer.call(Chargesessions, {:serial, serial, limit, offset})
end
def start(connector_id, serial, id_tag, start_time) do
GenServer.call(Chargesessions, {:start, connector_id, serial, id_tag, start_time})
end
def stop(transaction_id, volume, stop_time) do
GenServer.call(Chargesessions, {:stop, transaction_id, volume, stop_time})
end
# callbacks
def handle_call({:start, connector_id, serial, id_tag, start_time}, _from, state) do
session = %Session{connector_id: connector_id |> Integer.to_string, serial: serial, token: id_tag, start_time: start_time}
{:ok, inserted} = OcppBackendRepo.insert(session)
{:reply, {:ok, inserted.id |> Integer.to_string}, state}
end
def handle_call({:stop, transaction_id, volume, end_time}, _from, state) do
session = get_session(transaction_id)
info inspect(session)
duration = Timex.diff(end_time, session.start_time, :minutes)
{:ok, updated} = update(transaction_id, %{stop_time: end_time, duration: duration, volume: volume})
{:reply, {:ok, updated}, state}
end
def handle_call({:all, limit, offset}, _from, state) do
sessions = OcppBackendRepo.all(
from s in Session,
order_by: [desc: s.start_time],
limit: ^limit,
offset: ^offset
)
{:reply, {:ok, sessions}, state}
end
def handle_call({:serial, serial, limit, offset}, _from, state) do
sessions = OcppBackendRepo.all(
from s in Session,
where: s.serial == ^serial,
order_by: [desc: s.start_time],
limit: ^limit,
offset: ^offset
)
{:reply, {:ok, sessions}, state}
end
def get_session(transaction_id) do
sessions = OcppBackendRepo.all(
from s in Session,
where: s.id == ^transaction_id and is_nil(s.stop_time),
limit: 1
)
sessions |> List.first
end
defp update(transaction_id, changes) do
session = get_session(transaction_id)
changeset = Session.changeset(session, changes)
OcppBackendRepo.update(changeset)
end
end
| 28.074468 | 126 | 0.661993 |
ff8d165bc9d9252f0242456cd914aa8cab7b9150 | 375 | exs | Elixir | apps/faqcheck/priv/repo/migrations/20210824003239_create_user_identities.exs | csboling/faqcheck | bc182c365d466c8dcacc6b1a5fe9186a2c912cd4 | [
"CC0-1.0"
] | null | null | null | apps/faqcheck/priv/repo/migrations/20210824003239_create_user_identities.exs | csboling/faqcheck | bc182c365d466c8dcacc6b1a5fe9186a2c912cd4 | [
"CC0-1.0"
] | 20 | 2021-09-08T04:07:31.000Z | 2022-03-10T21:52:24.000Z | apps/faqcheck/priv/repo/migrations/20210824003239_create_user_identities.exs | csboling/faqcheck | bc182c365d466c8dcacc6b1a5fe9186a2c912cd4 | [
"CC0-1.0"
] | null | null | null | defmodule Faqcheck.Repo.Migrations.CreateUserIdentities do
use Ecto.Migration
def change do
create table(:user_identities) do
add :provider, :string, null: false
add :uid, :string, null: false
add :user_id, references("users", on_delete: :nothing)
timestamps()
end
create unique_index(:user_identities, [:uid, :provider])
end
end
| 23.4375 | 60 | 0.690667 |
ff8d4eae3bd81799fe1f501ea8b5fefa9d726bcc | 1,888 | ex | Elixir | clients/manufacturers/lib/google_api/manufacturers/v1/model/product_detail.ex | matehat/elixir-google-api | c1b2523c2c4cdc9e6ca4653ac078c94796b393c3 | [
"Apache-2.0"
] | 1 | 2018-12-03T23:43:10.000Z | 2018-12-03T23:43:10.000Z | clients/manufacturers/lib/google_api/manufacturers/v1/model/product_detail.ex | matehat/elixir-google-api | c1b2523c2c4cdc9e6ca4653ac078c94796b393c3 | [
"Apache-2.0"
] | null | null | null | clients/manufacturers/lib/google_api/manufacturers/v1/model/product_detail.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.Manufacturers.V1.Model.ProductDetail do
@moduledoc """
A product detail of the product. For more information, see
https://support.google.com/manufacturers/answer/6124116#productdetail.
## Attributes
* `attributeName` (*type:* `String.t`, *default:* `nil`) - The name of the attribute.
* `attributeValue` (*type:* `String.t`, *default:* `nil`) - The value of the attribute.
* `sectionName` (*type:* `String.t`, *default:* `nil`) - A short section name that can be reused between multiple product details.
"""
use GoogleApi.Gax.ModelBase
@type t :: %__MODULE__{
:attributeName => String.t(),
:attributeValue => String.t(),
:sectionName => String.t()
}
field(:attributeName)
field(:attributeValue)
field(:sectionName)
end
defimpl Poison.Decoder, for: GoogleApi.Manufacturers.V1.Model.ProductDetail do
def decode(value, options) do
GoogleApi.Manufacturers.V1.Model.ProductDetail.decode(value, options)
end
end
defimpl Poison.Encoder, for: GoogleApi.Manufacturers.V1.Model.ProductDetail do
def encode(value, options) do
GoogleApi.Gax.ModelBase.encode(value, options)
end
end
| 34.962963 | 134 | 0.724047 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.