hexsha
stringlengths
40
40
size
int64
2
991k
ext
stringclasses
2 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
208
max_stars_repo_name
stringlengths
6
106
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
sequence
max_stars_count
int64
1
33.5k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
208
max_issues_repo_name
stringlengths
6
106
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
sequence
max_issues_count
int64
1
16.3k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
208
max_forks_repo_name
stringlengths
6
106
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
sequence
max_forks_count
int64
1
6.91k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
2
991k
avg_line_length
float64
1
36k
max_line_length
int64
1
977k
alphanum_fraction
float64
0
1
79ccb486776744e7c3ce917b91693b8216a77379
504
exs
Elixir
test/test_helper.exs
mark-d-holmberg/phoenix-active-link
ffc9131f28020e3abec03a4dff017667f833cc86
[ "MIT" ]
43
2016-04-16T10:36:04.000Z
2018-09-19T05:12:49.000Z
test/test_helper.exs
mark-d-holmberg/phoenix-active-link
ffc9131f28020e3abec03a4dff017667f833cc86
[ "MIT" ]
10
2019-02-14T09:19:19.000Z
2021-12-28T14:57:32.000Z
test/test_helper.exs
mark-d-holmberg/phoenix-active-link
ffc9131f28020e3abec03a4dff017667f833cc86
[ "MIT" ]
15
2019-03-19T18:27:47.000Z
2021-11-13T08:33:27.000Z
ExUnit.start() defmodule TestHelpers do def conn(opts \\ []) do %Plug.Conn{} |> Map.put(:private, make_private(opts)) |> Map.put(:request_path, opts[:path]) |> Map.put(:query_string, opts[:query_string] || "") end defp make_private(opts) do cond do opts[:controller] -> %{phoenix_controller: opts[:controller], phoenix_action: opts[:action]} opts[:live_view] -> %{phoenix_live_view: {opts[:live_view], [action: opts[:action]]}} true -> %{} end end end
26.526316
98
0.626984
79ccd3ee8651d51b7b3e6a6c0ae15f37954bcf6c
2,235
ex
Elixir
clients/dlp/lib/google_api/dlp/v2/model/google_privacy_dlp_v2_bucket.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/dlp/lib/google_api/dlp/v2/model/google_privacy_dlp_v2_bucket.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/dlp/lib/google_api/dlp/v2/model/google_privacy_dlp_v2_bucket.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
1
2020-11-10T16:58:27.000Z
2020-11-10T16:58:27.000Z
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "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.DLP.V2.Model.GooglePrivacyDlpV2Bucket do @moduledoc """ Bucket is represented as a range, along with replacement values. ## Attributes - max (GooglePrivacyDlpV2Value): Upper bound of the range, exclusive; type must match min. Defaults to: `null`. - min (GooglePrivacyDlpV2Value): Lower bound of the range, inclusive. Type should be the same as max if used. Defaults to: `null`. - replacementValue (GooglePrivacyDlpV2Value): Replacement value for this bucket. If not provided the default behavior will be to hyphenate the min-max range. Defaults to: `null`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :max => GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2Value.t(), :min => GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2Value.t(), :replacementValue => GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2Value.t() } field(:max, as: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2Value) field(:min, as: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2Value) field(:replacementValue, as: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2Value) end defimpl Poison.Decoder, for: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2Bucket do def decode(value, options) do GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2Bucket.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2Bucket do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
41.388889
180
0.756152
79ccd86e15a7b902656978d185febf9242cfce2a
629
ex
Elixir
resistor-color/lib/resistor_color.ex
okaram/exercism-elixir
66429a50738a16da5d352ad4455a483622625949
[ "Unlicense" ]
null
null
null
resistor-color/lib/resistor_color.ex
okaram/exercism-elixir
66429a50738a16da5d352ad4455a483622625949
[ "Unlicense" ]
null
null
null
resistor-color/lib/resistor_color.ex
okaram/exercism-elixir
66429a50738a16da5d352ad4455a483622625949
[ "Unlicense" ]
null
null
null
defmodule ResistorColor do @doc """ Return the value of a color band """ @spec code(atom) :: integer() def code(:black) do 0 end def code(:brown) do 1 end def code(:red) do 2 end def code(:orange) do 3 end def code(:yellow) do 4 end def code(:green) do 5 end def code(:blue) do 6 end def code(:violet) do 7 end def code(:grey) do 8 end def code(:white) do 9 end def code1(color) do case color do :black -> 0 :brown -> 1 :red -> 2 :orange -> 3 :yellow -> 4 :green -> 5 :blue -> 6 :violet -> 7 :grey -> 8 :white -> 9 end end end
19.65625
34
0.54849
79ccd9553d19e48ba4b280b223f170fce4b6778f
18,909
ex
Elixir
clients/cloud_debugger/lib/google_api/cloud_debugger/v2/api/debugger.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/cloud_debugger/lib/google_api/cloud_debugger/v2/api/debugger.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/cloud_debugger/lib/google_api/cloud_debugger/v2/api/debugger.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.CloudDebugger.V2.Api.Debugger do @moduledoc """ API calls for all endpoints tagged `Debugger`. """ alias GoogleApi.CloudDebugger.V2.Connection alias GoogleApi.Gax.{Request, Response} @library_version Mix.Project.config() |> Keyword.get(:version, "") @doc """ Lists all the debuggees that the user has access to. ## Parameters * `connection` (*type:* `GoogleApi.CloudDebugger.V2.Connection.t`) - Connection to server * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:clientVersion` (*type:* `String.t`) - Required. The client version making the call. Schema: `domain/type/version` (e.g., `google.com/intellij/v1`). * `:includeInactive` (*type:* `boolean()`) - When set to `true`, the result includes all debuggees. Otherwise, the result includes only debuggees that are active. * `:project` (*type:* `String.t`) - Required. Project number of a Google Cloud project whose debuggees to list. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.CloudDebugger.V2.Model.ListDebuggeesResponse{}}` on success * `{:error, info}` on failure """ @spec clouddebugger_debugger_debuggees_list(Tesla.Env.client(), keyword(), keyword()) :: {:ok, GoogleApi.CloudDebugger.V2.Model.ListDebuggeesResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def clouddebugger_debugger_debuggees_list(connection, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :clientVersion => :query, :includeInactive => :query, :project => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v2/debugger/debuggees", %{}) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.CloudDebugger.V2.Model.ListDebuggeesResponse{}] ) end @doc """ Deletes the breakpoint from the debuggee. ## Parameters * `connection` (*type:* `GoogleApi.CloudDebugger.V2.Connection.t`) - Connection to server * `debuggee_id` (*type:* `String.t`) - Required. ID of the debuggee whose breakpoint to delete. * `breakpoint_id` (*type:* `String.t`) - Required. ID of the breakpoint to delete. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:clientVersion` (*type:* `String.t`) - Required. The client version making the call. Schema: `domain/type/version` (e.g., `google.com/intellij/v1`). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.CloudDebugger.V2.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec clouddebugger_debugger_debuggees_breakpoints_delete( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.CloudDebugger.V2.Model.Empty.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def clouddebugger_debugger_debuggees_breakpoints_delete( connection, debuggee_id, breakpoint_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :clientVersion => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v2/debugger/debuggees/{debuggeeId}/breakpoints/{breakpointId}", %{ "debuggeeId" => URI.encode(debuggee_id, &URI.char_unreserved?/1), "breakpointId" => URI.encode(breakpoint_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.CloudDebugger.V2.Model.Empty{}]) end @doc """ Gets breakpoint information. ## Parameters * `connection` (*type:* `GoogleApi.CloudDebugger.V2.Connection.t`) - Connection to server * `debuggee_id` (*type:* `String.t`) - Required. ID of the debuggee whose breakpoint to get. * `breakpoint_id` (*type:* `String.t`) - Required. ID of the breakpoint 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"). * `:clientVersion` (*type:* `String.t`) - Required. The client version making the call. Schema: `domain/type/version` (e.g., `google.com/intellij/v1`). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.CloudDebugger.V2.Model.GetBreakpointResponse{}}` on success * `{:error, info}` on failure """ @spec clouddebugger_debugger_debuggees_breakpoints_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.CloudDebugger.V2.Model.GetBreakpointResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def clouddebugger_debugger_debuggees_breakpoints_get( connection, debuggee_id, breakpoint_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :clientVersion => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v2/debugger/debuggees/{debuggeeId}/breakpoints/{breakpointId}", %{ "debuggeeId" => URI.encode(debuggee_id, &URI.char_unreserved?/1), "breakpointId" => URI.encode(breakpoint_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.CloudDebugger.V2.Model.GetBreakpointResponse{}] ) end @doc """ Lists all breakpoints for the debuggee. ## Parameters * `connection` (*type:* `GoogleApi.CloudDebugger.V2.Connection.t`) - Connection to server * `debuggee_id` (*type:* `String.t`) - Required. ID of the debuggee whose breakpoints to list. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `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.value"` (*type:* `String.t`) - Only breakpoints with the specified action will pass the filter. * `:clientVersion` (*type:* `String.t`) - Required. The client version making the call. Schema: `domain/type/version` (e.g., `google.com/intellij/v1`). * `:includeAllUsers` (*type:* `boolean()`) - When set to `true`, the response includes the list of breakpoints set by any user. Otherwise, it includes only breakpoints set by the caller. * `:includeInactive` (*type:* `boolean()`) - When set to `true`, the response includes active and inactive breakpoints. Otherwise, it includes only active breakpoints. * `:stripResults` (*type:* `boolean()`) - This field is deprecated. The following fields are always stripped out of the result: `stack_frames`, `evaluated_expressions` and `variable_table`. * `:waitToken` (*type:* `String.t`) - A wait token that, if specified, blocks the call until the breakpoints list has changed, or a server selected timeout has expired. The value should be set from the last response. The error code `google.rpc.Code.ABORTED` (RPC) is returned on wait timeout, which should be called again with the same `wait_token`. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.CloudDebugger.V2.Model.ListBreakpointsResponse{}}` on success * `{:error, info}` on failure """ @spec clouddebugger_debugger_debuggees_breakpoints_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.CloudDebugger.V2.Model.ListBreakpointsResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def clouddebugger_debugger_debuggees_breakpoints_list( connection, debuggee_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :"action.value" => :query, :clientVersion => :query, :includeAllUsers => :query, :includeInactive => :query, :stripResults => :query, :waitToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v2/debugger/debuggees/{debuggeeId}/breakpoints", %{ "debuggeeId" => URI.encode(debuggee_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.CloudDebugger.V2.Model.ListBreakpointsResponse{}] ) end @doc """ Sets the breakpoint to the debuggee. ## Parameters * `connection` (*type:* `GoogleApi.CloudDebugger.V2.Connection.t`) - Connection to server * `debuggee_id` (*type:* `String.t`) - Required. ID of the debuggee where the breakpoint is to be set. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:canaryOption` (*type:* `String.t`) - The canary option set by the user upon setting breakpoint. * `:clientVersion` (*type:* `String.t`) - Required. The client version making the call. Schema: `domain/type/version` (e.g., `google.com/intellij/v1`). * `:body` (*type:* `GoogleApi.CloudDebugger.V2.Model.Breakpoint.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.CloudDebugger.V2.Model.SetBreakpointResponse{}}` on success * `{:error, info}` on failure """ @spec clouddebugger_debugger_debuggees_breakpoints_set( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.CloudDebugger.V2.Model.SetBreakpointResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def clouddebugger_debugger_debuggees_breakpoints_set( connection, debuggee_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :canaryOption => :query, :clientVersion => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v2/debugger/debuggees/{debuggeeId}/breakpoints/set", %{ "debuggeeId" => URI.encode(debuggee_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.CloudDebugger.V2.Model.SetBreakpointResponse{}] ) end end
46.232274
357
0.622455
79cce516ebb3c55eba088489e7487789f7423a55
1,242
exs
Elixir
test/particle/functions_test.exs
tompesman/particle-elixir
90226405b868f8e8ff308c84c34e88ea68a8570a
[ "MIT" ]
null
null
null
test/particle/functions_test.exs
tompesman/particle-elixir
90226405b868f8e8ff308c84c34e88ea68a8570a
[ "MIT" ]
null
null
null
test/particle/functions_test.exs
tompesman/particle-elixir
90226405b868f8e8ff308c84c34e88ea68a8570a
[ "MIT" ]
null
null
null
require IEx defmodule Particle.FunctionsTest do use ExUnit.Case use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney setup_all do ExVCR.Config.cassette_library_dir("fixture/vcr_cassettes/particle/functions") ExVCR.Config.filter_sensitive_data("Bearer .+", "TOKEN") ExVCR.Config.filter_sensitive_data("(.*)" <> (System.get_env("device_id") || "DEVICE_ID") <> "(.*)", "\\1DEVICE_ID\\2") ExVCR.Config.filter_sensitive_data("(?:\\d{1,3}\\.){3}\\d{1,3}", "0.0.0.0") :ok end describe "post with a valid function" do test "it returns the value of the function call" do use_cassette "post" do device_id = System.get_env("device_id") || "DEVICE_ID" response = Particle.Functions.post(device_id, "power", "off") assert {:ok, r} = response assert r.return_value == 1 end end end describe "post with an invalid function" do test "it returns an error tuple" do use_cassette "missing_function" do device_id = System.get_env("device_id") || "DEVICE_ID" response = Particle.Functions.post(device_id, "MISSING", "off") assert response == {:error, %Particle.Error{reason: "Function MISSING not found", code: 404}} end end end end
34.5
123
0.65942
79cce8c912b0b465f20ad69acbea849d711df27d
2,601
exs
Elixir
mix.exs
GregMefford/nerves_system_rpi0_zbar
03e8e1a918309b60e25d149daeda88a2f995e1be
[ "Apache-2.0" ]
null
null
null
mix.exs
GregMefford/nerves_system_rpi0_zbar
03e8e1a918309b60e25d149daeda88a2f995e1be
[ "Apache-2.0" ]
null
null
null
mix.exs
GregMefford/nerves_system_rpi0_zbar
03e8e1a918309b60e25d149daeda88a2f995e1be
[ "Apache-2.0" ]
1
2018-09-04T23:53:58.000Z
2018-09-04T23:53:58.000Z
defmodule NervesSystemRpi0Zbar.MixProject do use Mix.Project @app :nerves_system_rpi0_zbar @version Path.join(__DIR__, "VERSION") |> File.read!() |> String.trim() def project do [ app: @app, version: @version, elixir: "~> 1.6", compilers: Mix.compilers() ++ [:nerves_package], nerves_package: nerves_package(), description: description(), package: package(), deps: deps(), aliases: [loadconfig: [&bootstrap/1], docs: ["docs", &copy_images/1]], docs: [extras: ["README.md"], main: "readme"] ] end def application do [] end defp bootstrap(args) do set_target() Application.start(:nerves_bootstrap) Mix.Task.run("loadconfig", args) end defp nerves_package do [ type: :system, artifact_sites: [ {:github_releases, "gregmefford/#{@app}"} ], build_runner_opts: build_runner_opts(), platform: Nerves.System.BR, platform_config: [ defconfig: "nerves_defconfig" ], checksum: package_files() ] end defp deps do [ {:nerves, "~> 1.5.0", runtime: false}, {:nerves_system_br, "1.8.5", runtime: false}, {:nerves_toolchain_armv6_rpi_linux_gnueabi, "1.2.0", runtime: false}, {:nerves_system_linter, "~> 0.3.0", runtime: false}, {:ex_doc, "~> 0.18", only: [:dev, :test], runtime: false} ] end defp description do """ Nerves System - Raspberry Pi Zero and Zero W with Zbar (barcode tools) """ end defp package do [ files: package_files(), licenses: ["Apache 2.0"], links: %{"Github" => "https://github.com/gregmefford/#{@app}"} ] end defp package_files do [ "fwup_include", "rootfs_overlay", "CHANGELOG.md", "cmdline.txt", "config.txt", "fwup-revert.conf", "fwup.conf", "LICENSE", "linux-4.19.defconfig", "mix.exs", "nerves_defconfig", "post-build.sh", "post-createfs.sh", "ramoops.dts", "README.md", "VERSION" ] end # Copy the images referenced by docs, since ex_doc doesn't do this. defp copy_images(_) do File.cp_r("assets", "doc/assets") end defp build_runner_opts() do if primary_site = System.get_env("BR2_PRIMARY_SITE") do [make_args: ["BR2_PRIMARY_SITE=#{primary_site}"]] else [] end end defp set_target() do if function_exported?(Mix, :target, 1) do apply(Mix, :target, [:target]) else System.put_env("MIX_TARGET", "target") end end end
22.617391
76
0.584006
79cd0b1f8b28548acfa130ddffcdc33ffc5209b5
498
ex
Elixir
apps/rayyan_site/lib/rayyan_site_web/views/error_view.ex
boqolo/boqolo
ba9a2ebcf379f5056b3836756179b49163f91d72
[ "BSD-3-Clause" ]
null
null
null
apps/rayyan_site/lib/rayyan_site_web/views/error_view.ex
boqolo/boqolo
ba9a2ebcf379f5056b3836756179b49163f91d72
[ "BSD-3-Clause" ]
null
null
null
apps/rayyan_site/lib/rayyan_site_web/views/error_view.ex
boqolo/boqolo
ba9a2ebcf379f5056b3836756179b49163f91d72
[ "BSD-3-Clause" ]
null
null
null
defmodule RayyanSiteWeb.ErrorView do use RayyanSiteWeb, :view # If you want to customize a particular status code # for a certain format, you may uncomment below. # def render("500.html", _assigns) do # "Internal Server Error" # end # By default, Phoenix returns the status message from # the template name. For example, "404.html" becomes # "Not Found". def template_not_found(template, _assigns) do Phoenix.Controller.status_message_from_template(template) end end
27.666667
61
0.736948
79cd37dde95b83d96d87148bdf9546ef9336cfc7
1,538
ex
Elixir
test/support/data_case.ex
joseluis8906/platform
f1b4c49b5de60dd880f0075ec3020aef03c557af
[ "Apache-2.0" ]
null
null
null
test/support/data_case.ex
joseluis8906/platform
f1b4c49b5de60dd880f0075ec3020aef03c557af
[ "Apache-2.0" ]
1
2021-05-11T14:48:01.000Z
2021-05-11T14:48:01.000Z
test/support/data_case.ex
joseluis8906/platform
f1b4c49b5de60dd880f0075ec3020aef03c557af
[ "Apache-2.0" ]
null
null
null
defmodule Platform.DataCase do @moduledoc """ This module defines the setup for tests requiring access to the application's data layer. You may define functions here to be used as helpers in your tests. Finally, if the test case interacts with the database, we enable the SQL sandbox, so changes done to the database are reverted at the end of every test. If you are using PostgreSQL, you can even run database tests asynchronously by setting `use Platform.DataCase, async: true`, although this option is not recommended for other databases. """ use ExUnit.CaseTemplate using do quote do alias Platform.Repo import Ecto import Ecto.Changeset import Ecto.Query import Platform.DataCase end end setup tags do :ok = Ecto.Adapters.SQL.Sandbox.checkout(Platform.Repo) unless tags[:async] do Ecto.Adapters.SQL.Sandbox.mode(Platform.Repo, {:shared, self()}) end :ok end @doc """ A helper that transforms changeset errors into a map of messages. assert {:error, changeset} = Accounts.create_user(%{password: "short"}) assert "password is too short" in errors_on(changeset).password assert %{password: ["password is too short"]} = errors_on(changeset) """ def errors_on(changeset) do Ecto.Changeset.traverse_errors(changeset, fn {message, opts} -> Regex.replace(~r"%{(\w+)}", message, fn _, key -> opts |> Keyword.get(String.to_existing_atom(key), key) |> to_string() end) end) end end
27.464286
77
0.689857
79cd5cd883ada4a93fe2538b2b0a613115645c4b
14,795
ex
Elixir
lib/kino/control.ex
cristineguadelupe/kino
65348f632c5753d543cd16ff1357d06808b6a4a3
[ "Apache-2.0" ]
null
null
null
lib/kino/control.ex
cristineguadelupe/kino
65348f632c5753d543cd16ff1357d06808b6a4a3
[ "Apache-2.0" ]
null
null
null
lib/kino/control.ex
cristineguadelupe/kino
65348f632c5753d543cd16ff1357d06808b6a4a3
[ "Apache-2.0" ]
null
null
null
defmodule Kino.Control do @moduledoc """ Various widgets for user interactions. Each widget is a UI control element that the user interacts with, consequently producing an event stream. Those widgets are often useful paired with `Kino.Frame` for presenting content that changes upon user interactions. ## Examples First, create a control and make sure it is rendered, either by placing it at the end of a code cell or by explicitly rendering it with `Kino.render/1`. button = Kino.Control.button("Hello") Next, to receive events from the control, a process needs to subscribe to it and specify pick a name to distinguish the events. Kino.Control.subscribe(button, :hello) As the user interacts with the button, the subscribed process receives corresponding events. IEx.Helpers.flush() #=> {:hello, %{origin: #PID<10895.9854.0>}} #=> {:hello, %{origin: #PID<10895.9854.0>}} """ defstruct [:attrs] @opaque t :: %__MODULE__{attrs: Kino.Output.control_attrs()} @opaque interval :: {:interval, milliseconds :: non_neg_integer()} @type event_source :: t() | Kino.Input.t() | interval() defp new(attrs) do ref = Kino.Output.random_ref() subscription_manager = Kino.SubscriptionManager.cross_node_name() attrs = Map.merge(attrs, %{ref: ref, destination: subscription_manager}) Kino.Bridge.reference_object(ref, self()) Kino.Bridge.monitor_object(ref, subscription_manager, {:clear_topic, ref}) %__MODULE__{attrs: attrs} end @doc """ Creates a new button. """ @spec button(String.t()) :: t() def button(label) when is_binary(label) do new(%{type: :button, label: label}) end @doc """ Creates a new keyboard control. This widget is represented as button that toggles interception mode, in which the given keyboard events are captured. ## Event info In addition to standard properties, all events include additional properties. ### Key events * `:type` - either `:keyup` or `:keydown` * `:key` - the value matching the browser [KeyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) ### Status event * `:type` - either `:status` * `:enabled` - whether the keyboard is activated ## Examples Create the widget: keyboard = Kino.Control.keyboard([:keyup, :keydown, :status]) Subscribe to events: Kino.Control.subscribe(keyboard, :keyboard) As the user types events are streamed: IEx.Helpers.flush() #=> {:keyboard, %{enabled: true, origin: #PID<10895.9854.0>, type: :status} #=> {:keyboard, %{key: "o", origin: #PID<10895.9854.0>, type: :keydown}} #=> {:keyboard, %{key: "k", origin: #PID<10895.9854.0>, type: :keydown}} #=> {:keyboard, %{key: "o", origin: #PID<10895.9854.0>, type: :keyup}} #=> {:keyboard, %{key: "k", origin: #PID<10895.9854.0>, type: :keyup}} """ @spec keyboard(list(:keyup | :keydown | :status)) :: t() def keyboard(events) when is_list(events) do if events == [] do raise ArgumentError, "expected at least one event, got: []" end for event <- events do unless event in [:keyup, :keydown, :status] do raise ArgumentError, "expected event to be either :keyup, :keydown or :status, got: #{inspect(event)}" end end new(%{type: :keyboard, events: events}) end @doc """ Creates a new form. A form is composed of regular inputs from the `Kino.Input` module, however in a form input values are not synchronized between users. Consequently, the form is another control for producing user-specific events. Either `:submit` or `:report_changes` must be specified. ## Options * `:submit` - specifies the label to use for the submit button and enables submit events * `:report_changes` - whether to send new form value whenever any of the input changes. Defaults to `false` * `:reset_on_submit` - a list of fields to revert to their default values once the form is submitted. Use `true` to indicate all fields. Defaults to `[]` ## Event info In addition to standard properties, all events include additional properties. * `:type` - either `:submit` or `:change` * `:data` - a map with field values, matching the field list ## Examples Create a form out of inputs: form = Kino.Control.form( [ name: Kino.Input.text("Name"), message: Kino.Input.textarea("Message") ], submit: "Send" ) Subscribe to events: Kino.Control.subscribe(form, :chat_form) As users submit the form the payload is sent: IEx.Helpers.flush() #=> {:chat_form, #=> %{ #=> data: %{message: "Hola", name: "Amy"}, #=> origin: #PID<10905.5195.0>, #=> type: :submit #=> }} #=> {:chat_form, #=> %{ #=> data: %{message: "Hey!", name: "Jake"}, #=> origin: #PID<10905.5186.0>, #=> type: :submit #=> }} """ @spec form(list({atom(), Kino.Input.t()}), keyword()) :: t() def form(fields, opts \\ []) when is_list(fields) do if fields == [] do raise ArgumentError, "expected at least one field, got: []" end for {field, input} <- fields do unless is_atom(field) do raise ArgumentError, "expected each field key to be an atom, got: #{inspect(field)}" end unless is_struct(input, Kino.Input) do raise ArgumentError, "expected each field to be a Kino.Input widget, got: #{inspect(input)} for #{inspect(field)}" end end unless opts[:submit] || opts[:report_changes] do raise ArgumentError, "expected either :submit or :report_changes option to be enabled" end fields = Enum.map(fields, fn {field, input} -> # Make sure we use this input only in the form and nowhere else input = Kino.Input.duplicate(input) {field, input.attrs} end) submit = Keyword.get(opts, :submit, nil) report_changes = if Keyword.get(opts, :report_changes, false) do Map.new(fields, fn {field, _} -> {field, true} end) else %{} end reset_on_submit = case Keyword.get(opts, :reset_on_submit, []) do true -> Keyword.keys(fields) false -> [] fields -> fields end new(%{ type: :form, fields: fields, submit: submit, report_changes: report_changes, reset_on_submit: reset_on_submit }) end @doc """ Subscribes the calling process to control or input events. The events are sent as `{tag, info}`, where info is a map with event details. In particular, it always includes `:origin`, which is an opaque identifier of the client that triggered the event. """ @spec subscribe(t() | Kino.Input.t(), term()) :: :ok def subscribe(source, tag) when is_struct(source, Kino.Control) or is_struct(source, Kino.Input) do Kino.SubscriptionManager.subscribe(source.attrs.ref, self(), tag) end @doc """ Unsubscribes the calling process from control or input events. """ @spec unsubscribe(t() | Kino.Input.t()) :: :ok def unsubscribe(source) when is_struct(source, Kino.Control) or is_struct(source, Kino.Input) do Kino.SubscriptionManager.unsubscribe(source.attrs.ref, self()) end @doc """ Returns a new interval event source. This can be used as event source for `stream/1` and `tagged_stream/1`. The events are emitted periodically with an increasing value, starting from 0 and have the form: %{type: :interval, iteration: non_neg_integer()} """ @spec interval(non_neg_integer()) :: interval() def interval(milliseconds) when is_number(milliseconds) and milliseconds > 0 do {:interval, milliseconds} end @doc """ Returns a `Stream` of control events. This is an alternative API to `subscribe/2`, such that event messages are consume via stream instead of process messages. It accepts a single source or a list of sources, where each source is either of: * `Kino.Control` - emitting value on relevant interaction * `Kino.Input` - emitting value on value change ## Example button = Kino.Control.button("Hello") for event <- Kino.Control.stream(button) do IO.inspect(event) end #=> %{origin: #PID<10895.9854.0>, type: :click} #=> %{origin: #PID<10895.9854.0>, type: :click} Or with multiple sources: button = Kino.Control.button("Hello") input = Kino.Input.checkbox("Check") interval = Kino.Control.interval(1000) for event <- Kino.Control.stream([button, input, interval]) do IO.inspect(event) end #=> %{type: :interval, iteration: 0} #=> %{origin: #PID<10895.9854.0>, type: :click} #=> %{origin: #PID<10895.9854.0>, type: :change, value: true} """ @spec stream(event_source() | list(event_source())) :: Enumerable.t() def stream(source) def stream(sources) when is_list(sources) do for source <- sources, do: assert_stream_source!(source) tagged_topics = for %{attrs: %{ref: ref}} <- sources, do: {nil, ref} tagged_intervals = for {:interval, ms} <- sources, do: {nil, ms} build_stream(tagged_topics, tagged_intervals, fn nil, event -> event end) end def stream(source) do stream([source]) end @doc """ Subscribes the given function to events from one or more event sources. The given function runs asynchronously. See `stream/1` for more details on event sources. ## Examples button = Kino.Control.button("Greet") Kino.Control.stream(button, fn _event -> IO.puts("Hello!") end) """ @spec stream(event_source() | list(event_source()), (term() -> any())) :: :ok def stream(source, fun) when is_function(fun, 1) do async(fn -> source |> stream() |> Enum.each(fun) end) end @doc ~S""" A stateful version of `stream/1`. ## Examples button = Kino.Control.button("Greet") Kino.Control.stream(button, 0, fn _event, counter -> new_counter = counter + 1 IO.puts("clicks: #{new_counter}") new_counter end) """ @spec stream(event_source() | list(event_source()), state, (term(), state -> state)) :: :ok when state: term() def stream(source, state, fun) when is_function(fun, 2) do async(fn -> source |> stream() |> Enum.reduce(state, fun) end) end defp async(fun) do Kino.start_child({Task, fun}) :ok end @doc """ Same as `stream/1`, but attaches custom tag to every stream item. ## Example button = Kino.Control.button("Hello") input = Kino.Input.checkbox("Check") for event <- Kino.Control.tagged_stream([hello: button, check: input]) do IO.inspect(event) end #=> {:hello, %{origin: #PID<10895.9854.0>, type: :click}} #=> {:check, %{origin: #PID<10895.9854.0>, type: :change, value: true}} """ @spec tagged_stream(list({atom(), event_source()})) :: Enumerable.t() def tagged_stream(entries) when is_list(entries) do for entry <- entries do case entry do {tag, source} when is_atom(tag) -> assert_stream_source!(source) _other -> raise ArgumentError, "expected a keyword list, got: #{inspect(entries)}" end end tagged_topics = for {tag, %{attrs: %{ref: ref}}} <- entries, do: {tag, ref} tagged_intervals = for {tag, {:interval, ms}} <- entries, do: {tag, ms} build_stream(tagged_topics, tagged_intervals, fn tag, event -> {tag, event} end) end @doc """ Same as `stream/2`, but attaches custom tag to every event. ## Example button = Kino.Control.button("Hello") input = Kino.Input.checkbox("Check") Kino.Control.tagged_stream([hello: button, check: input], fn {:hello, event} -> ... {:check, event} -> ... end) """ @spec tagged_stream(list({tag, event_source()}), ({tag, term()} -> any())) :: :ok when tag: atom() def tagged_stream(entries, fun) when is_list(entries) and is_function(fun, 1) do async(fn -> entries |> tagged_stream() |> Enum.each(fun) end) end @doc ~S""" A stateful version of `tagged_stream/2`. ## Example up = Kino.Control.button("Up") |> Kino.render() down = Kino.Control.button("Down") |> Kino.render() Kino.Control.tagged_stream([up: up, down: down], 0, fn {:up, _event}, counter -> new_counter = counter + 1 IO.puts("counter: #{new_counter}") new_counter {:down, _event}, counter -> new_counter = counter - 1 IO.puts("counter: #{new_counter}") new_counter end) """ @spec tagged_stream(list({tag, event_source()}), state, ({tag, term()}, state -> state)) :: :ok when tag: atom(), state: term() def tagged_stream(entries, state, fun) when is_list(entries) and is_function(fun, 2) do async(fn -> entries |> tagged_stream() |> Enum.reduce(state, fun) end) end defp assert_stream_source!(%Kino.Control{}), do: :ok defp assert_stream_source!(%Kino.Input{}), do: :ok defp assert_stream_source!({:interval, ms}) when is_number(ms) and ms > 0, do: :ok defp assert_stream_source!(item) do raise ArgumentError, "expected source to be either %Kino.Control{}, %Kino.Input{} or {:interval, ms}, got: #{inspect(item)}" end defp build_stream(tagged_topics, tagged_intervals, mapper) do Stream.resource( fn -> ref = make_ref() for {tag, topic} <- tagged_topics do Kino.SubscriptionManager.subscribe(topic, self(), {ref, tag}, notify_clear: true) end for {tag, ms} <- tagged_intervals do Process.send_after(self(), {{ref, tag}, :__interval__, ms, 0}, ms) end topics = Enum.map(tagged_topics, &elem(&1, 1)) {ref, topics} end, fn {ref, topics} -> receive do {{^ref, tag}, event} -> {[mapper.(tag, event)], {ref, topics}} {{^ref, _tag}, :topic_cleared, topic} -> case topics -- [topic] do [] -> {:halt, {ref, []}} topics -> {[], {ref, topics}} end {{^ref, tag}, :__interval__, ms, i} -> Process.send_after(self(), {{ref, tag}, :__interval__, ms, i + 1}, ms) event = %{type: :interval, iteration: i} {[mapper.(tag, event)], {ref, topics}} end end, fn {_ref, topics} -> for topic <- topics do Kino.SubscriptionManager.unsubscribe(topic, self()) end end ) end end
28.784047
133
0.614059
79cd6f80c12f0dc49f3294f020ea2d3612b07db3
533
ex
Elixir
lib/flicks_web/views/error_view.ex
KTSCode/flicks-backend
e484b7a69cf24d7e474373c1ad627a3a4eaddbc6
[ "MIT" ]
null
null
null
lib/flicks_web/views/error_view.ex
KTSCode/flicks-backend
e484b7a69cf24d7e474373c1ad627a3a4eaddbc6
[ "MIT" ]
null
null
null
lib/flicks_web/views/error_view.ex
KTSCode/flicks-backend
e484b7a69cf24d7e474373c1ad627a3a4eaddbc6
[ "MIT" ]
null
null
null
defmodule FlicksWeb.ErrorView do use FlicksWeb, :view # If you want to customize a particular status code # for a certain format, you may uncomment below. # def render("500.json", _assigns) do # %{errors: %{detail: "Internal Server Error"}} # end # By default, Phoenix returns the status message from # the template name. For example, "404.json" becomes # "Not Found". def template_not_found(template, _assigns) do %{errors: %{detail: Phoenix.Controller.status_message_from_template(template)}} end end
31.352941
83
0.718574
79ce0538ddfcdfb0912ca7515f5490881244d1b2
1,953
ex
Elixir
clients/people/lib/google_api/people/v1/model/contact_group_response.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/people/lib/google_api/people/v1/model/contact_group_response.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/people/lib/google_api/people/v1/model/contact_group_response.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.People.V1.Model.ContactGroupResponse do @moduledoc """ The response for a specific contact group. ## Attributes * `contactGroup` (*type:* `GoogleApi.People.V1.Model.ContactGroup.t`, *default:* `nil`) - The contact group. * `requestedResourceName` (*type:* `String.t`, *default:* `nil`) - The original requested resource name. * `status` (*type:* `GoogleApi.People.V1.Model.Status.t`, *default:* `nil`) - The status of the response. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :contactGroup => GoogleApi.People.V1.Model.ContactGroup.t() | nil, :requestedResourceName => String.t() | nil, :status => GoogleApi.People.V1.Model.Status.t() | nil } field(:contactGroup, as: GoogleApi.People.V1.Model.ContactGroup) field(:requestedResourceName) field(:status, as: GoogleApi.People.V1.Model.Status) end defimpl Poison.Decoder, for: GoogleApi.People.V1.Model.ContactGroupResponse do def decode(value, options) do GoogleApi.People.V1.Model.ContactGroupResponse.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.People.V1.Model.ContactGroupResponse do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
36.849057
112
0.727599
79ce39749f2da12ad9843462f9f62113e3dd5fae
1,763
ex
Elixir
packages/rlack/api/web/controllers/api/session_controller.ex
ragmha/projects
673f7bbad8e27868a4cfa81480556bbc3f4d5bea
[ "MIT" ]
1
2017-04-08T20:08:05.000Z
2017-04-08T20:08:05.000Z
packages/rlack/api/web/controllers/api/session_controller.ex
ragmha/projects
673f7bbad8e27868a4cfa81480556bbc3f4d5bea
[ "MIT" ]
null
null
null
packages/rlack/api/web/controllers/api/session_controller.ex
ragmha/projects
673f7bbad8e27868a4cfa81480556bbc3f4d5bea
[ "MIT" ]
null
null
null
defmodule Rlack.SessionController do use Rlack.Web, :controller def create(conn, params) do case authenticate(params) do {:ok, user} -> new_conn = Guardian.Plug.api_sign_in(conn, user, :access) jwt = Guardian.Plug.current_token(new_conn) new_conn |> put_status(:created) |> render("show.json", user: user, jwt: jwt) :error -> conn |> put_status(:unauthorized) |> render("error.json") end end def delete(conn, _) do jwt = Guardian.Plug.current_token(conn) Guardian.revoke!(jwt) conn |> put_status(:ok) |> render("delete.json") end def refresh(conn, _params) do user = Guardian.Plug.current_resource(conn) jwt = Guardian.Plug.current_token(conn) {:ok, claims} = Guardian.Plug.claims(conn) case Guardian.refresh!(jwt, claims, %{ttl: {30, :days}}) do {:ok, new_jwt, _new_claims} -> conn |> put_status(:ok) |> render("show.json", user: user, jwt: new_jwt) {:error, _reason} -> conn |> put_status(:unauthorized) |> render("forbidden.json", error: "Not authenticated") end end def unauthenticated(conn, _params) do conn |> put_status(:forbidden) |> render(Rlack.SessionView, "forbidden.json", error: "Not Authenticated") end defp authenticate(%{"email" => email, "password" => password}) do user = Repo.get_by(Rlack.User, email: String.downcase(email)) case check_password(user, password) do true -> {:ok, user} _ -> :error end end defp check_password(user, password) do case user do nil -> Comeonin.Bcrypt.dummy_checkpw() _ -> Comeonin.Bcrypt.checkpw(password, user.password_hash) end end end
25.926471
78
0.617697
79ce4f9a0c33ba7ce060fd35da43e0313793cf78
3,841
ex
Elixir
lib/kirby_web/controllers/user_auth.ex
prefeitura-municipal-campos/kirby
290835751a28cd7e39be2e721de243e495273be7
[ "BSD-3-Clause" ]
null
null
null
lib/kirby_web/controllers/user_auth.ex
prefeitura-municipal-campos/kirby
290835751a28cd7e39be2e721de243e495273be7
[ "BSD-3-Clause" ]
null
null
null
lib/kirby_web/controllers/user_auth.ex
prefeitura-municipal-campos/kirby
290835751a28cd7e39be2e721de243e495273be7
[ "BSD-3-Clause" ]
null
null
null
defmodule KirbyWeb.UserAuth do @moduledoc """ UserAuth """ import Plug.Conn import Phoenix.Controller alias Kirby.Context.Accounts alias KirbyWeb.Router.Helpers, as: Routes # Make the remember me cookie valid for 60 days. # If you want bump or reduce this value, also change # the token expiry itself in UserToken. @max_age 60 * 60 * 24 * 60 @remember_me_cookie "_kirby_web_user_remember_me" @remember_me_options [sign: true, max_age: @max_age, same_site: "Lax"] @doc """ Logs the user in. It renews the session ID and clears the whole session to avoid fixation attacks. See the renew_session function to customize this behaviour. It also sets a `:live_socket_id` key in the session, so LiveView sessions are identified and automatically disconnected on log out. The line can be safely removed if you are not using LiveView. """ def log_in_user(conn, user, params \\ %{}) do token = Accounts.generate_user_session_token(user) user_return_to = get_session(conn, :user_return_to) conn |> renew_session() |> put_session(:user_token, token) |> put_session(:live_socket_id, "users_sessions:#{Base.url_encode64(token)}") |> maybe_write_remember_me_cookie(token, params) |> redirect(to: user_return_to || signed_in_path(conn)) end defp maybe_write_remember_me_cookie(conn, token, %{"remember_me" => "true"}) do put_resp_cookie(conn, @remember_me_cookie, token, @remember_me_options) end defp maybe_write_remember_me_cookie(conn, _token, _params) do conn end defp renew_session(conn) do conn |> configure_session(renew: true) |> clear_session() end @doc """ Logs the user out. It clears all session data for safety. See renew_session. """ def log_out_user(conn) do user_token = get_session(conn, :user_token) user_token && Accounts.delete_session_token(user_token) if live_socket_id = get_session(conn, :live_socket_id) do KirbyWeb.Endpoint.broadcast(live_socket_id, "disconnect", %{}) end conn |> renew_session() |> delete_resp_cookie(@remember_me_cookie) |> redirect(to: "/") end @doc """ Authenticates the user by looking into the session and remember me token. """ def fetch_current_user(conn, _opts) do {user_token, conn} = ensure_user_token(conn) user = user_token && Accounts.get_user_by_session_token(user_token) assign(conn, :current_user, user) end defp ensure_user_token(conn) do if user_token = get_session(conn, :user_token) do {user_token, conn} else conn = fetch_cookies(conn, signed: [@remember_me_cookie]) if user_token = conn.cookies[@remember_me_cookie] do {user_token, put_session(conn, :user_token, user_token)} else {nil, conn} end end end @doc """ Used for routes that require the user to not be authenticated. """ def redirect_if_user_is_authenticated(conn, _opts) do if conn.assigns[:current_user] do conn |> redirect(to: signed_in_path(conn)) |> halt() else conn end end @doc """ Used for routes that require the user to be authenticated. If you want to enforce the user email is confirmed before they use the application at all, here would be a good place. """ def require_authenticated_user(conn, _opts) do if conn.assigns[:current_user] do conn else conn |> put_flash(:error, "Você precisa estar logado para acessar está página!") |> maybe_store_return_to() |> redirect(to: Routes.user_session_path(conn, :new)) |> halt() end end defp maybe_store_return_to(%{method: "GET"} = conn) do put_session(conn, :user_return_to, current_path(conn)) end defp maybe_store_return_to(conn), do: conn defp signed_in_path(_conn), do: "/" end
27.633094
81
0.696954
79ce7fb38b7cc70ba1f36aee50b9f2f90282b507
2,414
ex
Elixir
test/support/mocks/schemas.ex
opsb/rolodex
0e814527a8f7ef04a50742752096655b07365888
[ "MIT" ]
36
2019-02-19T19:07:38.000Z
2022-02-23T18:14:31.000Z
test/support/mocks/schemas.ex
opsb/rolodex
0e814527a8f7ef04a50742752096655b07365888
[ "MIT" ]
4
2019-02-19T18:55:46.000Z
2019-05-03T18:45:53.000Z
test/support/mocks/schemas.ex
opsb/rolodex
0e814527a8f7ef04a50742752096655b07365888
[ "MIT" ]
3
2019-02-19T19:50:05.000Z
2020-11-20T11:26:57.000Z
defmodule Rolodex.Mocks.User do use Rolodex.Schema @configs [ private: :boolean, archived: :boolean, active: :boolean ] schema "User", desc: "A user record" do field(:id, :uuid, desc: "The id of the user", required: true) field(:email, :string, desc: "The email of the user", required: true) # Nested object field(:comment, Rolodex.Mocks.Comment) # Nested schema with a cyclical dependency field(:parent, Rolodex.Mocks.Parent) # List of one type field(:comments, :list, of: [Rolodex.Mocks.Comment]) # Can use the list shorthand field(:short_comments, [Rolodex.Mocks.Comment]) # List of multiple types field(:comments_of_many_types, :list, of: [:string, Rolodex.Mocks.Comment], desc: "List of text or comment" ) # A field with multiple possible types field(:multi, :one_of, of: [:string, Rolodex.Mocks.NotFound]) # Can use a for comprehension to define many fields for {name, type} <- @configs, do: field(name, type) end end defmodule Rolodex.Mocks.Parent do use Rolodex.Schema schema "Parent" do field(:child, Rolodex.Mocks.User) end end defmodule Rolodex.Mocks.Comment do use Rolodex.Schema schema "Comment", desc: "A comment record" do field(:id, :uuid, desc: "The comment id") field(:text, :string) end end defmodule Rolodex.Mocks.NotFound do use Rolodex.Schema schema "NotFound", desc: "Not found response" do field(:message, :string) end end defmodule Rolodex.Mocks.NestedDemo do use Rolodex.Schema schema "NestedDemo" do field(:nested, Rolodex.Mocks.FirstNested) end end defmodule Rolodex.Mocks.FirstNested do use Rolodex.Schema schema "FirstNested" do field(:nested, Rolodex.Mocks.SecondNested) end end defmodule Rolodex.Mocks.SecondNested do use Rolodex.Schema schema "SecondNested" do field(:id, :uuid) end end defmodule Rolodex.Mocks.WithPartials do use Rolodex.Schema schema "WithPartials" do field(:created_at, :datetime) partial(Rolodex.Mocks.Comment) partial(mentions: [:uuid]) end end defmodule Rolodex.Mocks.ParamsSchema do use Rolodex.Schema alias Rolodex.Mocks.WithPartials schema "ParamsSchema" do field(:account_id, :uuid) field(:team_id, :integer, maximum: 10, minimum: 0, required: true, default: 2 ) partial(WithPartials) end end
20.457627
73
0.686413
79ce97030963df8d1a6bf5e248d4da7d24925bd2
119,689
ex
Elixir
clients/pub_sub/lib/google_api/pub_sub/v1/api/projects.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
null
null
null
clients/pub_sub/lib/google_api/pub_sub/v1/api/projects.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
null
null
null
clients/pub_sub/lib/google_api/pub_sub/v1/api/projects.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.PubSub.V1.Api.Projects do @moduledoc """ API calls for all endpoints tagged `Projects`. """ alias GoogleApi.PubSub.V1.Connection alias GoogleApi.Gax.{Request, Response} @library_version Mix.Project.config() |> Keyword.get(:version, "") @doc """ Creates a snapshot from the requested subscription. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. If the snapshot already exists, returns `ALREADY_EXISTS`. If the requested subscription doesn't exist, returns `NOT_FOUND`. If the backlog in the subscription is too old -- and the resulting snapshot would expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned. See also the `Snapshot.expire_time` field. If the name is not provided in the request, the server will assign a random name for this snapshot on the same project as the subscription, conforming to the [resource name format] (https://cloud.google.com/pubsub/docs/admin#resource_names). The generated name is populated in the returned Snapshot object. Note that for REST API requests, you must specify a name in the request. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. Required. User-provided name for this snapshot. If the name is not provided in the request, the server will assign a random name for this snapshot on the same project as the subscription. Note that for REST API requests, you must specify a name. See the resource name rules. Format is `projects/{project}/snapshots/{snap}`. * `snapshots_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.CreateSnapshotRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Snapshot{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_snapshots_create( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Snapshot.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_snapshots_create( connection, projects_id, snapshots_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:put) |> Request.url("/v1/projects/{projectsId}/snapshots/{snapshotsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "snapshotsId" => URI.encode(snapshots_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Snapshot{}]) end @doc """ Removes an existing snapshot. Snapshots are used in [Seek] (https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. When the snapshot is deleted, all messages retained in the snapshot are immediately dropped. After a snapshot is deleted, a new one may be created with the same name, but the new one has no association with the old snapshot or its subscription, unless the same subscription is specified. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `snapshot`. Required. The name of the snapshot to delete. Format is `projects/{project}/snapshots/{snap}`. * `snapshots_id` (*type:* `String.t`) - Part of `snapshot`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_snapshots_delete( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Empty.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_snapshots_delete( connection, projects_id, snapshots_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v1/projects/{projectsId}/snapshots/{snapshotsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "snapshotsId" => URI.encode(snapshots_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Empty{}]) end @doc """ Gets the configuration details of a snapshot. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `snapshot`. Required. The name of the snapshot to get. Format is `projects/{project}/snapshots/{snap}`. * `snapshots_id` (*type:* `String.t`) - Part of `snapshot`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Snapshot{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_snapshots_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Snapshot.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_snapshots_get( connection, projects_id, snapshots_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/projects/{projectsId}/snapshots/{snapshotsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "snapshotsId" => URI.encode(snapshots_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Snapshot{}]) end @doc """ Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `resource`. REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. * `snapshots_id` (*type:* `String.t`) - Part of `resource`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:"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.PubSub.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_snapshots_get_iam_policy( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_snapshots_get_iam_policy( connection, projects_id, snapshots_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :"options.requestedPolicyVersion" => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/projects/{projectsId}/snapshots/{snapshotsId}:getIamPolicy", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "snapshotsId" => URI.encode(snapshots_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Policy{}]) end @doc """ Lists the existing snapshots. Snapshots are used in [Seek]( https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `project`. Required. The name of the project in which to list snapshots. Format is `projects/{project-id}`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:pageSize` (*type:* `integer()`) - Maximum number of snapshots to return. * `:pageToken` (*type:* `String.t`) - The value returned by the last `ListSnapshotsResponse`; indicates that this is a continuation of a prior `ListSnapshots` call, and that the system should return the next page of data. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.ListSnapshotsResponse{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_snapshots_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.PubSub.V1.Model.ListSnapshotsResponse.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_snapshots_list(connection, projects_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/projects/{projectsId}/snapshots", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.ListSnapshotsResponse{}]) end @doc """ Updates an existing snapshot. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `snapshot.name`. The name of the snapshot. * `snapshots_id` (*type:* `String.t`) - Part of `snapshot.name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.UpdateSnapshotRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Snapshot{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_snapshots_patch( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Snapshot.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_snapshots_patch( connection, projects_id, snapshots_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v1/projects/{projectsId}/snapshots/{snapshotsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "snapshotsId" => URI.encode(snapshots_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Snapshot{}]) end @doc """ Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `resource`. REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. * `snapshots_id` (*type:* `String.t`) - Part of `resource`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.SetIamPolicyRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_snapshots_set_iam_policy( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_snapshots_set_iam_policy( connection, projects_id, snapshots_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/projects/{projectsId}/snapshots/{snapshotsId}:setIamPolicy", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "snapshotsId" => URI.encode(snapshots_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Policy{}]) end @doc """ Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `resource`. REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. * `snapshots_id` (*type:* `String.t`) - Part of `resource`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.TestIamPermissionsRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.TestIamPermissionsResponse{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_snapshots_test_iam_permissions( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.TestIamPermissionsResponse.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_snapshots_test_iam_permissions( connection, projects_id, snapshots_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/projects/{projectsId}/snapshots/{snapshotsId}:testIamPermissions", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "snapshotsId" => URI.encode(snapshots_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.TestIamPermissionsResponse{}]) end @doc """ Acknowledges the messages associated with the `ack_ids` in the `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages from the subscription. Acknowledging a message whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `subscription`. Required. The subscription whose message is being acknowledged. Format is `projects/{project}/subscriptions/{sub}`. * `subscriptions_id` (*type:* `String.t`) - Part of `subscription`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.AcknowledgeRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_acknowledge( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Empty.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_acknowledge( connection, projects_id, subscriptions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/projects/{projectsId}/subscriptions/{subscriptionsId}:acknowledge", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "subscriptionsId" => URI.encode(subscriptions_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Empty{}]) end @doc """ Creates a subscription to a given topic. See the [resource name rules] (https://cloud.google.com/pubsub/docs/admin#resource_names). If the subscription already exists, returns `ALREADY_EXISTS`. If the corresponding topic doesn't exist, returns `NOT_FOUND`. If the name is not provided in the request, the server will assign a random name for this subscription on the same project as the topic, conforming to the [resource name format] (https://cloud.google.com/pubsub/docs/admin#resource_names). The generated name is populated in the returned Subscription object. Note that for REST API requests, you must specify a name in the request. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. Required. The name of the subscription. It must have the format `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`. * `subscriptions_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.Subscription.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Subscription{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_create( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Subscription.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_create( connection, projects_id, subscriptions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:put) |> Request.url("/v1/projects/{projectsId}/subscriptions/{subscriptionsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "subscriptionsId" => URI.encode(subscriptions_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Subscription{}]) end @doc """ Deletes an existing subscription. All messages retained in the subscription are immediately dropped. Calls to `Pull` after deletion will return `NOT_FOUND`. After a subscription is deleted, a new one may be created with the same name, but the new one has no association with the old subscription or its topic unless the same topic is specified. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `subscription`. Required. The subscription to delete. Format is `projects/{project}/subscriptions/{sub}`. * `subscriptions_id` (*type:* `String.t`) - Part of `subscription`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_delete( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Empty.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_delete( connection, projects_id, subscriptions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v1/projects/{projectsId}/subscriptions/{subscriptionsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "subscriptionsId" => URI.encode(subscriptions_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Empty{}]) end @doc """ Detaches a subscription from this topic. All messages retained in the subscription are dropped. Subsequent `Pull` and `StreamingPull` requests will return FAILED_PRECONDITION. If the subscription is a push subscription, pushes to the endpoint will stop. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `subscription`. Required. The subscription to detach. Format is `projects/{project}/subscriptions/{subscription}`. * `subscriptions_id` (*type:* `String.t`) - Part of `subscription`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.DetachSubscriptionResponse{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_detach( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.DetachSubscriptionResponse.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_detach( connection, projects_id, subscriptions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:post) |> Request.url("/v1/projects/{projectsId}/subscriptions/{subscriptionsId}:detach", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "subscriptionsId" => URI.encode(subscriptions_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.DetachSubscriptionResponse{}]) end @doc """ Gets the configuration details of a subscription. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `subscription`. Required. The name of the subscription to get. Format is `projects/{project}/subscriptions/{sub}`. * `subscriptions_id` (*type:* `String.t`) - Part of `subscription`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Subscription{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Subscription.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_get( connection, projects_id, subscriptions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/projects/{projectsId}/subscriptions/{subscriptionsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "subscriptionsId" => URI.encode(subscriptions_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Subscription{}]) end @doc """ Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `resource`. REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. * `subscriptions_id` (*type:* `String.t`) - Part of `resource`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:"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.PubSub.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_get_iam_policy( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_get_iam_policy( connection, projects_id, subscriptions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :"options.requestedPolicyVersion" => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/projects/{projectsId}/subscriptions/{subscriptionsId}:getIamPolicy", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "subscriptionsId" => URI.encode(subscriptions_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Policy{}]) end @doc """ Lists matching subscriptions. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `project`. Required. The name of the project in which to list subscriptions. Format is `projects/{project-id}`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:pageSize` (*type:* `integer()`) - Maximum number of subscriptions to return. * `:pageToken` (*type:* `String.t`) - The value returned by the last `ListSubscriptionsResponse`; indicates that this is a continuation of a prior `ListSubscriptions` call, and that the system should return the next page of data. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.ListSubscriptionsResponse{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.PubSub.V1.Model.ListSubscriptionsResponse.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_list( connection, projects_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/projects/{projectsId}/subscriptions", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.ListSubscriptionsResponse{}]) end @doc """ Modifies the ack deadline for a specific message. This method is useful to indicate that more time is needed to process a message by the subscriber, or to make the message available for redelivery if the processing was interrupted. Note that this does not modify the subscription-level `ackDeadlineSeconds` used for subsequent messages. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `subscription`. Required. The name of the subscription. Format is `projects/{project}/subscriptions/{sub}`. * `subscriptions_id` (*type:* `String.t`) - Part of `subscription`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.ModifyAckDeadlineRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_modify_ack_deadline( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Empty.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_modify_ack_deadline( connection, projects_id, subscriptions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/v1/projects/{projectsId}/subscriptions/{subscriptionsId}:modifyAckDeadline", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "subscriptionsId" => URI.encode(subscriptions_id, &URI.char_unreserved?/1) } ) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Empty{}]) end @doc """ Modifies the `PushConfig` for a specified subscription. This may be used to change a push subscription to a pull one (signified by an empty `PushConfig`) or vice versa, or change the endpoint URL and other attributes of a push subscription. Messages will accumulate for delivery continuously through the call regardless of changes to the `PushConfig`. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `subscription`. Required. The name of the subscription. Format is `projects/{project}/subscriptions/{sub}`. * `subscriptions_id` (*type:* `String.t`) - Part of `subscription`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.ModifyPushConfigRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_modify_push_config( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Empty.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_modify_push_config( connection, projects_id, subscriptions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/v1/projects/{projectsId}/subscriptions/{subscriptionsId}:modifyPushConfig", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "subscriptionsId" => URI.encode(subscriptions_id, &URI.char_unreserved?/1) } ) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Empty{}]) end @doc """ Updates an existing subscription. Note that certain properties of a subscription, such as its topic, are not modifiable. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `subscription.name`. Required. The name of the subscription. It must have the format `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`. * `subscriptions_id` (*type:* `String.t`) - Part of `subscription.name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.UpdateSubscriptionRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Subscription{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_patch( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Subscription.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_patch( connection, projects_id, subscriptions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v1/projects/{projectsId}/subscriptions/{subscriptionsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "subscriptionsId" => URI.encode(subscriptions_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Subscription{}]) end @doc """ Pulls messages from the server. The server may return `UNAVAILABLE` if there are too many concurrent pull requests pending for the given subscription. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `subscription`. Required. The subscription from which messages should be pulled. Format is `projects/{project}/subscriptions/{sub}`. * `subscriptions_id` (*type:* `String.t`) - Part of `subscription`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.PullRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.PullResponse{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_pull( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.PullResponse.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_pull( connection, projects_id, subscriptions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/projects/{projectsId}/subscriptions/{subscriptionsId}:pull", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "subscriptionsId" => URI.encode(subscriptions_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.PullResponse{}]) end @doc """ Seeks an existing subscription to a point in time or to a given snapshot, whichever is provided in the request. Snapshots are used in [Seek]( https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. Note that both the subscription and the snapshot must be on the same topic. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `subscription`. Required. The subscription to affect. * `subscriptions_id` (*type:* `String.t`) - Part of `subscription`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.SeekRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.SeekResponse{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_seek( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.SeekResponse.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_seek( connection, projects_id, subscriptions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/projects/{projectsId}/subscriptions/{subscriptionsId}:seek", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "subscriptionsId" => URI.encode(subscriptions_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.SeekResponse{}]) end @doc """ Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `resource`. REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. * `subscriptions_id` (*type:* `String.t`) - Part of `resource`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.SetIamPolicyRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_set_iam_policy( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_set_iam_policy( connection, projects_id, subscriptions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/projects/{projectsId}/subscriptions/{subscriptionsId}:setIamPolicy", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "subscriptionsId" => URI.encode(subscriptions_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Policy{}]) end @doc """ Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `resource`. REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. * `subscriptions_id` (*type:* `String.t`) - Part of `resource`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.TestIamPermissionsRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.TestIamPermissionsResponse{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_subscriptions_test_iam_permissions( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.TestIamPermissionsResponse.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_subscriptions_test_iam_permissions( connection, projects_id, subscriptions_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/v1/projects/{projectsId}/subscriptions/{subscriptionsId}:testIamPermissions", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "subscriptionsId" => URI.encode(subscriptions_id, &URI.char_unreserved?/1) } ) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.TestIamPermissionsResponse{}]) end @doc """ Creates the given topic with the given name. See the [resource name rules]( https://cloud.google.com/pubsub/docs/admin#resource_names). ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `name`. Required. The name of the topic. It must have the format `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`. * `topics_id` (*type:* `String.t`) - Part of `name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.Topic.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Topic{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_topics_create( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Topic.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_topics_create( connection, projects_id, topics_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:put) |> Request.url("/v1/projects/{projectsId}/topics/{topicsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "topicsId" => URI.encode(topics_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Topic{}]) end @doc """ Deletes the topic with the given name. Returns `NOT_FOUND` if the topic does not exist. After a topic is deleted, a new topic may be created with the same name; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their `topic` field is set to `_deleted-topic_`. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `topic`. Required. Name of the topic to delete. Format is `projects/{project}/topics/{topic}`. * `topics_id` (*type:* `String.t`) - Part of `topic`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_topics_delete( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Empty.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_topics_delete( connection, projects_id, topics_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/v1/projects/{projectsId}/topics/{topicsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "topicsId" => URI.encode(topics_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Empty{}]) end @doc """ Gets the configuration of a topic. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `topic`. Required. The name of the topic to get. Format is `projects/{project}/topics/{topic}`. * `topics_id` (*type:* `String.t`) - Part of `topic`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Topic{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_topics_get( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Topic.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_topics_get( connection, projects_id, topics_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/projects/{projectsId}/topics/{topicsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "topicsId" => URI.encode(topics_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Topic{}]) end @doc """ Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `resource`. REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. * `topics_id` (*type:* `String.t`) - Part of `resource`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:"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.PubSub.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_topics_get_iam_policy( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_topics_get_iam_policy( connection, projects_id, topics_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :"options.requestedPolicyVersion" => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/projects/{projectsId}/topics/{topicsId}:getIamPolicy", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "topicsId" => URI.encode(topics_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Policy{}]) end @doc """ Lists matching topics. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `project`. Required. The name of the project in which to list topics. Format is `projects/{project-id}`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:pageSize` (*type:* `integer()`) - Maximum number of topics to return. * `:pageToken` (*type:* `String.t`) - The value returned by the last `ListTopicsResponse`; indicates that this is a continuation of a prior `ListTopics` call, and that the system should return the next page of data. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.ListTopicsResponse{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_topics_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.PubSub.V1.Model.ListTopicsResponse.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_topics_list(connection, projects_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/projects/{projectsId}/topics", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.ListTopicsResponse{}]) end @doc """ Updates an existing topic. Note that certain properties of a topic are not modifiable. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `topic.name`. Required. The name of the topic. It must have the format `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`. * `topics_id` (*type:* `String.t`) - Part of `topic.name`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.UpdateTopicRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Topic{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_topics_patch( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Topic.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_topics_patch( connection, projects_id, topics_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v1/projects/{projectsId}/topics/{topicsId}", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "topicsId" => URI.encode(topics_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Topic{}]) end @doc """ Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic does not exist. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `topic`. Required. The messages in the request will be published on this topic. Format is `projects/{project}/topics/{topic}`. * `topics_id` (*type:* `String.t`) - Part of `topic`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.PublishRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.PublishResponse{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_topics_publish( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.PublishResponse.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_topics_publish( connection, projects_id, topics_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/projects/{projectsId}/topics/{topicsId}:publish", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "topicsId" => URI.encode(topics_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.PublishResponse{}]) end @doc """ Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `resource`. REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. * `topics_id` (*type:* `String.t`) - Part of `resource`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.SetIamPolicyRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_topics_set_iam_policy( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_topics_set_iam_policy( connection, projects_id, topics_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/projects/{projectsId}/topics/{topicsId}:setIamPolicy", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "topicsId" => URI.encode(topics_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.Policy{}]) end @doc """ Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `resource`. REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. * `topics_id` (*type:* `String.t`) - Part of `resource`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.PubSub.V1.Model.TestIamPermissionsRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.TestIamPermissionsResponse{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_topics_test_iam_permissions( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.TestIamPermissionsResponse.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_topics_test_iam_permissions( connection, projects_id, topics_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1/projects/{projectsId}/topics/{topicsId}:testIamPermissions", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "topicsId" => URI.encode(topics_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.TestIamPermissionsResponse{}]) end @doc """ Lists the names of the snapshots on this topic. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `topic`. Required. The name of the topic that snapshots are attached to. Format is `projects/{project}/topics/{topic}`. * `topics_id` (*type:* `String.t`) - Part of `topic`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:pageSize` (*type:* `integer()`) - Maximum number of snapshot names to return. * `:pageToken` (*type:* `String.t`) - The value returned by the last `ListTopicSnapshotsResponse`; indicates that this is a continuation of a prior `ListTopicSnapshots` call, and that the system should return the next page of data. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.ListTopicSnapshotsResponse{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_topics_snapshots_list( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.ListTopicSnapshotsResponse.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_topics_snapshots_list( connection, projects_id, topics_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/projects/{projectsId}/topics/{topicsId}/snapshots", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "topicsId" => URI.encode(topics_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.PubSub.V1.Model.ListTopicSnapshotsResponse{}]) end @doc """ Lists the names of the attached subscriptions on this topic. ## Parameters * `connection` (*type:* `GoogleApi.PubSub.V1.Connection.t`) - Connection to server * `projects_id` (*type:* `String.t`) - Part of `topic`. Required. The name of the topic that subscriptions are attached to. Format is `projects/{project}/topics/{topic}`. * `topics_id` (*type:* `String.t`) - Part of `topic`. See documentation of `projectsId`. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:pageSize` (*type:* `integer()`) - Maximum number of subscription names to return. * `:pageToken` (*type:* `String.t`) - The value returned by the last `ListTopicSubscriptionsResponse`; indicates that this is a continuation of a prior `ListTopicSubscriptions` call, and that the system should return the next page of data. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.PubSub.V1.Model.ListTopicSubscriptionsResponse{}}` on success * `{:error, info}` on failure """ @spec pubsub_projects_topics_subscriptions_list( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.PubSub.V1.Model.ListTopicSubscriptionsResponse.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def pubsub_projects_topics_subscriptions_list( connection, projects_id, topics_id, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1/projects/{projectsId}/topics/{topicsId}/subscriptions", %{ "projectsId" => URI.encode(projects_id, &URI.char_unreserved?/1), "topicsId" => URI.encode(topics_id, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.PubSub.V1.Model.ListTopicSubscriptionsResponse{}] ) end end
49.417424
1,029
0.624911
79ceabeb81bc2123200ffa15759b4531f8b13ddc
425
exs
Elixir
test/couchdb_connector/as_json_test.exs
PinheiroRodrigo/couchdb_connector
464136ebe47049c5b3143bbd5f74977c82c9c621
[ "Apache-2.0" ]
64
2016-01-20T17:48:05.000Z
2017-05-24T18:00:14.000Z
test/couchdb_connector/as_json_test.exs
PinheiroRodrigo/couchdb_connector
464136ebe47049c5b3143bbd5f74977c82c9c621
[ "Apache-2.0" ]
40
2016-01-16T18:39:46.000Z
2017-06-03T10:02:54.000Z
test/couchdb_connector/as_json_test.exs
PinheiroRodrigo/couchdb_connector
464136ebe47049c5b3143bbd5f74977c82c9c621
[ "Apache-2.0" ]
22
2015-12-28T00:23:20.000Z
2017-05-28T21:58:21.000Z
defmodule Couchdb.Connector.AsJsonTest do use ExUnit.Case import Couchdb.Connector.AsJson test "as_json/1 with valid input should encode to JSON" do doc_map = %{"_id" => "foo", "_rev" => "1-0f97561a543ed2e9c98a24dea818ec10", "test_key" => "test_value"} encoded = as_json(doc_map) assert encoded == "{\"test_key\":\"test_value\",\"_rev\":\"1-0f97561a543ed2e9c98a24dea818ec10\",\"_id\":\"foo\"}" end end
32.692308
117
0.689412
79ceb4dfd78c5ca8df3972f2f51bcebda275abfb
6,445
ex
Elixir
clients/health_care/lib/google_api/health_care/v1/model/policy.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/health_care/lib/google_api/health_care/v1/model/policy.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/health_care/lib/google_api/health_care/v1/model/policy.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.HealthCare.V1.Model.Policy do @moduledoc """ An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:[email protected]", "group:[email protected]", "domain:google.com", "serviceAccount:[email protected]" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:[email protected]" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 } **YAML example:** bindings: - members: - user:[email protected] - group:[email protected] - domain:google.com - serviceAccount:[email protected] role: roles/resourcemanager.organizationAdmin - members: - user:[email protected] role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3 For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/). ## Attributes * `auditConfigs` (*type:* `list(GoogleApi.HealthCare.V1.Model.AuditConfig.t)`, *default:* `nil`) - Specifies cloud audit logging configuration for this policy. * `bindings` (*type:* `list(GoogleApi.HealthCare.V1.Model.Binding.t)`, *default:* `nil`) - Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:[email protected]`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`. * `etag` (*type:* `String.t`, *default:* `nil`) - `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. * `version` (*type:* `integer()`, *default:* `nil`) - Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version 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). """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :auditConfigs => list(GoogleApi.HealthCare.V1.Model.AuditConfig.t()) | nil, :bindings => list(GoogleApi.HealthCare.V1.Model.Binding.t()) | nil, :etag => String.t() | nil, :version => integer() | nil } field(:auditConfigs, as: GoogleApi.HealthCare.V1.Model.AuditConfig, type: :list) field(:bindings, as: GoogleApi.HealthCare.V1.Model.Binding, type: :list) field(:etag) field(:version) end defimpl Poison.Decoder, for: GoogleApi.HealthCare.V1.Model.Policy do def decode(value, options) do GoogleApi.HealthCare.V1.Model.Policy.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.HealthCare.V1.Model.Policy do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
115.089286
2,012
0.75128
79cec2ff2e96aad261148020d45515b71a560c50
4,874
ex
Elixir
clients/private_ca/lib/google_api/private_ca/v1beta1/model/google_api_servicecontrol_v1_http_request.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
clients/private_ca/lib/google_api/private_ca/v1beta1/model/google_api_servicecontrol_v1_http_request.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
clients/private_ca/lib/google_api/private_ca/v1beta1/model/google_api_servicecontrol_v1_http_request.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.PrivateCA.V1beta1.Model.GoogleApiServicecontrolV1HttpRequest do @moduledoc """ A common proto for logging HTTP requests. Only contains semantics defined by the HTTP specification. Product-specific logging information MUST be defined in a separate message. ## Attributes * `cacheFillBytes` (*type:* `String.t`, *default:* `nil`) - The number of HTTP response bytes inserted into cache. Set only when a cache fill was attempted. * `cacheHit` (*type:* `boolean()`, *default:* `nil`) - Whether or not an entity was served from cache (with or without validation). * `cacheLookup` (*type:* `boolean()`, *default:* `nil`) - Whether or not a cache lookup was attempted. * `cacheValidatedWithOriginServer` (*type:* `boolean()`, *default:* `nil`) - Whether or not the response was validated with the origin server before being served from cache. This field is only meaningful if `cache_hit` is True. * `latency` (*type:* `String.t`, *default:* `nil`) - The request processing latency on the server, from the time the request was received until the response was sent. * `protocol` (*type:* `String.t`, *default:* `nil`) - Protocol used for the request. Examples: "HTTP/1.1", "HTTP/2", "websocket" * `referer` (*type:* `String.t`, *default:* `nil`) - The referer URL of the request, as defined in [HTTP/1.1 Header Field Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). * `remoteIp` (*type:* `String.t`, *default:* `nil`) - The IP address (IPv4 or IPv6) of the client that issued the HTTP request. Examples: `"192.168.1.1"`, `"FE80::0202:B3FF:FE1E:8329"`. * `requestMethod` (*type:* `String.t`, *default:* `nil`) - The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`. * `requestSize` (*type:* `String.t`, *default:* `nil`) - The size of the HTTP request message in bytes, including the request headers and the request body. * `requestUrl` (*type:* `String.t`, *default:* `nil`) - The scheme (http, https), the host name, the path, and the query portion of the URL that was requested. Example: `"http://example.com/some/info?color=red"`. * `responseSize` (*type:* `String.t`, *default:* `nil`) - The size of the HTTP response message sent back to the client, in bytes, including the response headers and the response body. * `serverIp` (*type:* `String.t`, *default:* `nil`) - The IP address (IPv4 or IPv6) of the origin server that the request was sent to. * `status` (*type:* `integer()`, *default:* `nil`) - The response code indicating the status of the response. Examples: 200, 404. * `userAgent` (*type:* `String.t`, *default:* `nil`) - The user agent sent by the client. Example: `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET CLR 1.0.3705)"`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :cacheFillBytes => String.t(), :cacheHit => boolean(), :cacheLookup => boolean(), :cacheValidatedWithOriginServer => boolean(), :latency => String.t(), :protocol => String.t(), :referer => String.t(), :remoteIp => String.t(), :requestMethod => String.t(), :requestSize => String.t(), :requestUrl => String.t(), :responseSize => String.t(), :serverIp => String.t(), :status => integer(), :userAgent => String.t() } field(:cacheFillBytes) field(:cacheHit) field(:cacheLookup) field(:cacheValidatedWithOriginServer) field(:latency) field(:protocol) field(:referer) field(:remoteIp) field(:requestMethod) field(:requestSize) field(:requestUrl) field(:responseSize) field(:serverIp) field(:status) field(:userAgent) end defimpl Poison.Decoder, for: GoogleApi.PrivateCA.V1beta1.Model.GoogleApiServicecontrolV1HttpRequest do def decode(value, options) do GoogleApi.PrivateCA.V1beta1.Model.GoogleApiServicecontrolV1HttpRequest.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.PrivateCA.V1beta1.Model.GoogleApiServicecontrolV1HttpRequest do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
53.56044
231
0.685269
79ceef1bf026cb42636cff296d6d3c42a6f68a40
1,225
exs
Elixir
bootstrap/templates/new/mix.exs
tverlaan/nerves
515b9b7730a1b2934ac051b0e7075cd7987b6c4a
[ "Apache-2.0" ]
null
null
null
bootstrap/templates/new/mix.exs
tverlaan/nerves
515b9b7730a1b2934ac051b0e7075cd7987b6c4a
[ "Apache-2.0" ]
null
null
null
bootstrap/templates/new/mix.exs
tverlaan/nerves
515b9b7730a1b2934ac051b0e7075cd7987b6c4a
[ "Apache-2.0" ]
null
null
null
defmodule <%= application_module %>.Mixfile do use Mix.Project @target System.get_env("NERVES_TARGET") || "<%= default_target %>" def project do [app: :<%= application_name %>, version: "0.1.0", target: @target, archives: [nerves_bootstrap: "~> <%= bootstrap_vsn %>"], <%= if in_umbrella do %> deps_path: "../../deps/#{@target}", build_path: "../../_build/#{@target}", config_path: "../../config/config.exs", lockfile: "../../mix.lock", <% else %> deps_path: "deps/#{@target}", build_path: "_build/#{@target}", <% end %> build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, aliases: aliases(), deps: deps() ++ system(@target)] end # Configuration for the OTP application. # # Type `mix help compile.app` for more information. def application do [mod: {<%= application_module %>, []}, applications: [:logger]] end def deps do [<%= nerves_dep %>] end def system(target) do [{:"nerves_system_#{target}", ">= 0.0.0"}] end def aliases do ["deps.precompile": ["nerves.precompile", "deps.precompile"], "deps.loadpaths": ["deps.loadpaths", "nerves.loadpaths"]] end end
25.520833
68
0.582857
79cf0956ec82453f19812a8db03c91d764141610
1,018
ex
Elixir
lib/zaryn/application.ex
zarynxyz/zaryn
5d6cf8b6e43e8cdf2a8d0688fb9c16e4509fc958
[ "Apache-2.0" ]
4
2021-05-29T11:22:36.000Z
2022-02-09T11:26:39.000Z
lib/zaryn/application.ex
zarynxyz/zaryn
5d6cf8b6e43e8cdf2a8d0688fb9c16e4509fc958
[ "Apache-2.0" ]
2
2021-06-17T13:32:39.000Z
2022-02-09T11:26:02.000Z
lib/zaryn/application.ex
zarynxyz/zaryn
5d6cf8b6e43e8cdf2a8d0688fb9c16e4509fc958
[ "Apache-2.0" ]
1
2021-06-04T14:27:20.000Z
2021-06-04T14:27:20.000Z
defmodule Zaryn.Application do # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications @moduledoc false use Application @impl true def start(_type, _args) do children = [ # Start the Ecto repository Zaryn.Repo, # Start the Telemetry supervisor ZarynWeb.Telemetry, # Start the PubSub system {Phoenix.PubSub, name: Zaryn.PubSub}, # Start the Endpoint (http/https) ZarynWeb.Endpoint # Start a worker by calling: Zaryn.Worker.start_link(arg) # {Zaryn.Worker, arg} ] # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: Zaryn.Supervisor] Supervisor.start_link(children, opts) end # Tell Phoenix to update the endpoint configuration # whenever the application is updated. @impl true def config_change(changed, _new, removed) do ZarynWeb.Endpoint.config_change(changed, removed) :ok end end
27.513514
63
0.694499
79cf0aceedfd13de069f7a540b8de9304beccef4
10,733
ex
Elixir
clients/games_management/lib/google_api/games_management/v1management/api/scores.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/games_management/lib/google_api/games_management/v1management/api/scores.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/games_management/lib/google_api/games_management/v1management/api/scores.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
1
2020-11-10T16:58:27.000Z
2020-11-10T16:58:27.000Z
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.GamesManagement.V1management.Api.Scores do @moduledoc """ API calls for all endpoints tagged `Scores`. """ alias GoogleApi.GamesManagement.V1management.Connection alias GoogleApi.Gax.{Request, Response} @doc """ Resets scores for the leaderboard with the given ID for the currently authenticated player. This method is only accessible to whitelisted tester accounts for your application. ## Parameters - connection (GoogleApi.GamesManagement.V1management.Connection): Connection to server - leaderboard_id (String.t): The ID of the leaderboard. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for the response. - :fields (String.t): Selector specifying which fields to include in a partial response. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :oauth_token (String.t): OAuth 2.0 token for the current user. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :quotaUser (String.t): An opaque string that represents a user for quota purposes. Must not exceed 40 characters. - :userIp (String.t): Deprecated. Please use quotaUser instead. ## Returns {:ok, %GoogleApi.GamesManagement.V1management.Model.PlayerScoreResetResponse{}} on success {:error, info} on failure """ @spec games_management_scores_reset(Tesla.Env.client(), String.t(), keyword()) :: {:ok, GoogleApi.GamesManagement.V1management.Model.PlayerScoreResetResponse.t()} | {:error, Tesla.Env.t()} def games_management_scores_reset(connection, leaderboard_id, opts \\ []) do optional_params = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query } request = Request.new() |> Request.method(:post) |> Request.url("/leaderboards/{leaderboardId}/scores/reset", %{ "leaderboardId" => URI.encode_www_form(leaderboard_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode( struct: %GoogleApi.GamesManagement.V1management.Model.PlayerScoreResetResponse{} ) end @doc """ Resets all scores for all leaderboards for the currently authenticated players. This method is only accessible to whitelisted tester accounts for your application. ## Parameters - connection (GoogleApi.GamesManagement.V1management.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for the response. - :fields (String.t): Selector specifying which fields to include in a partial response. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :oauth_token (String.t): OAuth 2.0 token for the current user. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :quotaUser (String.t): An opaque string that represents a user for quota purposes. Must not exceed 40 characters. - :userIp (String.t): Deprecated. Please use quotaUser instead. ## Returns {:ok, %GoogleApi.GamesManagement.V1management.Model.PlayerScoreResetAllResponse{}} on success {:error, info} on failure """ @spec games_management_scores_reset_all(Tesla.Env.client(), keyword()) :: {:ok, GoogleApi.GamesManagement.V1management.Model.PlayerScoreResetAllResponse.t()} | {:error, Tesla.Env.t()} def games_management_scores_reset_all(connection, opts \\ []) do optional_params = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query } request = Request.new() |> Request.method(:post) |> Request.url("/scores/reset") |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode( struct: %GoogleApi.GamesManagement.V1management.Model.PlayerScoreResetAllResponse{} ) end @doc """ Resets scores for all draft leaderboards for all players. This method is only available to user accounts for your developer console. ## Parameters - connection (GoogleApi.GamesManagement.V1management.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for the response. - :fields (String.t): Selector specifying which fields to include in a partial response. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :oauth_token (String.t): OAuth 2.0 token for the current user. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :quotaUser (String.t): An opaque string that represents a user for quota purposes. Must not exceed 40 characters. - :userIp (String.t): Deprecated. Please use quotaUser instead. ## Returns {:ok, %{}} on success {:error, info} on failure """ @spec games_management_scores_reset_all_for_all_players(Tesla.Env.client(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t()} def games_management_scores_reset_all_for_all_players(connection, opts \\ []) do optional_params = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query } request = Request.new() |> Request.method(:post) |> Request.url("/scores/resetAllForAllPlayers") |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(decode: false) end @doc """ Resets scores for the leaderboard with the given ID for all players. This method is only available to user accounts for your developer console. Only draft leaderboards can be reset. ## Parameters - connection (GoogleApi.GamesManagement.V1management.Connection): Connection to server - leaderboard_id (String.t): The ID of the leaderboard. - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for the response. - :fields (String.t): Selector specifying which fields to include in a partial response. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :oauth_token (String.t): OAuth 2.0 token for the current user. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :quotaUser (String.t): An opaque string that represents a user for quota purposes. Must not exceed 40 characters. - :userIp (String.t): Deprecated. Please use quotaUser instead. ## Returns {:ok, %{}} on success {:error, info} on failure """ @spec games_management_scores_reset_for_all_players(Tesla.Env.client(), String.t(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t()} def games_management_scores_reset_for_all_players(connection, leaderboard_id, opts \\ []) do optional_params = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query } request = Request.new() |> Request.method(:post) |> Request.url("/leaderboards/{leaderboardId}/scores/resetForAllPlayers", %{ "leaderboardId" => URI.encode_www_form(leaderboard_id) }) |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(decode: false) end @doc """ Resets scores for the leaderboards with the given IDs for all players. This method is only available to user accounts for your developer console. Only draft leaderboards may be reset. ## Parameters - connection (GoogleApi.GamesManagement.V1management.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :alt (String.t): Data format for the response. - :fields (String.t): Selector specifying which fields to include in a partial response. - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - :oauth_token (String.t): OAuth 2.0 token for the current user. - :prettyPrint (boolean()): Returns response with indentations and line breaks. - :quotaUser (String.t): An opaque string that represents a user for quota purposes. Must not exceed 40 characters. - :userIp (String.t): Deprecated. Please use quotaUser instead. - :body (ScoresResetMultipleForAllRequest): ## Returns {:ok, %{}} on success {:error, info} on failure """ @spec games_management_scores_reset_multiple_for_all_players(Tesla.Env.client(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t()} def games_management_scores_reset_multiple_for_all_players(connection, opts \\ []) do optional_params = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/scores/resetMultipleForAllPlayers") |> Request.add_optional_params(optional_params, opts) connection |> Connection.execute(request) |> Response.decode(decode: false) end end
41.122605
185
0.6944
79cf0bd3b73a6881674a04d79efef33834466f25
861
exs
Elixir
deps/phoenix_live_reload/mix.exs
dmitrinesterenko/sample_phoenix_ecs
d6b94f35680163302e372cf30c70d3e409b0c9b1
[ "MIT" ]
null
null
null
deps/phoenix_live_reload/mix.exs
dmitrinesterenko/sample_phoenix_ecs
d6b94f35680163302e372cf30c70d3e409b0c9b1
[ "MIT" ]
null
null
null
deps/phoenix_live_reload/mix.exs
dmitrinesterenko/sample_phoenix_ecs
d6b94f35680163302e372cf30c70d3e409b0c9b1
[ "MIT" ]
null
null
null
defmodule PhoenixLiveReload.Mixfile do use Mix.Project @version "1.0.1" def project do [app: :phoenix_live_reload, version: @version, elixir: "~> 1.0.2 or ~> 1.1-dev", deps: deps, # Hex description: "Provides live-reload functionality for Phoenix", package: package, # Docs name: "Phoenix Live-Reload", docs: [source_ref: "v#{@version}", source_url: "https://github.com/phoenixframework/phoenix_live_reload"]] end defp package do [contributors: ["Chris McCord"], licenses: ["MIT"], links: %{"GitHub" => "https://github.com/phoenixframework/phoenix_live_reload"}] end def application do [applications: [:logger, :phoenix, :fs]] end defp deps do [{:phoenix, "~> 0.16 or ~> 1.0"}, {:ex_doc, "~> 0.7.1", only: :docs}, {:fs, "~> 0.9.1"}] end end
22.657895
85
0.599303
79cf1d3d5cc2f1e6decb01c5a01b8a92188c9489
1,762
exs
Elixir
mix.exs
d-led/d-zen
25aec2d78e3053df055c0be9cdfac5673dc94f0f
[ "Unlicense" ]
null
null
null
mix.exs
d-led/d-zen
25aec2d78e3053df055c0be9cdfac5673dc94f0f
[ "Unlicense" ]
null
null
null
mix.exs
d-led/d-zen
25aec2d78e3053df055c0be9cdfac5673dc94f0f
[ "Unlicense" ]
null
null
null
defmodule Dzen.MixProject do use Mix.Project def project do [ app: :dzen, version: "0.1.0", elixir: "~> 1.12", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:gettext] ++ Mix.compilers(), start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps() ] end # Configuration for the OTP application. # # Type `mix help compile.app` for more information. def application do [ mod: {Dzen.Application, []}, extra_applications: [:logger, :runtime_tools] ] end # Specifies which paths to compile per environment. defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] # Specifies your project dependencies. # # Type `mix help deps` for examples and options. defp deps do [ {:phoenix, "~> 1.6.6"}, {:phoenix_html, "~> 3.0"}, {:phoenix_live_reload, "~> 1.2", only: :dev}, {:phoenix_live_view, "~> 0.17.5"}, {:floki, ">= 0.30.0", only: :test}, {:phoenix_live_dashboard, "~> 0.6"}, {:esbuild, "~> 0.3", runtime: Mix.env() == :dev}, {:ecto_sql, "~> 3.0"}, {:postgrex, ">= 0.0.0"}, {:swoosh, "~> 1.3"}, {:telemetry_metrics, "~> 0.6"}, {:telemetry_poller, "~> 1.0"}, {:gettext, "~> 0.18"}, {:jason, "~> 1.2"}, {:plug_cowboy, "~> 2.5"} ] end # Aliases are shortcuts or tasks specific to the current project. # For example, to install project dependencies and perform other setup tasks, run: # # $ mix setup # # See the documentation for `Mix` for more info on aliases. defp aliases do [ setup: ["deps.get"], "assets.deploy": ["esbuild default --minify", "phx.digest"] ] end end
26.298507
84
0.564132
79cf7fa95775d441456587c168f2d9063affdca9
1,584
ex
Elixir
server/web/controllers/team_controller.ex
MikaAK/trello-burndown
b78d97fa03fcdd60c1c9652b65d272936f648c6f
[ "MIT" ]
null
null
null
server/web/controllers/team_controller.ex
MikaAK/trello-burndown
b78d97fa03fcdd60c1c9652b65d272936f648c6f
[ "MIT" ]
3
2016-04-18T18:09:21.000Z
2016-04-25T07:29:59.000Z
server/web/controllers/team_controller.ex
MikaAK/trello-burndown
b78d97fa03fcdd60c1c9652b65d272936f648c6f
[ "MIT" ]
null
null
null
defmodule TrelloBurndown.TeamController do use TrelloBurndown.Web, :controller alias TrelloBurndown.Team def index(conn, _params) do teams = Repo.all(from p in Team, preload: [:team_members]) render(conn, "index.json", teams: teams) end def create(conn, team_params) do changeset = Team.changeset(%Team{}, team_params) case Repo.insert(changeset) do {:ok, team} -> conn |> put_status(:created) |> put_resp_header("location", team_path(conn, :show, team)) |> render("show.json", team: team) {:error, changeset} -> conn |> put_status(:unprocessable_entity) |> render(TrelloBurndown.ChangesetView, "error.json", changeset: changeset) end end def show(conn, %{"id" => id}) do team = Repo.get!(Team, id) render(conn, "show.json", team: team) end def update(conn, team_params) do team = from(t in Team, preload: [:team_members]) |> Repo.get!(team_params["id"]) changeset = Team.changeset(team, team_params) case Repo.update(changeset) do {:ok, team} -> render(conn, "show.json", team: team) {:error, changeset} -> conn |> put_status(:unprocessable_entity) |> render(TrelloBurndown.ChangesetView, "error.json", changeset: changeset) end end def delete(conn, %{"id" => id}) do team = Repo.get!(Team, id) # Here we use delete! (with a bang) because we expect # it to always work (and if it does not, it will raise). Repo.delete!(team) send_resp(conn, :no_content, "") end end
27.310345
83
0.625
79cfc6277e3c01ca1361ba8d9fd8c04a6b7ab73e
277
exs
Elixir
test/goals_test.exs
lupinthe14th/codewars
5c71a1be6dd5c42a6217d70e5cfcd43c6c016ac7
[ "MIT" ]
null
null
null
test/goals_test.exs
lupinthe14th/codewars
5c71a1be6dd5c42a6217d70e5cfcd43c6c016ac7
[ "MIT" ]
70
2020-01-07T01:21:38.000Z
2021-06-18T02:57:39.000Z
test/goals_test.exs
lupinthe14th/codewars
5c71a1be6dd5c42a6217d70e5cfcd43c6c016ac7
[ "MIT" ]
null
null
null
defmodule TestGoals do use ExUnit.Case defp testing(a, b, c, e) do ac = Goals.goals(a, b, c) assert ac == e, "Given numbers #{a}, #{b}, and #{c}: Expected #{e}, got #{ac}" end test "fixed tests" do testing(0, 0, 0, 0) testing(43, 10, 5, 58) end end
19.785714
82
0.563177
79cff7d55c88cede177d2d1c51a36dd44e0d6c7f
938
ex
Elixir
test/support/channel_case.ex
sickill/flash
8797cb00b70c94b6f3bdd51e9cb456483f1c5741
[ "Apache-2.0" ]
1
2021-09-08T16:56:39.000Z
2021-09-08T16:56:39.000Z
test/support/channel_case.ex
sickill/flash
8797cb00b70c94b6f3bdd51e9cb456483f1c5741
[ "Apache-2.0" ]
null
null
null
test/support/channel_case.ex
sickill/flash
8797cb00b70c94b6f3bdd51e9cb456483f1c5741
[ "Apache-2.0" ]
null
null
null
defmodule FlashWeb.ChannelCase do @moduledoc """ This module defines the test case to be used by channel tests. Such tests rely on `Phoenix.ChannelTest` and also import other functionality to make it easier to build common data structures and query the data layer. Finally, if the test case interacts with the database, we enable the SQL sandbox, so changes done to the database are reverted at the end of every test. If you are using PostgreSQL, you can even run database tests asynchronously by setting `use FlashWeb.ChannelCase, async: true`, although this option is not recommended for other databases. """ use ExUnit.CaseTemplate using do quote do # Import conveniences for testing with channels import Phoenix.ChannelTest import FlashWeb.ChannelCase # The default endpoint for testing @endpoint FlashWeb.Endpoint end end setup _tags do :ok end end
26.8
62
0.736674
79d020e53ffd51a794f425b8faca4e7fa00e27ed
13,795
ex
Elixir
lib/tds/tokens.ex
pressrelations/tds
a05120c6064b9561860695242ebff37037f01165
[ "Apache-2.0" ]
null
null
null
lib/tds/tokens.ex
pressrelations/tds
a05120c6064b9561860695242ebff37037f01165
[ "Apache-2.0" ]
null
null
null
lib/tds/tokens.ex
pressrelations/tds
a05120c6064b9561860695242ebff37037f01165
[ "Apache-2.0" ]
null
null
null
defmodule Tds.Tokens do import Tds.BinaryUtils import Tds.Utils require Logger alias Tds.Types # 0x79 @tds_token_returnstatus 0x79 # 0x81 @tds_token_colmetadata 0x81 # 0xA9 @tds_token_order 0xA9 # 0xAA @tds_token_error 0xAA # 0xAB @tds_token_info 0xAB @tds_token_returnvalue 0xAC @tds_token_loginack 0xAD # 0xD1 - ROW @tds_token_row 0xD1 # 0xD2 - NBCROW @tds_token_nbcrow 0xD2 # 0xE3 @tds_token_envchange 0xE3 # @tds_token_sspi 0xED # 0xED # 0xFD @tds_token_done 0xFD # 0xFE @tds_token_doneproc 0xFE # 0xFF @tds_token_doneinproc 0xFF @tds_envtype_database 1 # @tds_envtype_language 2 # @tds_envtype_charset 3 @tds_envtype_packetsize 4 @tds_envtype_begintrans 8 @tds_envtype_committrans 9 @tds_envtype_rollbacktrans 10 @tds_envtype_routing 20 ## Decode Token Stream def decode_tokens(tail, tokens) when tail == "" or tail == nil do tokens end def decode_tokens(<<tail::binary>>, tokens) do {tokens, tail} = decode_token(tail, tokens) decode_tokens(tail, tokens) end def retval_typ_size(38) do # 0x26 - SYBINTN - 1 8 end def retval_typ_size(dec) do # Undefined raise Tds.Error, "Unknown datatype parsed when decoding return value: #{dec}" end defp decode_value(<<0x26, size::size(8), size::size(8), data::binary>>) do <<value::little-size(size)-unit(8), data::binary>> = data {value, data} end defp decode_token(<<@tds_token_returnvalue, data::binary>>, tokens) do << _ord::little-unsigned-16, length::size(8), name::binary-size(length)-unit(16), _status::size(8), _usertype::size(32), _flags::size(16), data::binary >> = data name = ucs2_to_utf(name) {value, data} = decode_value(data) {[parameters: {name, value}] ++ tokens, data} end defp decode_token( <<@tds_token_returnstatus, _value::little-size(32), data::binary>>, tokens ) do # todo: add retrun status into tokens {tokens, data} end # COLMETADATA defp decode_token( <<@tds_token_colmetadata, column_count::little-(2 * 8), tail::binary>>, tokens ) do columns = [] {columns, tail} = decode_columns(tail, columns, column_count) {[columns: columns] ++ tokens, tail} end # ORDER defp decode_token( <<@tds_token_order, length::little-unsigned-16, tail::binary>>, tokens ) do length = trunc(length / 2) {columns, tail} = decode_column_order(tail, length, []) {[order: columns] ++ tokens, tail} end # ERROR defp decode_token( << @tds_token_error, length::little-size(16), number::little-size(32), state, class, msg_len::little-size(16), msg::binary-size(msg_len)-unit(16), sn_len, server_name::binary-size(sn_len)-unit(16), pn_len, proc_name::binary-size(pn_len)-unit(16), line_number::little-size(32), _data::binary >>, _tokens ) do e = %{ length: length, number: number, state: state, class: class, msg_text: ucs2_to_utf(msg), server_name: ucs2_to_utf(server_name), proc_name: ucs2_to_utf(proc_name), line_number: line_number } # TODO Need to concat errors for delivery # Logger.debug "SQL Error: #{inspect e}" {[error: e], nil} end defp decode_token( << @tds_token_info, length::little-size(16), number::little-size(32), state, class, msg_len::little-size(16), msg::binary-size(msg_len)-unit(16), sn_len, server_name::binary-size(sn_len)-unit(16), pn_len, proc_name::binary-size(pn_len)-unit(16), line_number::little-size(32), tail::binary >>, tokens ) do i = %{ length: length, number: number, state: state, class: class, msg_text: ucs2_to_utf(msg), server_name: ucs2_to_utf(server_name), proc_name: ucs2_to_utf(proc_name), line_number: line_number } tokens = Keyword.update(tokens, :info, [i], & [i|&1]) {tokens, tail} end ## ROW defp decode_token(<<@tds_token_row, tail::binary>>, tokens) do column_count = Enum.count(tokens[:columns]) {row, tail} = decode_row_columns(tail, tokens, [], column_count, 0) row = row |> Enum.reverse() tokens = Keyword.update(tokens, :rows, [row], fn _x -> [row | tokens[:rows]] end) {tokens, tail} end ## NBC ROW defp decode_token(<<@tds_token_nbcrow, tail::binary>>, tokens) do column_count = Enum.count(tokens[:columns]) {bitmap_bytes, _} = column_count |> Kernel./(8) |> Float.ceil() |> :erlang.float_to_list(decimals: 0) |> to_string |> Integer.parse() {bitmap, tail} = bitmap_list([], tail, bitmap_bytes) bitmap = bitmap |> Enum.reverse() {row, tail} = decode_row_columns(tail, tokens, [], column_count, 0, bitmap) row = row |> Enum.reverse() tokens = Keyword.update(tokens, :rows, [row], fn _x -> [row | tokens[:rows]] end) {tokens, tail} end defp decode_token( << @tds_token_envchange, _length::little-unsigned-16, env_type::unsigned-8, tail::binary >>, tokens ) do case env_type do @tds_envtype_database -> << new_value_size::unsigned-8, new_value::binary-little-size(new_value_size)-unit(8), old_value_size::unsigned-8, old_value::binary-little-size(old_value_size)-unit(8), rest::binary >> = tail Logger.debug(fn -> "Switching from #{new_value} database to #{old_value}" end) {tokens |> Keyword.put(:database, new_value), rest} @tds_envtype_packetsize -> << new_value_size::unsigned-8, new_value::binary(new_value_size, 16), old_value_size::unsigned-8, old_value::binary(old_value_size, 16), rest::binary >> = tail new_value = ucs2_to_utf(new_value) old_value = ucs2_to_utf(old_value) if(new_value != old_value) do Logger.debug(fn -> """ Database server configured packetsize to #{new_value} where old value was #{old_value} """ end) end {tokens |> Keyword.put(:packetsize, new_value), rest} @tds_envtype_begintrans -> << value_size::unsigned-8, new_value::binary-little-size(value_size)-unit(8), 0x00, rest::binary >> = tail {tokens |> Keyword.put(:trans, new_value), rest} @tds_envtype_committrans -> << 0x00, value_size::unsigned-8, _old_value::binary-little-size(value_size)-unit(8), rest::binary >> = tail {tokens |> Keyword.put(:trans, <<0x00>>), rest} @tds_envtype_rollbacktrans -> << 0x00, value_size::unsigned-8, _old_value::binary-little-size(value_size)-unit(8), rest::binary >> = tail {tokens |> Keyword.put(:trans, <<0x00>>), rest} @tds_envtype_routing -> << _routing_data_len::little-uint16, 0x00, #Protocol MUST be 0, specifying TCP-IP protocol port::little-uint16, alt_host_len::little-uint16, alt_host::binary(alt_host_len, 16), 0x00, 0x00, rest::binary >> = tail token = %{ hostname: ucs2_to_utf(alt_host), port: port } {tokens |> Keyword.put(:env_redirect, token), rest} end end ## DONE defp decode_token( << @tds_token_done, status::int16, cur_cmd::binary(2), row_count::little-size(8)-unit(8), _tail::binary >>, tokens ) do case Keyword.get(tokens, :done) do nil -> { Keyword.put(tokens, :done, %{ status: status, cmd: cur_cmd, rows: row_count }), nil } %{rows: rows} when row_count > rows -> { Keyword.put(tokens, :done, %{ status: status, cmd: cur_cmd, rows: row_count }), nil } _ -> {tokens, nil} end end ## DONEPROC defp decode_token( << @tds_token_doneproc, status::int16, cur_cmd::binary(2), row_count::little-size(8)-unit(8), _tail::binary >>, tokens ) do case Keyword.get(tokens, :done) do nil -> { Keyword.put(tokens, :done, %{ status: status, cmd: cur_cmd, rows: row_count }), nil } %{rows: rows} when row_count > rows -> { Keyword.put(tokens, :done, %{ status: status, cmd: cur_cmd, rows: row_count }), nil } _ -> {tokens, nil} end end ## DONEINPROC defp decode_token( << @tds_token_doneinproc, status::int16, cur_cmd::little-size(8)-unit(2), row_count::little-size(8)-unit(8), # _something::binary-size(5), tail::binary >>, tokens ) do case Keyword.get(tokens, :done) do nil -> { Keyword.put(tokens, :done, %{ status: status, cmd: cur_cmd, rows: row_count }), tail } %{rows: rows} when row_count > rows -> { Keyword.put(tokens, :done, %{ status: status, cmd: cur_cmd, rows: row_count }), nil } _ -> {tokens, nil} end # case tokens do # [done: done] -> # cond do # row_count > done.rows -> {[done: %{status: status, cmd: cur_cmd, # rows: row_count}] ++ tokens, nil} # true -> {tokens, tail} # end # {tokens, nil} # _ -> {[done: %{status: status, cmd: cur_cmd, rows: row_count}] ++ # tokens, tail} # end end defp decode_token( << @tds_token_loginack, _length::little-uint16, interface :: size(8), tds_version::binary(4), prog_name_len::size(8), prog_name::binary(prog_name_len, 16), major_ver::size(8), minor_ver::size(8), build_hi::size(8), build_low::size(8), tail::binary >>, tokens ) do token = %{ t_sql_only: interface == 1, tds_version: "0x#{Base.encode16(tds_version)}", program: "#{ucs2_to_utf(prog_name)}", version: "#{major_ver}.#{minor_ver}.#{build_hi}.#{build_low}" } {Keyword.put(tokens, :login_ack, token), tail} end defp decode_column_order(<<tail::binary>>, n, columns) when n == 0 do {columns, tail} end defp decode_column_order( <<col_id::little-unsigned-16, tail::binary>>, n, columns ) do decode_column_order(tail, n - 1, [col_id | columns]) end ## Row and Column Decoders defp bitmap_list(bitmap, <<tail::binary>>, n) when n <= 0 do {bitmap, tail} end defp bitmap_list(bitmap, <<byte::binary-size(1)-unit(8), tail::binary>>, n) when n > 0 do list = for <<bit::1 <- byte>>, do: bit bitmap_list(list ++ bitmap, tail, n - 1) end defp decode_columns(<<tail::binary>>, columns, n) when n < 1 do {Enum.reverse(columns), tail} end defp decode_columns(<<tail::binary>>, columns, n) do {column, tail} = decode_column(tail) decode_columns(tail, [column | columns], n - 1) end defp decode_column(<<_usertype::int32, _flags::int16, tail::binary>>) do {info, tail} = Types.decode_info(tail) {name, tail} = decode_column_name(tail) info = info |> Map.put(:name, name) {info, tail} end defp decode_column_name(<< name_length::int8, name::unicode(name_length), tail::binary >>) do name = name |> :unicode.characters_to_binary({:utf16, :little}, :utf8) {name, tail} end defp decode_row_columns(<<tail::binary>>, _tokens, row, column_count, n) when n >= column_count do {row, tail} end defp decode_row_columns(<<tail::binary>>, tokens, row, column_count, n) do {:ok, column} = Enum.fetch(tokens[:columns], n) {value, tail} = decode_row_column(tail, column) row = [value | row] decode_row_columns(tail, tokens, row, column_count, n + 1) end defp decode_row_columns( <<tail::binary>>, _tokens, row, column_count, n, _bitmap ) when n >= column_count do {row, tail} end defp decode_row_columns( <<tail::binary>>, tokens, row, column_count, n, bitmap ) do {value, tail} = case Enum.fetch(bitmap, n) do {:ok, 0} -> {:ok, column} = Enum.fetch(tokens[:columns], n) decode_row_column(tail, column) {_, _} -> {nil, tail} end row = [value | row] decode_row_columns(tail, tokens, row, column_count, n + 1, bitmap) end defp decode_row_column(<<tail::binary>>, column) do Types.decode_data(column, tail) end end
24.415929
81
0.542443
79d040689b45ac0fb72766bbcdc92d9ed4b116ec
126
ex
Elixir
apps/web/lib/web/controllers/page_controller.ex
alejandrodnm/ranking_poller
f7d231e928f1c467bfbffd8bab2b6947bdb0b87a
[ "MIT" ]
2
2019-03-22T12:29:37.000Z
2021-01-08T17:25:32.000Z
lib/web/controllers/page_controller.ex
oestrich/raisin
7a0cf13768a8e59b023f8e940c73e7c7eeff18e8
[ "MIT" ]
8
2017-12-04T16:53:35.000Z
2018-04-08T11:01:46.000Z
apps/web/lib/web/controllers/page_controller.ex
friendshipismagic/Hekateros
0d340b6818583e2e65b0395227c9bb91796e5f89
[ "MIT" ]
null
null
null
defmodule Web.PageController do use Web, :controller def index(conn, _params) do render conn, "index.html" end end
15.75
31
0.714286
79d074b451eb301a8537f8ce7ca26ce0bb70ed8d
3,379
ex
Elixir
lib/elixir/lib/task/supervised.ex
jbcrail/elixir
f30ef15d9d028a6d0f74d10c2bb320d5f8501bdb
[ "Apache-2.0" ]
1
2015-02-23T00:01:48.000Z
2015-02-23T00:01:48.000Z
lib/elixir/lib/task/supervised.ex
jbcrail/elixir
f30ef15d9d028a6d0f74d10c2bb320d5f8501bdb
[ "Apache-2.0" ]
null
null
null
lib/elixir/lib/task/supervised.ex
jbcrail/elixir
f30ef15d9d028a6d0f74d10c2bb320d5f8501bdb
[ "Apache-2.0" ]
null
null
null
defmodule Task.Supervised do @moduledoc false def start(info, fun) do {:ok, :proc_lib.spawn(__MODULE__, :noreply, [info, fun])} end def start_link(info, fun) do {:ok, :proc_lib.spawn_link(__MODULE__, :noreply, [info, fun])} end def start_link(caller, info, fun) do :proc_lib.start_link(__MODULE__, :reply, [caller, info, fun]) end def async(caller, info, mfa) do initial_call(mfa) ref = receive do: ({^caller, ref} -> ref) send caller, {ref, do_apply(info, mfa)} end def reply(caller, info, mfa) do initial_call(mfa) :erlang.link(caller) :proc_lib.init_ack({:ok, self()}) ref = # There is a race condition on this operation when working accross # node that manifests if a `Task.Supervisor.async/1` call is made # while the supervisor is busy spawning previous tasks. # # Imagine the following workflow: # # 1. The nodes disconnect # 2. The async call fails and is caught, the calling process does not exit # 3. The task is spawned and links to the calling process, causing the nodes to reconnect # 4. The calling process has not exited and so does not send its monitor reference # 5. The spawned task waits forever for the monitor reference so it can begin # # We have solved this by specifying a timeout of 5000 seconds. # Given no work is done in the client in between the task start and # sending the reference, 5000 should be enough to not raise false # negatives unless the nodes are indeed not available. receive do {^caller, ref} -> ref after 5000 -> exit(:timeout) end send caller, {ref, do_apply(info, mfa)} end def noreply(info, mfa) do initial_call(mfa) do_apply(info, mfa) end defp initial_call(mfa) do Process.put(:"$initial_call", get_initial_call(mfa)) end defp get_initial_call({:erlang, :apply, [fun, []]}) when is_function(fun, 0) do {:module, module} = :erlang.fun_info(fun, :module) {:name, name} = :erlang.fun_info(fun, :name) {module, name, 0} end defp get_initial_call({mod, fun, args}) do {mod, fun, length(args)} end defp do_apply(info, {module, fun, args} = mfa) do try do apply(module, fun, args) catch :error, value -> exit(info, mfa, {value, System.stacktrace()}) :throw, value -> exit(info, mfa, {{:nocatch, value}, System.stacktrace()}) :exit, value -> exit(info, mfa, value) end end defp exit(_info, _mfa, reason) when reason == :normal when reason == :shutdown when tuple_size(reason) == 2 and elem(reason, 0) == :shutdown do exit(reason) end defp exit(info, mfa, reason) do {fun, args} = get_running(mfa) :error_logger.format( '** Task ~p terminating~n' ++ '** Started from ~p~n' ++ '** When function == ~p~n' ++ '** arguments == ~p~n' ++ '** Reason for termination == ~n' ++ '** ~p~n', [self, get_from(info), fun, args, reason]) exit(reason) end defp get_from({node, pid_or_name}) when node == node(), do: pid_or_name defp get_from(other), do: other defp get_running({:erlang, :apply, [fun, []]}) when is_function(fun, 0), do: {fun, []} defp get_running({mod, fun, args}), do: {:erlang.make_fun(mod, fun, length(args)), args} end
30.169643
95
0.624741
79d0b9aca69c3de7d9f305d30f3fc9b2ac17c7e5
2,259
exs
Elixir
mix.exs
donatienLef/api
d3fedb3fc4943221dd3fbdf2bb2348a41a42b614
[ "MIT" ]
null
null
null
mix.exs
donatienLef/api
d3fedb3fc4943221dd3fbdf2bb2348a41a42b614
[ "MIT" ]
null
null
null
mix.exs
donatienLef/api
d3fedb3fc4943221dd3fbdf2bb2348a41a42b614
[ "MIT" ]
1
2020-03-17T20:31:21.000Z
2020-03-17T20:31:21.000Z
defmodule RealWorld.Mixfile do use Mix.Project def project do [ app: :real_world, version: "0.0.1", elixir: "~> 1.5", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps(), test_coverage: [tool: ExCoveralls], # Docs name: "RealWorld Example App", source_url: "https://github.com/gothinkster/elixir-phoenix-realworld-example-app", homepage_url: "https://github.com/gothinkster/elixir-phoenix-realworld-example-app", # The main page in the docs docs: [main: "RealWorld Example App", logo: "logo.png", extras: ["README.md"]] ] end # Configuration for the OTP application. # # Type `mix help compile.app` for more information. def application do [mod: {RealWorld.Application, []}, extra_applications: [:logger, :runtime_tools, :comeonin]] end # Specifies which paths to compile per environment. defp elixirc_paths(:test), do: ["lib", "test/support", "test/factories"] defp elixirc_paths(_), do: ["lib"] # Specifies your project dependencies. # # Type `mix help deps` for examples and options. defp deps do [ {:phoenix, "~> 1.3.0"}, {:phoenix_pubsub, "~> 1.0"}, {:phoenix_ecto, "~> 3.2"}, {:postgrex, "~> 0.13.3"}, {:gettext, "~> 0.11"}, {:proper_case, "~> 1.0.0"}, {:cowboy, "~> 1.1"}, {:comeonin, "~> 3.2"}, {:guardian, "~> 1.0"}, {:excoveralls, "~> 0.7", only: [:dev, :test]}, {:credo, "~> 0.8.5", only: [:dev, :test]}, {:ex_machina, "~> 2.0", only: :test}, {:ex_doc, "~> 0.16", only: :dev, runtime: false}, {:plug, "~> 1.0"}, {:corsica, "~> 1.0"} ] end # Aliases are shortcuts or tasks specific to the current project. # For example, to create, migrate and run the seeds file at once: # # $ mix ecto.setup # # See the documentation for `Mix` for more info on aliases. defp aliases do [ "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], "ecto.reset": ["ecto.drop", "ecto.setup"], test: ["ecto.create --quiet", "ecto.migrate", "test"] ] end end
30.945205
96
0.582116
79d0c7e7a1054bb25e661f4f569ab88a1088952f
1,768
exs
Elixir
clients/cloud_trace/mix.exs
yoshi-code-bot/elixir-google-api
cdb6032f01fac5ab704803113c39f2207e9e019d
[ "Apache-2.0" ]
null
null
null
clients/cloud_trace/mix.exs
yoshi-code-bot/elixir-google-api
cdb6032f01fac5ab704803113c39f2207e9e019d
[ "Apache-2.0" ]
null
null
null
clients/cloud_trace/mix.exs
yoshi-code-bot/elixir-google-api
cdb6032f01fac5ab704803113c39f2207e9e019d
[ "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.CloudTrace.Mixfile do use Mix.Project @version "0.23.2" def project() do [ app: :google_api_cloud_trace, version: @version, elixir: "~> 1.6", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, description: description(), package: package(), deps: deps(), source_url: "https://github.com/googleapis/elixir-google-api/tree/master/clients/cloud_trace" ] end def application() do [extra_applications: [:logger]] end defp deps() do [ {:google_gax, "~> 0.4"}, {:ex_doc, "~> 0.16", only: :dev} ] end defp description() do """ Cloud Trace API client library. """ end defp package() do [ files: ["lib", "mix.exs", "README*", "LICENSE"], maintainers: ["Jeff Ching", "Daniel Azuma"], licenses: ["Apache 2.0"], links: %{ "GitHub" => "https://github.com/googleapis/elixir-google-api/tree/master/clients/cloud_trace", "Homepage" => "https://cloud.google.com/trace" } ] end end
26.38806
102
0.648756
79d11bfb3fdf306bff9360250d88ae2bcbb8e031
1,131
exs
Elixir
bench/section_block_access_all_bench.exs
McEx/chunk-ex
f0307629efb7e64ddb07612926c1fb5fcc615183
[ "MIT" ]
4
2016-06-16T23:26:11.000Z
2021-07-08T12:05:06.000Z
bench/section_block_access_all_bench.exs
Gjum/chunk-ex
f0307629efb7e64ddb07612926c1fb5fcc615183
[ "MIT" ]
null
null
null
bench/section_block_access_all_bench.exs
Gjum/chunk-ex
f0307629efb7e64ddb07612926c1fb5fcc615183
[ "MIT" ]
3
2016-04-09T21:06:01.000Z
2021-07-27T13:39:51.000Z
defmodule McChunk.Bench.SectionBlockAccessAll do use Benchfella alias McChunk.Section defp build_section(palette_len) do Section.new_with_palette(for i <- 1..palette_len, do: i) end bench "Section.get_block (1 bit, all indices)", [section: build_section(2)], do: for index <- 0..4095, do: Section.get_block(section, index) bench "Section.get_block (5 bits, all indices)", [section: build_section(32)], do: for index <- 0..4095, do: Section.get_block(section, index) bench "Section.get_block (7 bits, all indices)", [section: build_section(128)], do: for index <- 0..4095, do: Section.get_block(section, index) bench "Section.set_block (1 bit, all indices)", [section: build_section(2)], do: for index <- 0..4095, do: Section.set_block(section, index, 1) bench "Section.set_block (5 bits, all indices)", [section: build_section(32)], do: for index <- 0..4095, do: Section.set_block(section, index, 1) bench "Section.set_block (7 bits, all indices)", [section: build_section(128)], do: for index <- 0..4095, do: Section.set_block(section, index, 1) end
33.264706
70
0.683466
79d11c6428d27f051ebb62da40f4871741db250a
994
ex
Elixir
apps/core/test/support/il_factories/register_factory.ex
ehealth-ua/ehealth.api
4ffe26a464fe40c95fb841a4aa2e147068f65ca2
[ "Apache-2.0" ]
8
2019-06-14T11:34:49.000Z
2021-08-05T19:14:24.000Z
apps/core/test/support/il_factories/register_factory.ex
edenlabllc/ehealth.api.public
4ffe26a464fe40c95fb841a4aa2e147068f65ca2
[ "Apache-2.0" ]
1
2019-07-08T15:20:22.000Z
2019-07-08T15:20:22.000Z
apps/core/test/support/il_factories/register_factory.ex
ehealth-ua/ehealth.api
4ffe26a464fe40c95fb841a4aa2e147068f65ca2
[ "Apache-2.0" ]
6
2018-05-11T13:59:32.000Z
2022-01-19T20:15:22.000Z
defmodule Core.ILFactories.RegisterFactory do @moduledoc false defmacro __using__(_opts) do quote do def register_factory do uuid = Ecto.UUID.generate() %Core.Registers.Register{ qty: %{ total: 0, errors: 0, not_found: 0, processing: 0 }, file_name: "Some name", type: Core.Registers.Register.type(:death), status: Core.Registers.Register.status(:new), inserted_by: uuid, updated_by: uuid } end def register_entry_factory do uuid = Ecto.UUID.generate() %Core.Registers.RegisterEntry{ status: Core.Registers.Register.status(:new), document_type: "TAX_ID", document_number: sequence("222222222"), inserted_by: uuid, updated_by: uuid, register: insert(:il, :register), person_id: Ecto.UUID.generate() } end end end end
24.85
55
0.557344
79d14463dc06b7a20a92101ef256901ea0ce0bfd
7,793
exs
Elixir
components/notifications-service/server/test/formatters/servicenow_test.exs
MsysTechnologiesllc/automate
633e3efe43c3e8da808a120381448198282b7c0b
[ "Apache-2.0" ]
4
2019-10-24T05:59:51.000Z
2021-08-16T15:17:27.000Z
components/notifications-service/server/test/formatters/servicenow_test.exs
MsysTechnologiesllc/automate
633e3efe43c3e8da808a120381448198282b7c0b
[ "Apache-2.0" ]
null
null
null
components/notifications-service/server/test/formatters/servicenow_test.exs
MsysTechnologiesllc/automate
633e3efe43c3e8da808a120381448198282b7c0b
[ "Apache-2.0" ]
null
null
null
defmodule Notifications.Formatters.ServiceNow.Test do use ExUnit.Case, async: false doctest Notifications.Formatters.ServiceNow alias Notifications.Formatters.ServiceNow describe "#format" do test "that a populated CCR notification creates the correct webhook paylaod" do exception_backtrace = [ "/Users/aleff/projects/chef/lib/chef/mixin/why_run.rb:240:in `run'", "/Users/aleff/projects/chef/lib/chef/mixin/why_run.rb:321:in `block in run'", "/Users/aleff/projects/chef/lib/chef/mixin/why_run.rb:320:in `each'", "/Users/aleff/projects/chef/lib/chef/mixin/why_run.rb:320:in `run'", "/Users/aleff/projects/chef/lib/chef/provider.rb:155:in `process_resource_requirements'", "/Users/aleff/projects/chef/lib/chef/provider.rb:133:in `run_action'", "/Users/aleff/projects/chef/lib/chef/resource.rb:591:in `run_action'", "/Users/aleff/projects/chef/lib/chef/runner.rb:69:in `run_action'", "/Users/aleff/projects/chef/lib/chef/runner.rb:97:in `block (2 levels) in converge'", "/Users/aleff/projects/chef/lib/chef/runner.rb:97:in `each'", "/Users/aleff/projects/chef/lib/chef/runner.rb:97:in `block in converge'", "/Users/aleff/projects/chef/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'", "/Users/aleff/projects/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'", "/Users/aleff/projects/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'", "/Users/aleff/projects/chef/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'", "/Users/aleff/projects/chef/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'", "/Users/aleff/projects/chef/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'", "/Users/aleff/projects/chef/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'", "/Users/aleff/projects/chef/lib/chef/runner.rb:96:in `converge'", "/Users/aleff/projects/chef/lib/chef/client.rb:669:in `block in converge'", "/Users/aleff/projects/chef/lib/chef/client.rb:664:in `catch'", "/Users/aleff/projects/chef/lib/chef/client.rb:664:in `converge'", "/Users/aleff/projects/chef/lib/chef/client.rb:703:in `converge_and_save'", "/Users/aleff/projects/chef/lib/chef/client.rb:283:in `run'", "/Users/aleff/projects/chef/lib/chef/application.rb:286:in `block in fork_chef_client'", "/Users/aleff/projects/chef/lib/chef/application.rb:274:in `fork'", "/Users/aleff/projects/chef/lib/chef/application.rb:274:in `fork_chef_client'", "/Users/aleff/projects/chef/lib/chef/application.rb:239:in `block in run_chef_client'", "/Users/aleff/projects/chef/lib/chef/local_mode.rb:44:in `with_server_connectivity'", "/Users/aleff/projects/chef/lib/chef/application.rb:227:in `run_chef_client'", "/Users/aleff/projects/chef/lib/chef/application/client.rb:456:in `sleep_then_run_chef_client'", "/Users/aleff/projects/chef/lib/chef/application/client.rb:443:in `block in interval_run_chef_client'", "/Users/aleff/projects/chef/lib/chef/application/client.rb:442:in `loop'", "/Users/aleff/projects/chef/lib/chef/application/client.rb:442:in `interval_run_chef_client'", "/Users/aleff/projects/chef/lib/chef/application/client.rb:426:in `run_application'", "/Users/aleff/projects/chef/lib/chef/application.rb:59:in `run'", "/Users/aleff/projects/chef/bin/chef-client:26:in `<top (required)>'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/bin/chef-client:22:in `load'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/bin/chef-client:22:in `<top (required)>'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `load'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `kernel_load'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:24:in `run'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/gems/bundler-1.12.5/lib/bundler/cli.rb:304:in `exec'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/gems/bundler-1.12.5/exe/bundle:27:in `block in <top (required)>'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/gems/bundler-1.12.5/exe/bundle:19:in `<top (required)>'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/bin/bundle:22:in `load'", "/Users/aleff/.chefdk/gem/ruby/2.1.0/bin/bundle:22:in `<main>'" ] notification = %Notifications.CCRFailure{ run_id: "", node_name: "insights.chef.co", node_url: "chef-server.insights.co", run_url: "https://localhost/nodes/0271e125-97dd-498a-b026-8448ee60aafe/runs/ba6acb91-1eaa-4c84-8d68-f19ee641e606", cookbook: "test-cookbook", recipe: "", time: %Notifications.TimeInfo{start_time: "2016-06-28T20:05:29.000000Z", end_time: "2016-06-28T20:05:30.000000Z"}, timestamp: "2016-06-28T20:05:31.000000Z", exception: %Notifications.ExceptionInfo{class: "", title: "Error executing action `create` on resource 'file[/failed/file/resource]'", msg: "file[/failed/file/resource] (insights-test::default line 26) had an error: Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /failed/file does not exist.", backtrace: exception_backtrace}} expected = %{automate_failure_url: "https://localhost/nodes/0271e125-97dd-498a-b026-8448ee60aafe/runs/ba6acb91-1eaa-4c84-8d68-f19ee641e606", automate_fqdn: "http://localhost", cookbook: "test-cookbook", end_time_utc: "2016-06-28T20:05:30.000000Z", exception_message: "file[/failed/file/resource] (insights-test::default line 26) had an error: Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /failed/file does not exist.", exception_title: "Error executing action `create` on resource 'file[/failed/file/resource]'", failure_snippet: "Chef client run failure on [chef-server.insights.co] insights.chef.co : https://localhost/nodes/0271e125-97dd-498a-b026-8448ee60aafe/runs/ba6acb91-1eaa-4c84-8d68-f19ee641e606\nError executing action `create` on resource 'file[/failed/file/resource]'\nfile[/failed/file/resource] (insights-test::default line 26) had an error: Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /failed/file does not exist. \n", node_name: "insights.chef.co", start_time_utc: "2016-06-28T20:05:29.000000Z", type: "converge_failure", timestamp_utc: "2016-06-28T20:05:31.000000Z", exception_backtrace: exception_backtrace } assert expected == ServiceNow.format(notification) end end end
80.340206
454
0.679328
79d14bb71787d8f017b102e85b807dcbb583f51e
1,105
ex
Elixir
lib/mix_test_watch.ex
mnishiguchi/mix-test.watch
275fb0dffd49c72ee040a0b84234b8ec3f25c19c
[ "MIT" ]
null
null
null
lib/mix_test_watch.ex
mnishiguchi/mix-test.watch
275fb0dffd49c72ee040a0b84234b8ec3f25c19c
[ "MIT" ]
null
null
null
lib/mix_test_watch.ex
mnishiguchi/mix-test.watch
275fb0dffd49c72ee040a0b84234b8ec3f25c19c
[ "MIT" ]
null
null
null
defmodule MixTestWatch do @moduledoc """ Automatically run your Elixir project's tests each time you save a file. Because TDD is awesome. """ use Application alias MixTestWatch.Watcher # # Public interface # @spec run([String.t()]) :: no_return def run(args \\ []) when is_list(args) do Mix.env(:test) put_config(args) :ok = Application.ensure_started(:file_system) :ok = Application.ensure_started(:mix_test_watch) Watcher.run_tasks() no_halt_unless_in_repl() end # # Application callback # def start(_type, _args) do import Supervisor.Spec, warn: false children = [ worker(Watcher, []) ] opts = [strategy: :one_for_one, name: Sup.Supervisor] Supervisor.start_link(children, opts) end # # Internal functions # defp put_config(args) do config = MixTestWatch.Config.new(args) Application.put_env(:mix_test_watch, :__config__, config, persistent: true) end defp no_halt_unless_in_repl do unless Code.ensure_loaded?(IEx) && IEx.started?() do :timer.sleep(:infinity) end end end
20.462963
79
0.676018
79d164308f92b3e80be7b3c3c61c1f60f53fe438
118
exs
Elixir
config/config.exs
maynewong/estuary
49158372a2ff1a93ec72166f7aaa83ff79973184
[ "MIT" ]
null
null
null
config/config.exs
maynewong/estuary
49158372a2ff1a93ec72166f7aaa83ff79973184
[ "MIT" ]
null
null
null
config/config.exs
maynewong/estuary
49158372a2ff1a93ec72166f7aaa83ff79973184
[ "MIT" ]
null
null
null
import Config config :estuary, slack_webhooks: "", time_interval: 4*60*60 import_config "#{Mix.env()}.secret.exs"
14.75
39
0.720339
79d169b70df1ac7b5094147c4137393e13c13105
5,368
ex
Elixir
lib/mix/triplex.ex
anamba/triplex
cdb16cc29b9fc100cde07f09a9e0cec7d07aab7d
[ "MIT" ]
null
null
null
lib/mix/triplex.ex
anamba/triplex
cdb16cc29b9fc100cde07f09a9e0cec7d07aab7d
[ "MIT" ]
null
null
null
lib/mix/triplex.ex
anamba/triplex
cdb16cc29b9fc100cde07f09a9e0cec7d07aab7d
[ "MIT" ]
null
null
null
defmodule Mix.Triplex do @moduledoc """ Useful functions for any triplex mix task. Here is the list of tasks we have for now: - [`mix triplex.gen.migration`](./Mix.Tasks.Triplex.Gen.Migration.html) - generates a tenant migration for the repo - [`mix triplex.migrate`](./Mix.Tasks.Triplex.Migrate.html) - runs the repository tenant migrations - [`mix triplex.migrations`](./Mix.Tasks.Triplex.Migrations.html) - displays the repository migration status - [`mix triplex.rollback`](./Mix.Tasks.Triplex.Rollback.html) - rolls back the repository tenant migrations """ alias Ecto.Migrator alias Logger.App alias Mix.Ecto alias Mix.Project @aliases [ r: :repo, n: :step ] @switches [ all: :boolean, step: :integer, to: :integer, start: :boolean, quiet: :boolean, prefix: :string, pool_size: :integer, log_sql: :boolean, strict_version_order: :boolean, repo: [:keep, :string], no_compile: :boolean, no_deps_check: :boolean ] @doc """ Ensures the migrations path exists for the given `repo`. Returns the path for the `repo` tenant migrations folder if succeeds or `Mix.raise`'s if it fails. """ def ensure_tenant_migrations_path(repo) do path = Path.join(source_repo_priv(repo), Triplex.config().migrations_path) if not Project.umbrella?() and not File.dir?(path) do raise_missing_migrations(Path.relative_to_cwd(path), repo) end path end defp raise_missing_migrations(path, repo) do Mix.raise(""" Could not find migrations directory #{inspect(path)} for repo #{inspect(repo)}. This may be because you are in a new project and the migration directory has not been created yet. Creating an empty directory at the path above will fix this error. If you expected existing migrations to be found, please make sure your repository has been properly configured and the configured path exists. """) end @doc """ Runs the tenant migrations with the given `args` and using `migrator` function. """ def run_tenant_migrations(args, direction, migrator \\ &Migrator.run/4) do repos = Ecto.parse_repo(args) {opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases) opts = if opts[:to] || opts[:step] || opts[:all], do: opts, else: Keyword.put(opts, :step, 1) opts = if opts[:quiet], do: Keyword.merge(opts, log: false, log_sql: false), else: opts Enum.each(repos, &run_tenant_migrations(&1, args, opts, direction, migrator)) end defp run_tenant_migrations(repo, args, opts, direction, migrator) do Ecto.ensure_repo(repo, args) path = ensure_tenant_migrations_path(repo) {:ok, pid, apps} = ensure_started(repo, opts) pool = repo.config[:pool] Code.compiler_options(ignore_module_conflict: true) migrated = Enum.flat_map(Triplex.all(repo), fn tenant -> opts = Keyword.put(opts, :prefix, Triplex.to_prefix(tenant)) if function_exported?(pool, :unboxed_run, 2) do pool.unboxed_run(repo, fn -> migrator.(repo, path, direction, opts) end) else migrator.(repo, path, direction, opts) end end) Code.compiler_options(ignore_module_conflict: false) pid && repo.stop() restart_apps_if_migrated(apps, migrated) end @doc """ Returns the private repository path relative to the source. """ def source_repo_priv(repo) do config = repo.config() priv = config[:priv] || "priv/#{repo |> Module.split() |> List.last() |> Macro.underscore()}" app = Keyword.fetch!(config, :otp_app) Path.join(Project.deps_paths()[app] || File.cwd!(), priv) end @doc """ Ensures the given repository is started and running. """ @spec ensure_started(Ecto.Repo.t(), Keyword.t()) :: {:ok, pid | nil, [atom]} def ensure_started(repo, opts) do {:ok, started} = Application.ensure_all_started(:ecto_sql) # If we starting EctoSQL just now, assume # logger has not been properly booted yet. if :ecto_sql in started && Process.whereis(Logger) do backends = Application.get_env(:logger, :backends, []) try do App.stop() Application.put_env(:logger, :backends, [:console]) :ok = App.start() after Application.put_env(:logger, :backends, backends) end end {:ok, apps} = repo.__adapter__.ensure_all_started(repo.config(), :temporary) pool_size = Keyword.get(opts, :pool_size, 2) case repo.start_link(pool_size: pool_size) do {:ok, pid} -> {:ok, pid, apps} {:error, {:already_started, _pid}} -> {:ok, nil, apps} {:error, error} -> Mix.raise("Could not start repo #{inspect(repo)}, error: #{inspect(error)}") end end @doc """ Restarts the app if there was any migration command. """ @spec restart_apps_if_migrated([atom], list()) :: :ok def restart_apps_if_migrated(_apps, []), do: :ok def restart_apps_if_migrated(apps, [_ | _]) do # Silence the logger to avoid application down messages. Logger.remove_backend(:console) for app <- Enum.reverse(apps) do Application.stop(app) end for app <- apps do Application.ensure_all_started(app) end :ok after Logger.add_backend(:console, flush: true) end end
28.252632
97
0.657787
79d1786bebef5587b73248903c003fc958c086cd
1,838
ex
Elixir
elixirpay/lib/elixirpay_web.ex
fcsouza/elixir-project
e6212c4def050400eb4fcc50c6a8274409b1f0c7
[ "MIT" ]
null
null
null
elixirpay/lib/elixirpay_web.ex
fcsouza/elixir-project
e6212c4def050400eb4fcc50c6a8274409b1f0c7
[ "MIT" ]
null
null
null
elixirpay/lib/elixirpay_web.ex
fcsouza/elixir-project
e6212c4def050400eb4fcc50c6a8274409b1f0c7
[ "MIT" ]
null
null
null
defmodule ElixirpayWeb do @moduledoc """ The entrypoint for defining your web interface, such as controllers, views, channels and so on. This can be used in your application as: use ElixirpayWeb, :controller use ElixirpayWeb, :view The definitions below will be executed for every view, controller, etc, so keep them short and clean, focused on imports, uses and aliases. Do NOT define functions inside the quoted expressions below. Instead, define any helper function in modules and import those modules here. """ def controller do quote do use Phoenix.Controller, namespace: ElixirpayWeb import Plug.Conn import ElixirpayWeb.Gettext alias ElixirpayWeb.Router.Helpers, as: Routes end end def view do quote do use Phoenix.View, root: "lib/elixirpay_web/templates", namespace: ElixirpayWeb # Import convenience functions from controllers import Phoenix.Controller, only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1] # Include shared imports and aliases for views unquote(view_helpers()) end end def router do quote do use Phoenix.Router import Plug.Conn import Phoenix.Controller end end def channel do quote do use Phoenix.Channel import ElixirpayWeb.Gettext end end defp view_helpers do quote do # Import basic rendering functionality (render, render_layout, etc) import Phoenix.View import ElixirpayWeb.ErrorHelpers import ElixirpayWeb.Gettext alias ElixirpayWeb.Router.Helpers, as: Routes end end @doc """ When used, dispatch to the appropriate controller/view/etc. """ defmacro __using__(which) when is_atom(which) do apply(__MODULE__, which, []) end end
23.265823
76
0.692057
79d17977d4d0662f3e38d915408746593473c536
1,493
ex
Elixir
apps/ema/lib/ema/recipe.ex
hoyon/skye
50a25a55bb0c38460a0bd204c8d0ce716da9f017
[ "MIT" ]
null
null
null
apps/ema/lib/ema/recipe.ex
hoyon/skye
50a25a55bb0c38460a0bd204c8d0ce716da9f017
[ "MIT" ]
null
null
null
apps/ema/lib/ema/recipe.ex
hoyon/skye
50a25a55bb0c38460a0bd204c8d0ce716da9f017
[ "MIT" ]
null
null
null
defmodule Ema.Recipe do defstruct steps: [], state: %{} alias Ema.Template def run(%__MODULE__{} = recipe, inputs \\ %{}) when is_map(inputs) do recipe = Map.put(recipe, :state, inputs) case run_steps(recipe) do {:error, error} -> {:error, error} result -> {:ok, result} end end defp run_steps(recipe) do Enum.reduce_while(recipe.steps, recipe, fn step, recipe -> trans = elem(step, 2) state = run_transformation(trans, recipe.state) run_result = Ema.run_sync(elem(step, 0), elem(step, 1), state) case run_result do {:ok, result} -> recipe = Map.update!(recipe, :state, &Map.merge(&1, result)) {:cont, recipe} {:error, error} -> # TODO return result of previous successful steps {:halt, {:error, error}} end end) end defp run_transformation(transform, state) do transform |> Enum.map(fn {k, v} -> {k, eval_template(v, state)} end) |> Enum.into(%{}) end defp eval_template(template, state) do {:ok, ast} = Template.parse(template) Enum.reduce(ast, "", fn item, acc -> case item do {:str, string} -> acc <> string {:expr, expression} -> acc <> get_val!(state, expression) end end) end defp get_val!(state, expression) do if val = Map.get(state, expression) do val else raise """ Variable #{expression} not found """ end end end
23.328125
71
0.572003
79d18953adb01ea4bcbfea4b7ccf75eb90bed394
1,065
ex
Elixir
lib/reserva_web/channels/user_socket.ex
AminArria/reserva
13faef72927aeb84d456f080d65249b8ef50180e
[ "MIT" ]
null
null
null
lib/reserva_web/channels/user_socket.ex
AminArria/reserva
13faef72927aeb84d456f080d65249b8ef50180e
[ "MIT" ]
2
2021-03-09T00:49:12.000Z
2021-05-08T03:13:05.000Z
lib/reserva_web/channels/user_socket.ex
AminArria/reserva
13faef72927aeb84d456f080d65249b8ef50180e
[ "MIT" ]
null
null
null
defmodule ReservaWeb.UserSocket do use Phoenix.Socket ## Channels # channel "room:*", ReservaWeb.RoomChannel # Socket params are passed from the client and can # be used to verify and authenticate a user. After # verification, you can put default assigns into # the socket that will be set for all channels, ie # # {:ok, assign(socket, :user_id, verified_user_id)} # # To deny connection, return `:error`. # # See `Phoenix.Token` documentation for examples in # performing token verification on connect. def connect(_params, socket, _connect_info) do {:ok, socket} end # Socket id's are topics that allow you to identify all sockets for a given user: # # def id(socket), do: "user_socket:#{socket.assigns.user_id}" # # Would allow you to broadcast a "disconnect" event and terminate # all active sockets and channels for a given user: # # ReservaWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{}) # # Returning `nil` makes this socket anonymous. def id(_socket), do: nil end
31.323529
83
0.696714
79d1d94f29b00982186c0fd1ef0c7585cf685748
3,009
ex
Elixir
lib/event_store/storage.ex
MichalDolata/eventstore
2a6725fcb4c398d81a74455b6077901189b75386
[ "MIT" ]
null
null
null
lib/event_store/storage.ex
MichalDolata/eventstore
2a6725fcb4c398d81a74455b6077901189b75386
[ "MIT" ]
null
null
null
lib/event_store/storage.ex
MichalDolata/eventstore
2a6725fcb4c398d81a74455b6077901189b75386
[ "MIT" ]
null
null
null
defmodule EventStore.Storage do @moduledoc false alias EventStore.Snapshots.SnapshotData alias EventStore.Storage.{ Appender, CreateStream, QueryStreamInfo, Reader, Snapshot, Subscription } @doc """ Create a new event stream with the given unique identifier. """ def create_stream(conn, stream_uuid, opts \\ []) do CreateStream.execute(conn, stream_uuid, opts) end @doc """ Append the given list of recorded events to storage. """ def append_to_stream(conn, stream_id, events, opts \\ []) do Appender.append(conn, stream_id, events, opts) end @doc """ Link the existing event ids already present in a stream to the given stream. """ def link_to_stream(conn, stream_id, event_ids, opts \\ []) do Appender.link(conn, stream_id, event_ids, opts) end @doc """ Read events for the given stream forward from the starting version, use zero for all events for the stream. """ def read_stream_forward(conn, stream_id, start_version, count, opts \\ []) do Reader.read_forward(conn, stream_id, start_version, count, opts) end @doc """ Get the id and version of the stream with the given `stream_uuid`. """ def stream_info(conn, stream_uuid, opts \\ []) do QueryStreamInfo.execute(conn, stream_uuid, opts) end @doc """ Create, or locate an existing, persistent subscription to a stream using a unique name and starting position (event number or stream version). """ def subscribe_to_stream(conn, stream_uuid, subscription_name, start_from \\ nil, opts \\ []) def subscribe_to_stream(conn, stream_uuid, subscription_name, start_from, opts) do Subscription.subscribe_to_stream(conn, stream_uuid, subscription_name, start_from, opts) end @doc """ Acknowledge receipt of an event by its number, for a single subscription. """ def ack_last_seen_event(conn, stream_uuid, subscription_name, last_seen, opts \\ []) do Subscription.ack_last_seen_event(conn, stream_uuid, subscription_name, last_seen, opts) end @doc """ Delete an existing named subscription to a stream. """ def delete_subscription(conn, stream_uuid, subscription_name, opts \\ []) do Subscription.delete_subscription(conn, stream_uuid, subscription_name, opts) end @doc """ Get all known subscriptions, to any stream. """ def subscriptions(conn, opts \\ []) do Subscription.subscriptions(conn, opts) end @doc """ Read a snapshot, if available, for a given source. """ def read_snapshot(conn, source_uuid, opts \\ []) do Snapshot.read_snapshot(conn, source_uuid, opts) end @doc """ Record a snapshot of the data and metadata for a given source. """ def record_snapshot(conn, %SnapshotData{} = snapshot, opts \\ []) do Snapshot.record_snapshot(conn, snapshot, opts) end @doc """ Delete an existing snapshot for a given source. """ def delete_snapshot(conn, source_uuid, opts \\ []) do Snapshot.delete_snapshot(conn, source_uuid, opts) end end
29.213592
94
0.708209
79d1de26df244446d894af26c02bcbf23b36467f
117
ex
Elixir
apps/neoscan_web/lib/neoscan_web/views/asset_view.ex
vincentgeneste/neo-scan
4a654575331eeb3eb12d4fd61696a7bd6dbca3ce
[ "MIT" ]
75
2017-07-23T02:45:32.000Z
2021-12-13T11:04:17.000Z
apps/neoscan_web/lib/neoscan_web/views/asset_view.ex
vincentgeneste/neo-scan
4a654575331eeb3eb12d4fd61696a7bd6dbca3ce
[ "MIT" ]
252
2017-07-13T19:36:00.000Z
2021-07-28T18:40:00.000Z
apps/neoscan_web/lib/neoscan_web/views/asset_view.ex
vincentgeneste/neo-scan
4a654575331eeb3eb12d4fd61696a7bd6dbca3ce
[ "MIT" ]
87
2017-07-23T02:45:34.000Z
2022-03-02T14:54:27.000Z
defmodule NeoscanWeb.AssetView do use NeoscanWeb, :view import Number.Delimit import NeoscanWeb.CommonView end
19.5
33
0.811966
79d205f0e047d4142b0e4e7faf15b75eb57fce6d
3,256
ex
Elixir
clients/service_management/lib/google_api/service_management/v1/model/config_change.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/service_management/lib/google_api/service_management/v1/model/config_change.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/service_management/lib/google_api/service_management/v1/model/config_change.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
1
2020-11-10T16:58:27.000Z
2020-11-10T16:58:27.000Z
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.ServiceManagement.V1.Model.ConfigChange do @moduledoc """ Output generated from semantically comparing two versions of a service configuration. Includes detailed information about a field that have changed with applicable advice about potential consequences for the change, such as backwards-incompatibility. ## Attributes - advices ([Advice]): Collection of advice provided for this change, useful for determining the possible impact of this change. Defaults to: `null`. - changeType (String.t): The type for this change, either ADDED, REMOVED, or MODIFIED. Defaults to: `null`. - Enum - one of [CHANGE_TYPE_UNSPECIFIED, ADDED, REMOVED, MODIFIED] - element (String.t): Object hierarchy path to the change, with levels separated by a &#39;.&#39; character. For repeated fields, an applicable unique identifier field is used for the index (usually selector, name, or id). For maps, the term &#39;key&#39; is used. If the field has no unique identifier, the numeric index is used. Examples: - visibility.rules[selector&#x3D;&#x3D;\&quot;google.LibraryService.CreateBook\&quot;].restriction - quota.metric_rules[selector&#x3D;&#x3D;\&quot;google\&quot;].metric_costs[key&#x3D;&#x3D;\&quot;reads\&quot;].value - logging.producer_destinations[0] Defaults to: `null`. - newValue (String.t): Value of the changed object in the new Service configuration, in JSON format. This field will not be populated if ChangeType &#x3D;&#x3D; REMOVED. Defaults to: `null`. - oldValue (String.t): Value of the changed object in the old Service configuration, in JSON format. This field will not be populated if ChangeType &#x3D;&#x3D; ADDED. Defaults to: `null`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :advices => list(GoogleApi.ServiceManagement.V1.Model.Advice.t()), :changeType => any(), :element => any(), :newValue => any(), :oldValue => any() } field(:advices, as: GoogleApi.ServiceManagement.V1.Model.Advice, type: :list) field(:changeType) field(:element) field(:newValue) field(:oldValue) end defimpl Poison.Decoder, for: GoogleApi.ServiceManagement.V1.Model.ConfigChange do def decode(value, options) do GoogleApi.ServiceManagement.V1.Model.ConfigChange.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.ServiceManagement.V1.Model.ConfigChange do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
53.377049
615
0.741708
79d2867968b1fa91e654b12960bcab0e15466fa9
481
exs
Elixir
priv/repo/migrations/20211104204126_create_formulas.exs
patrotom/adaptable-costs-evaluator
c97e65af1e021d7c6acf6564f4671c60321346e3
[ "MIT" ]
null
null
null
priv/repo/migrations/20211104204126_create_formulas.exs
patrotom/adaptable-costs-evaluator
c97e65af1e021d7c6acf6564f4671c60321346e3
[ "MIT" ]
4
2021-12-07T12:26:50.000Z
2021-12-30T14:17:25.000Z
priv/repo/migrations/20211104204126_create_formulas.exs
patrotom/adaptable-costs-evaluator
c97e65af1e021d7c6acf6564f4671c60321346e3
[ "MIT" ]
null
null
null
defmodule AdaptableCostsEvaluator.Repo.Migrations.CreateFormulas do use Ecto.Migration def change do create table(:formulas) do add :name, :string, null: false add :label, :string, null: false add :definition, :text add :computation_id, references(:computations, on_delete: :delete_all), null: false timestamps() end create index(:formulas, [:computation_id]) create unique_index(:formulas, [:label, :computation_id]) end end
26.722222
89
0.698545
79d289d6e9483c43f38e43f9e4833b98dc603798
2,634
ex
Elixir
lib/cushion.ex
blandinw/homelander
05d7aff6c7b8f65a95dbc525a687e915bde7d7de
[ "Apache-2.0" ]
23
2020-10-24T16:02:37.000Z
2021-01-20T04:07:06.000Z
lib/cushion.ex
blandinw/homelander
05d7aff6c7b8f65a95dbc525a687e915bde7d7de
[ "Apache-2.0" ]
null
null
null
lib/cushion.ex
blandinw/homelander
05d7aff6c7b8f65a95dbc525a687e915bde7d7de
[ "Apache-2.0" ]
null
null
null
defmodule Homelander.Cushion do use GenServer @max_wait_ms 60_000 def start_link(m, a, counter_name, cooldown, options) do GenServer.start_link(__MODULE__, [m, a, counter_name, cooldown], options) end def compute_cooldown(:default, reason, count, started_at) do case reason do :normal -> if count < 5 do 1_000 else 60_000 end _ -> alive_for = (:erlang.monotonic_time() - started_at) |> :erlang.convert_time_unit(:native, :millisecond) (Bitwise.<<<(1, count) * 1000 - alive_for) |> min(@max_wait_ms) |> max(0) end end def compute_cooldown(n, _, _, _) when is_integer(n) do n end @impl true def init([mod, args, counter_name, cooldown]) do Process.flag(:trap_exit, true) {:ok, pid} = apply(mod, :start_link, args) {:ok, {pid, mod, args, counter_name, cooldown, :erlang.monotonic_time()}} end @impl true def handle_info({:EXIT, pid, reason}, state) do {^pid, mod, args, counter_name, cooldown, started_at} = state count = GenServer.call(counter_name, {:sadface, {mod, args}}) cooldown_ms = compute_cooldown(cooldown, reason, count, started_at) receive do after cooldown_ms -> :ok end {:stop, reason, state} end end defmodule Homelander.CushionCounter do use GenServer @two_minutes 120_000 @gc_threshold 10_000 def start_link(options) do GenServer.start_link(__MODULE__, :erlang, options) end def start_link(time_mod, options) do GenServer.start_link(__MODULE__, time_mod, options) end def sadface(pid, id) do GenServer.call(pid, {:sadface, id}) end @impl true def init(time_mod) do {:ok, {time_mod, %{}}} end @impl true def handle_call({:sadface, id}, _from, state) do {count, state} = pencil_in(state, id) {:reply, count, state} end def handle_call({:ledger}, _from, state = {_, ledger}) do {:reply, ledger, state} end def pencil_in({time_mod, ledger}, id) do now = apply(time_mod, :monotonic_time, [:millisecond]) cutoff = now - @two_minutes {past, ledger} = Map.get_and_update(ledger, id, fn past -> xs = Enum.take(past || [], 10) |> Enum.take_while(fn x -> x > cutoff end) |> List.insert_at(0, now) {xs, xs} end) ledger = if Enum.count(ledger) > @gc_threshold do Enum.filter(ledger, fn {_, [most_recent | _]} -> most_recent > cutoff end) |> Map.new() else ledger end {Enum.count(past), {time_mod, ledger}} end end
22.512821
81
0.612377
79d2a3506f032d490ad20a0593cacf15b28456f9
1,944
ex
Elixir
lib/booklist_web/controllers/loan_controller.ex
allen-garvey/booklist-phoenix
b3c87713d742b64684c222cd3e5869dc9fbd2bd2
[ "MIT" ]
4
2019-10-04T16:11:15.000Z
2021-08-18T21:00:13.000Z
apps/booklist/lib/booklist_web/controllers/loan_controller.ex
allen-garvey/phoenix-umbrella
1d444bbd62a5e7b5f51d317ce2be71ee994125d5
[ "MIT" ]
5
2020-03-16T23:52:25.000Z
2021-09-03T16:52:17.000Z
lib/booklist_web/controllers/loan_controller.ex
allen-garvey/booklist-phoenix
b3c87713d742b64684c222cd3e5869dc9fbd2bd2
[ "MIT" ]
null
null
null
defmodule BooklistWeb.LoanController do use BooklistWeb, :controller alias Booklist.Admin alias Booklist.Admin.Loan def related_fields() do [ libraries: Admin.list_libraries() |> BooklistWeb.LibraryView.map_for_form, ] end def index(conn, _params) do loans = Admin.list_loans() render(conn, "index.html", loans: loans) end def new(conn, _params) do changeset = Admin.change_loan(%Loan{}) render(conn, "new.html", [changeset: changeset] ++ related_fields()) end def create(conn, %{"loan" => loan_params}) do case Admin.create_loan(loan_params) do {:ok, loan} -> conn |> put_flash(:info, "Loan created successfully.") |> redirect(to: Routes.loan_path(conn, :show, loan)) {:error, %Ecto.Changeset{} = changeset} -> render(conn, "new.html", [changeset: changeset] ++ related_fields()) end end def show(conn, %{"id" => id}) do loan = Admin.get_loan!(id) render(conn, "show.html", loan: loan) end def edit(conn, %{"id" => id}) do loan = Admin.get_loan!(id) changeset = Admin.change_loan(loan) render(conn, "edit.html", [loan: loan, changeset: changeset] ++ related_fields()) end def update(conn, %{"id" => id, "loan" => loan_params}) do loan = Admin.get_loan!(id) case Admin.update_loan(loan, loan_params) do {:ok, loan} -> conn |> put_flash(:info, "Loan updated successfully.") |> redirect(to: Routes.loan_path(conn, :show, loan)) {:error, %Ecto.Changeset{} = changeset} -> render(conn, "edit.html", [loan: loan, changeset: changeset] ++ related_fields()) end end def delete(conn, %{"id" => id}) do loan = Admin.get_loan!(id) item_name = BooklistWeb.LoanView.to_s(loan) {:ok, _loan} = Admin.delete_loan(loan) conn |> put_flash(:info, item_name <> " deleted.") |> redirect(to: Routes.loan_path(conn, :index)) end end
27.771429
89
0.624486
79d2a6b391e3673f5a86825cf5aa3805c5773465
1,701
ex
Elixir
lib/desktop_url_file.ex
san650/desktop_url_file
733528833cd7691441f010eccef3c31494738cd9
[ "MIT" ]
4
2018-07-25T00:30:44.000Z
2018-07-25T13:12:35.000Z
lib/desktop_url_file.ex
san650/desktop_url_file
733528833cd7691441f010eccef3c31494738cd9
[ "MIT" ]
null
null
null
lib/desktop_url_file.ex
san650/desktop_url_file
733528833cd7691441f010eccef3c31494738cd9
[ "MIT" ]
null
null
null
defmodule DesktopUrlFile do @moduledoc """ Generate `.url` files for Windows and OSX desktops. These type of files are used to create hyperlinks in the desktop to open a web page. """ @doc """ Return the content of a valid `.url` file ## Examples iex> DesktopUrlFile.make("https://github.com/desktop_url_file#readme") \"\"\" [InternetShortcut] URL=https://github.com/desktop_url_file#readme \"\"\" """ def make(url, opts \\ [icon_file: nil, icon_index: 1]) do # Each line terminates with CR and LF characters, and uses ANSI as it’s character set. content = """ [InternetShortcut] URL=#{url} #{icon(opts)} """ {:ok, content} end @doc """ Generates new `.url` file. ## Examples iex> DesktopUrlFile.write("foo/bar.url", "https://github.com/desktop_url_file#readme") {:ok, "foo/bar.url"} """ def write(file_path, url, opts \\ [icon_file: nil, icon_index: 1]) do {:ok, content} = make(url, opts) url_file_path = case Path.extname(file_path) do ".url" -> file_path _ -> "#{file_path}.url" end case File.write(file_path, content, [:utf8]) do :ok -> {:ok, url_file_path} error -> error end end @doc """ Returns a valid mime type for a .url file """ def mime do # MIME: wwwserver/redirection, application/internet-shortcut, application/x-url, message/external-body, text/url, text/x-url "application/internet-shortcut" end defp icon(%{icon_file: nil}), do: "" defp icon(%{icon_file: icon_file, icon_index: icon_index}) do """ \nIconFile=#{icon_file} IconIndex=#{icon_index} """ end end
24.3
128
0.616696
79d2c6cf72a0e659bf7d7674fcb3a5d22ef5e25c
2,430
ex
Elixir
installer/templates/phx_single/lib/app_name_web.ex
GregMefford/phoenix
b48bd80918ebbffe3b33a4c57be49703a1f806ae
[ "MIT" ]
null
null
null
installer/templates/phx_single/lib/app_name_web.ex
GregMefford/phoenix
b48bd80918ebbffe3b33a4c57be49703a1f806ae
[ "MIT" ]
null
null
null
installer/templates/phx_single/lib/app_name_web.ex
GregMefford/phoenix
b48bd80918ebbffe3b33a4c57be49703a1f806ae
[ "MIT" ]
null
null
null
defmodule <%= web_namespace %> do @moduledoc """ The entrypoint for defining your web interface, such as controllers, views, channels and so on. This can be used in your application as: use <%= web_namespace %>, :controller use <%= web_namespace %>, :view The definitions below will be executed for every view, controller, etc, so keep them short and clean, focused on imports, uses and aliases. Do NOT define functions inside the quoted expressions below. Instead, define any helper function in modules and import those modules here. """ def controller do quote do use Phoenix.Controller, namespace: <%= web_namespace %> import Plug.Conn<%= if gettext do %> import <%= web_namespace %>.Gettext<% end %> alias <%= web_namespace %>.Router.Helpers, as: Routes end end def view do quote do use Phoenix.View, root: "lib/<%= lib_web_name %>/templates", namespace: <%= web_namespace %> # Import convenience functions from controllers import Phoenix.Controller, only: [get_flash: 1, get_flash: 2, view_module: 1] # Include shared imports and aliases for views unquote(view_helpers()) end end<%= if live do %> def live_view do quote do use Phoenix.LiveView unquote(view_helpers()) end end def live_component do quote do use Phoenix.LiveComponent unquote(view_helpers()) end end<% end %> def router do quote do use Phoenix.Router import Plug.Conn import Phoenix.Controller<%= if live do %> import Phoenix.LiveView.Router<% end %> end end def channel do quote do use Phoenix.Channel<%= if gettext do %> import <%= web_namespace %>.Gettext<% end %> end end<%= if html do %> defp view_helpers do quote do # Use all HTML functionality (forms, tags, etc) use Phoenix.HTML<%= if live do %> # Import convenience functions for LiveView rendering import Phoenix.LiveView.Helpers<% end %> import <%= web_namespace %>.ErrorHelpers<%= if gettext do %> import <%= web_namespace %>.Gettext<% end %> alias <%= web_namespace %>.Router.Helpers, as: Routes end end<% end %> @doc """ When used, dispatch to the appropriate controller/view/etc. """ defmacro __using__(which) when is_atom(which) do apply(__MODULE__, which, []) end end
24.795918
83
0.646091
79d3264b77c4b03e3f9ae33858cf888861eef7a6
874
ex
Elixir
clients/file/lib/google_api/file/v1/metadata.ex
myskoach/elixir-google-api
4f8cbc2fc38f70ffc120fd7ec48e27e46807b563
[ "Apache-2.0" ]
null
null
null
clients/file/lib/google_api/file/v1/metadata.ex
myskoach/elixir-google-api
4f8cbc2fc38f70ffc120fd7ec48e27e46807b563
[ "Apache-2.0" ]
1
2020-12-18T09:25:12.000Z
2020-12-18T09:25:12.000Z
clients/file/lib/google_api/file/v1/metadata.ex
myskoach/elixir-google-api
4f8cbc2fc38f70ffc120fd7ec48e27e46807b563
[ "Apache-2.0" ]
null
null
null
# Copyright 2020 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.File.V1 do @moduledoc """ API client metadata for GoogleApi.File.V1. """ @discovery_revision "20201208" def discovery_revision(), do: @discovery_revision end
32.37037
74
0.756293
79d3331d8794f846729718dc4381e4b28c8136f5
1,540
exs
Elixir
mix.exs
apodlaski/verk_web
91c544b1f792f929e06f18e26b964e23a5771a8a
[ "MIT" ]
null
null
null
mix.exs
apodlaski/verk_web
91c544b1f792f929e06f18e26b964e23a5771a8a
[ "MIT" ]
null
null
null
mix.exs
apodlaski/verk_web
91c544b1f792f929e06f18e26b964e23a5771a8a
[ "MIT" ]
null
null
null
defmodule VerkWeb.Mixfile do use Mix.Project @description """ A Verk dashboard """ def project do [ app: :verk_web, version: "1.6.0", elixir: "~> 1.11", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, test_coverage: [tool: Coverex.Task, coveralls: true], name: "Verk Web", description: @description, package: package(), deps: deps() ] end def application do [ mod: {VerkWeb, []}, extra_applications: [:logger] ] end defp elixirc_paths(:test), do: ["lib", "web", "test/support"] defp elixirc_paths(_), do: ["lib", "web"] defp deps do [ {:phoenix, "~> 1.5.0"}, {:phoenix_pubsub, "~> 2.0"}, {:phoenix_html, "~> 2.6"}, {:gettext, "~> 0.16"}, {:verk, "~> 1.7.1"}, {:plug_cowboy, "~> 2.0"}, {:plug, "~> 1.10"}, {:phoenix_live_reload, "~> 1.0", only: :dev}, {:earmark, "~> 1.0", only: :dev}, {:ex_doc, "~> 0.13", only: :dev}, {:coverex, "~> 1.4", only: :test}, {:meck, "~> 0.8", only: :test}, {:timex, "~> 3.3.0"}, {:jason, "~> 1.1"} ] end defp package do [ maintainers: ["Eduardo Gurgel Pinho", "Alisson Sales"], licenses: ["MIT"], links: %{"Github" => "https://github.com/edgurgel/verk_web"}, files: ["lib", "web", "priv", "mix.exs", "README*", "LICENSE*"] ] end end
24.444444
69
0.507143
79d3a17b22ccb36d597bd4e880605ebcaf609f04
239
ex
Elixir
lib/phone/es/lo.ex
ajmath/phone
0c7c7033ea93d028d3bd2a9e445d3aa93a6bc2fa
[ "Apache-2.0" ]
null
null
null
lib/phone/es/lo.ex
ajmath/phone
0c7c7033ea93d028d3bd2a9e445d3aa93a6bc2fa
[ "Apache-2.0" ]
null
null
null
lib/phone/es/lo.ex
ajmath/phone
0c7c7033ea93d028d3bd2a9e445d3aa93a6bc2fa
[ "Apache-2.0" ]
null
null
null
defmodule Phone.ES.LO do @moduledoc false use Helper.Area def regex, do: ~r/^(34)(941|841)(.{6})/ def area_name, do: "La Rioja" def area_type, do: "province" def area_abbreviation, do: "LO" matcher(["34941", "34841"]) end
18.384615
41
0.644351
79d3b26148e760590a19a7f2890a1ee5356712f4
553
ex
Elixir
template/$PROJECT_NAME$/lib/$PROJECT_NAME$_web/controllers/admin/pages_controller.ex
luke-hawk/degree
9274fc979ea0715d3bdf65a0adb14fdd2419db9a
[ "MIT" ]
3
2019-08-01T08:28:24.000Z
2019-08-18T14:50:32.000Z
template/$PROJECT_NAME$/lib/$PROJECT_NAME$_web/controllers/admin/pages_controller.ex
luke-hawk/degree
9274fc979ea0715d3bdf65a0adb14fdd2419db9a
[ "MIT" ]
3
2021-03-09T12:14:26.000Z
2022-02-10T18:46:15.000Z
template/$PROJECT_NAME$/lib/$PROJECT_NAME$_web/controllers/admin/pages_controller.ex
luke-hawk/degree
9274fc979ea0715d3bdf65a0adb14fdd2419db9a
[ "MIT" ]
null
null
null
defmodule <%= @project_name_camel_case %>Web.Admin.PagesController do use <%= @project_name_camel_case %>Web, :controller alias <%= @project_name_camel_case %>.Repo def index(conn, _params) do render(conn, "index.html", routes: Thesis.Page |> Repo.all) end def delete_page(conn, %{"route_id" => route_id}) do page = Repo.get(Thesis.Page, route_id) Thesis.EctoStore.delete(%{"slug" => page.slug}) conn |> put_flash(:info, "Page deleted successfully.") |> redirect(to: Routes.pages_path(conn, :index)) end end
27.65
69
0.674503
79d3d6bec013028d287864a71516e216fba32ada
197
ex
Elixir
lib/cleanex.ex
data-maestro/cleanex
0db74ec267b15992130a5132f9dc34e4182638ea
[ "Apache-2.0" ]
null
null
null
lib/cleanex.ex
data-maestro/cleanex
0db74ec267b15992130a5132f9dc34e4182638ea
[ "Apache-2.0" ]
1
2018-01-11T11:34:38.000Z
2018-01-11T11:34:38.000Z
lib/cleanex.ex
data-craftsman/cleanex
0db74ec267b15992130a5132f9dc34e4182638ea
[ "Apache-2.0" ]
1
2018-01-11T11:30:05.000Z
2018-01-11T11:30:05.000Z
defmodule Cleanex do @moduledoc """ Documentation for Cleanex. """ @doc """ Hello world. ## Examples iex> Cleanex.hello :world """ def hello do :world end end
10.368421
28
0.568528
79d3e4f4713bab00f362114e2054c9bed4841280
1,125
exs
Elixir
src/config/config.exs
ArguShards/Helldev
f61d95f32c1336e8ac7e6f766eb7326411b0040a
[ "MIT" ]
null
null
null
src/config/config.exs
ArguShards/Helldev
f61d95f32c1336e8ac7e6f766eb7326411b0040a
[ "MIT" ]
null
null
null
src/config/config.exs
ArguShards/Helldev
f61d95f32c1336e8ac7e6f766eb7326411b0040a
[ "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 :hellbot, key: :value # # and access this configuration in your application as: # # Application.get_env(:hellbot, :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.290323
73
0.750222
79d3e9eb06a27a9e26d7082139229d54a05acbc4
1,117
exs
Elixir
elixir/config/config.exs
vlamy/lcd
fdcd38709e7d2837e186a9e618e69da84f3128b1
[ "MIT" ]
null
null
null
elixir/config/config.exs
vlamy/lcd
fdcd38709e7d2837e186a9e618e69da84f3128b1
[ "MIT" ]
null
null
null
elixir/config/config.exs
vlamy/lcd
fdcd38709e7d2837e186a9e618e69da84f3128b1
[ "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 :lcd, key: :value # # and access this configuration in your application as: # # Application.get_env(:lcd, :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.032258
73
0.748433
79d45c953f9df82058f1a94983c99178440ad6b6
1,288
ex
Elixir
lib/pdf_maker_web/endpoint.ex
avvo/pdf_maker
e5e074274a2b398d51c063a5acd800ef6356502f
[ "MIT" ]
2
2019-01-31T12:42:23.000Z
2019-10-09T19:34:44.000Z
lib/pdf_maker_web/endpoint.ex
avvo/pdf_maker
e5e074274a2b398d51c063a5acd800ef6356502f
[ "MIT" ]
1
2020-05-20T09:36:32.000Z
2020-05-20T09:36:32.000Z
lib/pdf_maker_web/endpoint.ex
avvo/pdf_maker
e5e074274a2b398d51c063a5acd800ef6356502f
[ "MIT" ]
1
2019-01-30T19:40:02.000Z
2019-01-30T19:40:02.000Z
defmodule PdfMakerWeb.Endpoint do use Phoenix.Endpoint, otp_app: :pdf_maker socket "/socket", PdfMakerWeb.UserSocket, websocket: true, longpoll: false plug CORSPlug # Serve at "/" the static files from "priv/static" directory. # # You should set gzip to true if you are running phx.digest # when deploying your static files in production. plug Plug.Static, at: "/", from: :pdf_maker, gzip: false, only: ~w(css fonts images js favicon.ico robots.txt) # Code reloading can be explicitly enabled under the # :code_reloader configuration of your endpoint. if code_reloading? do socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket plug Phoenix.LiveReloader plug Phoenix.CodeReloader end plug Plug.RequestId plug Plug.Logger plug Plug.Parsers, parsers: [:urlencoded, :multipart, :json], pass: ["*/*"], json_decoder: Phoenix.json_library() plug Plug.MethodOverride plug Plug.Head # The session will be stored in the cookie and signed, # this means its contents can be read but not tampered with. # Set :encryption_salt if you would also like to encrypt it. plug Plug.Session, store: :cookie, key: "_pdf_maker_key", signing_salt: "gEdKYQwm" plug PdfMakerWeb.Router end
26.285714
69
0.71118
79d46aa6e821fb4021a7e5874c6432c32120ec4d
3,208
ex
Elixir
lib/aws/generated/amp.ex
salemove/aws-elixir
debdf6482158a71a57636ac664c911e682093395
[ "Apache-2.0" ]
null
null
null
lib/aws/generated/amp.ex
salemove/aws-elixir
debdf6482158a71a57636ac664c911e682093395
[ "Apache-2.0" ]
null
null
null
lib/aws/generated/amp.ex
salemove/aws-elixir
debdf6482158a71a57636ac664c911e682093395
[ "Apache-2.0" ]
null
null
null
# WARNING: DO NOT EDIT, AUTO-GENERATED CODE! # See https://github.com/aws-beam/aws-codegen for more details. defmodule AWS.Amp do @moduledoc """ Amazon Managed Service for Prometheus """ alias AWS.Client alias AWS.Request def metadata do %AWS.ServiceMetadata{ abbreviation: nil, api_version: "2020-08-01", content_type: "application/x-amz-json-1.1", credential_scope: nil, endpoint_prefix: "aps", global?: false, protocol: "rest-json", service_id: "amp", signature_version: "v4", signing_name: "aps", target_prefix: nil } end @doc """ Creates a new AMP workspace. """ def create_workspace(%Client{} = client, input, options \\ []) do url_path = "/workspaces" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, 202 ) end @doc """ Deletes an AMP workspace. """ def delete_workspace(%Client{} = client, workspace_id, input, options \\ []) do url_path = "/workspaces/#{URI.encode(workspace_id)}" headers = [] {query_params, input} = [ {"clientToken", "clientToken"} ] |> Request.build_params(input) Request.request_rest( client, metadata(), :delete, url_path, query_params, headers, input, options, 202 ) end @doc """ Describes an existing AMP workspace. """ def describe_workspace(%Client{} = client, workspace_id, options \\ []) do url_path = "/workspaces/#{URI.encode(workspace_id)}" headers = [] query_params = [] Request.request_rest( client, metadata(), :get, url_path, query_params, headers, nil, options, 200 ) end @doc """ Lists all AMP workspaces, including workspaces being created or deleted. """ def list_workspaces( %Client{} = client, alias \\ nil, max_results \\ nil, next_token \\ nil, options \\ [] ) do url_path = "/workspaces" headers = [] query_params = [] query_params = if !is_nil(next_token) do [{"nextToken", next_token} | query_params] else query_params end query_params = if !is_nil(max_results) do [{"maxResults", max_results} | query_params] else query_params end query_params = if !is_nil(alias) do [{"alias", alias} | query_params] else query_params end Request.request_rest( client, metadata(), :get, url_path, query_params, headers, nil, options, 200 ) end @doc """ Updates an AMP workspace alias. """ def update_workspace_alias(%Client{} = client, workspace_id, input, options \\ []) do url_path = "/workspaces/#{URI.encode(workspace_id)}/alias" headers = [] query_params = [] Request.request_rest( client, metadata(), :post, url_path, query_params, headers, input, options, 204 ) end end
19.442424
87
0.565773
79d47523f1cd0e5ca3bfb09f61b835634584ae6b
47,123
ex
Elixir
clients/compute/lib/google_api/compute/v1/api/subnetworks.ex
jamesvl/elixir-google-api
6c87fb31d996f08fb42ce6066317e9d652a87acc
[ "Apache-2.0" ]
null
null
null
clients/compute/lib/google_api/compute/v1/api/subnetworks.ex
jamesvl/elixir-google-api
6c87fb31d996f08fb42ce6066317e9d652a87acc
[ "Apache-2.0" ]
1
2020-12-18T09:25:12.000Z
2020-12-18T09:25:12.000Z
clients/compute/lib/google_api/compute/v1/api/subnetworks.ex
myskoach/elixir-google-api
4f8cbc2fc38f70ffc120fd7ec48e27e46807b563
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.Compute.V1.Api.Subnetworks do @moduledoc """ API calls for all endpoints tagged `Subnetworks`. """ alias GoogleApi.Compute.V1.Connection alias GoogleApi.Gax.{Request, Response} @library_version Mix.Project.config() |> Keyword.get(:version, "") @doc """ Retrieves an aggregated list of subnetworks. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:filter` (*type:* `String.t`) - A filter expression that filters resources listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be either `=`, `!=`, `>`, or `<`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` * `:includeAllScopes` (*type:* `boolean()`) - Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. * `:maxResults` (*type:* `integer()`) - The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) * `:orderBy` (*type:* `String.t`) - Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. * `:pageToken` (*type:* `String.t`) - Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. * `:returnPartialSuccess` (*type:* `boolean()`) - Opt-in for partial success behavior which provides partial results in case of failure. The default value is false and the logic is the same as today. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.SubnetworkAggregatedList{}}` on success * `{:error, info}` on failure """ @spec compute_subnetworks_aggregated_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.Compute.V1.Model.SubnetworkAggregatedList.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_subnetworks_aggregated_list(connection, project, optional_params \\ [], opts \\ []) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :filter => :query, :includeAllScopes => :query, :maxResults => :query, :orderBy => :query, :pageToken => :query, :returnPartialSuccess => :query } request = Request.new() |> Request.method(:get) |> Request.url("/projects/{project}/aggregated/subnetworks", %{ "project" => URI.encode(project, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Compute.V1.Model.SubnetworkAggregatedList{}]) end @doc """ Deletes the specified subnetwork. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - Name of the region scoping this request. * `subnetwork` (*type:* `String.t`) - Name of the Subnetwork resource to delete. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:requestId` (*type:* `String.t`) - An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec compute_subnetworks_delete( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Compute.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_subnetworks_delete( connection, project, region, subnetwork, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :requestId => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/projects/{project}/regions/{region}/subnetworks/{subnetwork}", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &URI.char_unreserved?/1), "subnetwork" => URI.encode(subnetwork, &(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.Compute.V1.Model.Operation{}]) end @doc """ Expands the IP CIDR range of the subnetwork to a specified value. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - Name of the region scoping this request. * `subnetwork` (*type:* `String.t`) - Name of the Subnetwork resource to update. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:requestId` (*type:* `String.t`) - An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). * `:body` (*type:* `GoogleApi.Compute.V1.Model.SubnetworksExpandIpCidrRangeRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec compute_subnetworks_expand_ip_cidr_range( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Compute.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_subnetworks_expand_ip_cidr_range( connection, project, region, subnetwork, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :requestId => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/projects/{project}/regions/{region}/subnetworks/{subnetwork}/expandIpCidrRange", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &URI.char_unreserved?/1), "subnetwork" => URI.encode(subnetwork, &URI.char_unreserved?/1) } ) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Compute.V1.Model.Operation{}]) end @doc """ Returns the specified subnetwork. Gets a list of available subnetworks list() request. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - Name of the region scoping this request. * `subnetwork` (*type:* `String.t`) - Name of the Subnetwork resource to return. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.Subnetwork{}}` on success * `{:error, info}` on failure """ @spec compute_subnetworks_get( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Compute.V1.Model.Subnetwork.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_subnetworks_get( connection, project, region, subnetwork, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query } request = Request.new() |> Request.method(:get) |> Request.url("/projects/{project}/regions/{region}/subnetworks/{subnetwork}", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &URI.char_unreserved?/1), "subnetwork" => URI.encode(subnetwork, &(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.Compute.V1.Model.Subnetwork{}]) end @doc """ Gets the access control policy for a resource. May be empty if no such policy or resource exists. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - The name of the region for this request. * `resource` (*type:* `String.t`) - Name or id of the resource for this request. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:optionsRequestedPolicyVersion` (*type:* `integer()`) - Requested IAM Policy version. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec compute_subnetworks_get_iam_policy( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Compute.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_subnetworks_get_iam_policy( connection, project, region, resource, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :optionsRequestedPolicyVersion => :query } request = Request.new() |> Request.method(:get) |> Request.url( "/projects/{project}/regions/{region}/subnetworks/{resource}/getIamPolicy", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &URI.char_unreserved?/1), "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.Compute.V1.Model.Policy{}]) end @doc """ Creates a subnetwork in the specified project using the data included in the request. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - Name of the region scoping this request. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:requestId` (*type:* `String.t`) - An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). * `:body` (*type:* `GoogleApi.Compute.V1.Model.Subnetwork.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec compute_subnetworks_insert( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Compute.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_subnetworks_insert(connection, project, region, optional_params \\ [], opts \\ []) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :requestId => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/projects/{project}/regions/{region}/subnetworks", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Compute.V1.Model.Operation{}]) end @doc """ Retrieves a list of subnetworks available to the specified project. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - Name of the region scoping this request. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:filter` (*type:* `String.t`) - A filter expression that filters resources listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be either `=`, `!=`, `>`, or `<`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` * `:maxResults` (*type:* `integer()`) - The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) * `:orderBy` (*type:* `String.t`) - Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. * `:pageToken` (*type:* `String.t`) - Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. * `:returnPartialSuccess` (*type:* `boolean()`) - Opt-in for partial success behavior which provides partial results in case of failure. The default value is false and the logic is the same as today. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.SubnetworkList{}}` on success * `{:error, info}` on failure """ @spec compute_subnetworks_list(Tesla.Env.client(), String.t(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.Compute.V1.Model.SubnetworkList.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_subnetworks_list(connection, project, region, optional_params \\ [], opts \\ []) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :filter => :query, :maxResults => :query, :orderBy => :query, :pageToken => :query, :returnPartialSuccess => :query } request = Request.new() |> Request.method(:get) |> Request.url("/projects/{project}/regions/{region}/subnetworks", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Compute.V1.Model.SubnetworkList{}]) end @doc """ Retrieves an aggregated list of all usable subnetworks in the project. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:filter` (*type:* `String.t`) - A filter expression that filters resources listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be either `=`, `!=`, `>`, or `<`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` * `:maxResults` (*type:* `integer()`) - The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) * `:orderBy` (*type:* `String.t`) - Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. * `:pageToken` (*type:* `String.t`) - Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. * `:returnPartialSuccess` (*type:* `boolean()`) - Opt-in for partial success behavior which provides partial results in case of failure. The default value is false and the logic is the same as today. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.UsableSubnetworksAggregatedList{}}` on success * `{:error, info}` on failure """ @spec compute_subnetworks_list_usable(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.Compute.V1.Model.UsableSubnetworksAggregatedList.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_subnetworks_list_usable(connection, project, optional_params \\ [], opts \\ []) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :filter => :query, :maxResults => :query, :orderBy => :query, :pageToken => :query, :returnPartialSuccess => :query } request = Request.new() |> Request.method(:get) |> Request.url("/projects/{project}/aggregated/subnetworks/listUsable", %{ "project" => URI.encode(project, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode( opts ++ [struct: %GoogleApi.Compute.V1.Model.UsableSubnetworksAggregatedList{}] ) end @doc """ Patches the specified subnetwork with the data included in the request. Only certain fields can be updated with a patch request as indicated in the field descriptions. You must specify the current fingerprint of the subnetwork resource being patched. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - Name of the region scoping this request. * `subnetwork` (*type:* `String.t`) - Name of the Subnetwork resource to patch. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:drainTimeoutSeconds` (*type:* `integer()`) - The drain timeout specifies the upper bound in seconds on the amount of time allowed to drain connections from the current ACTIVE subnetwork to the current BACKUP subnetwork. The drain timeout is only applicable when the following conditions are true: - the subnetwork being patched has purpose = INTERNAL_HTTPS_LOAD_BALANCER - the subnetwork being patched has role = BACKUP - the patch request is setting the role to ACTIVE. Note that after this patch operation the roles of the ACTIVE and BACKUP subnetworks will be swapped. * `:requestId` (*type:* `String.t`) - An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). * `:body` (*type:* `GoogleApi.Compute.V1.Model.Subnetwork.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec compute_subnetworks_patch( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Compute.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_subnetworks_patch( connection, project, region, subnetwork, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :drainTimeoutSeconds => :query, :requestId => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/projects/{project}/regions/{region}/subnetworks/{subnetwork}", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &URI.char_unreserved?/1), "subnetwork" => URI.encode(subnetwork, &(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.Compute.V1.Model.Operation{}]) end @doc """ Sets the access control policy on the specified resource. Replaces any existing policy. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - The name of the region for this request. * `resource` (*type:* `String.t`) - Name or id of the resource for this request. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:body` (*type:* `GoogleApi.Compute.V1.Model.RegionSetPolicyRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.Policy{}}` on success * `{:error, info}` on failure """ @spec compute_subnetworks_set_iam_policy( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Compute.V1.Model.Policy.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_subnetworks_set_iam_policy( connection, project, region, resource, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/projects/{project}/regions/{region}/subnetworks/{resource}/setIamPolicy", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &URI.char_unreserved?/1), "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.Compute.V1.Model.Policy{}]) end @doc """ Set whether VMs in this subnet can access Google services without assigning external IP addresses through Private Google Access. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - Name of the region scoping this request. * `subnetwork` (*type:* `String.t`) - Name of the Subnetwork resource. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:requestId` (*type:* `String.t`) - An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). * `:body` (*type:* `GoogleApi.Compute.V1.Model.SubnetworksSetPrivateIpGoogleAccessRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec compute_subnetworks_set_private_ip_google_access( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Compute.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_subnetworks_set_private_ip_google_access( connection, project, region, subnetwork, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :requestId => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/projects/{project}/regions/{region}/subnetworks/{subnetwork}/setPrivateIpGoogleAccess", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &URI.char_unreserved?/1), "subnetwork" => URI.encode(subnetwork, &URI.char_unreserved?/1) } ) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Compute.V1.Model.Operation{}]) end @doc """ Returns permissions that a caller has on the specified resource. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - The name of the region for this request. * `resource` (*type:* `String.t`) - Name or id of the resource for this request. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:body` (*type:* `GoogleApi.Compute.V1.Model.TestPermissionsRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.TestPermissionsResponse{}}` on success * `{:error, info}` on failure """ @spec compute_subnetworks_test_iam_permissions( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Compute.V1.Model.TestPermissionsResponse.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_subnetworks_test_iam_permissions( connection, project, region, resource, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url( "/projects/{project}/regions/{region}/subnetworks/{resource}/testIamPermissions", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &URI.char_unreserved?/1), "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.Compute.V1.Model.TestPermissionsResponse{}]) end end
52.184939
583
0.64911
79d497eb1b58c90530798f8ac9d7278662f7b738
3,376
exs
Elixir
priv/repo/migrations/20190215192101_database.exs
HoffsMH/slax
b91ee30b9fd71a4cb7826f50b605ce580b7c1651
[ "MIT" ]
null
null
null
priv/repo/migrations/20190215192101_database.exs
HoffsMH/slax
b91ee30b9fd71a4cb7826f50b605ce580b7c1651
[ "MIT" ]
null
null
null
priv/repo/migrations/20190215192101_database.exs
HoffsMH/slax
b91ee30b9fd71a4cb7826f50b605ce580b7c1651
[ "MIT" ]
null
null
null
defmodule Slax.Repo.Migrations.Database do use Ecto.Migration def change do create_if_not_exists table(:estimates) do add(:user, :string) add(:value, :integer) add(:round_id, :integer) add(:created_at, :utc_datetime, null: false) add(:updated_at, :utc_datetime, null: false) add(:reason, :string) end create_if_not_exists table(:events) do add(:repo, :string) add(:org, :string) add(:number, :integer) add(:payload, :json) add(:github_id, :integer) add(:created_at, :utc_datetime, null: false) add(:updated_at, :utc_datetime, null: false) end create_if_not_exists(index(:events, ["number"], name: "index_events_on_number")) create_if_not_exists(index(:events, ["org"], name: "index_events_on_org")) create_if_not_exists(index(:events, ["repo"], name: "index_events_on_repo")) create_if_not_exists table(:health_calculations) do add(:org, :string) add(:repo, :string) add(:start_dt, :utc_datetime) add(:end_dt, :utc_datetime) add(:bugs_count, :integer) add(:bugs_closed_fast_count, :integer) add(:features_count, :integer) add(:features_closed_fast_count, :integer) add(:created_at, :utc_datetime) add(:updated_at, :utc_datetime) end create_if_not_exists table(:people) do add(:github_username, :string) add(:slack_username, :string) add(:created_at, :utc_datetime, null: false) add(:updated_at, :utc_datetime, null: false) end create_if_not_exists table(:project_channels) do add(:project_id, :integer) add(:channel_name, :string) add(:created_at, :utc_datetime, null: false) add(:updated_at, :utc_datetime, null: false) add(:webhook_token, :string) end create_if_not_exists( index(:project_channels, ["channel_name"], name: "index_project_channels_on_channel_name") ) create_if_not_exists table(:project_repos) do add(:project_id, :integer, null: false) add(:org_name, :string, null: false) add(:repo_name, :string, null: false) add(:created_at, :utc_datetime, null: false) add(:updated_at, :utc_datetime, null: false) end create_if_not_exists table(:projects) do add(:name, :string) add(:created_at, :utc_datetime, null: false) add(:updated_at, :utc_datetime, null: false) end create_if_not_exists table(:rounds) do add(:revealed, :boolean) add(:value, :integer) add(:issue, :string) add(:channel, :string) add(:created_at, :utc_datetime, null: false) add(:updated_at, :utc_datetime, null: false) add(:closed, :boolean) add(:response_url, :string) end create_if_not_exists table(:sprints) do add(:project_repo_id, references(:project_repos, on_delete: :nothing)) add(:milestone_id, :integer, null: false) add(:issues, {:array, :integer}, default: [], null: false) end create_if_not_exists(index(:sprints, ["milestone_id"], name: "index_sprints_on_milestone_id")) create_if_not_exists( index(:sprints, ["project_repo_id"], name: "index_sprints_on_project_repo_id") ) create_if_not_exists table(:users) do add(:slack_id, :string) add(:github_username, :string) add(:github_access_token, :string) end end end
32.461538
98
0.663507
79d4cb0370b947bed90d0ed43dbe8e15debb1da2
173
ex
Elixir
lib/searchex/archive/async_app.ex
andyl/searchex
aae186cddd14f0415b116fca198b8cc95eb2c379
[ "MIT" ]
91
2016-11-22T23:52:01.000Z
2022-02-12T13:06:24.000Z
lib/searchex/archive/async_app.ex
andyl/searchex
aae186cddd14f0415b116fca198b8cc95eb2c379
[ "MIT" ]
11
2016-11-23T17:37:57.000Z
2018-03-07T13:40:48.000Z
lib/searchex/archive/async_app.ex
andyl/searchex
aae186cddd14f0415b116fca198b8cc95eb2c379
[ "MIT" ]
9
2016-11-24T01:44:40.000Z
2020-05-15T04:16:19.000Z
# defmodule Searchex.AsyncApp do # use Application # # def start(_type, _args) do # AsyncSup.start_link() # end # # def stop(_state) do # :ok # end # end
14.416667
32
0.606936
79d4ec28f601f293fd2e81f7a5556bd10a4fd8c3
802
exs
Elixir
machine_translation/MorpHIN/Learned/Resources/Set2/TrainingInstances/40.exs
AdityaPrasadMishra/NLP--Project-Group-16
fb62cc6a1db4a494058171f11c14a2be3933a9a1
[ "MIT" ]
null
null
null
machine_translation/MorpHIN/Learned/Resources/Set2/TrainingInstances/40.exs
AdityaPrasadMishra/NLP--Project-Group-16
fb62cc6a1db4a494058171f11c14a2be3933a9a1
[ "MIT" ]
null
null
null
machine_translation/MorpHIN/Learned/Resources/Set2/TrainingInstances/40.exs
AdityaPrasadMishra/NLP--Project-Group-16
fb62cc6a1db4a494058171f11c14a2be3933a9a1
[ "MIT" ]
null
null
null
**EXAMPLE FILE** noun cm adjective noun cm; noun cm noun verb cm; noun cm noun verb cm; noun cm cardinal noun cm; noun cm noun verb cm; noun cm noun verb cm; noun cm adjective noun cm; pn pn verb conj cm; pnoun cm adjective noun cm; pnoun cm verb cm cm; noun cm verb verb_aux adjective; pnoun cm verb cm adjective; pnoun cm adjective noun cm; pnoun cm noun cm cm; cm pn quantifier adjective cm; SYM pn quantifier particle cm; noun cm noun verb cm; pnoun cm noun adjective cm; pnoun cm adjective cardinal cm; conj pn noun verb cm; conj pn noun verb cm; pnoun cm adjective noun cm; SYM pn noun noun cm; pnoun cm demonstrative noun cm; pnoun cm ordinal adjective cm; SYM pn demonstrative noun cm; pnoun cm noun noun cm; noun cm noun adjective cm; noun cm verb SYM adjective;
25.0625
33
0.738155
79d4eeb7f321da86fb8f0c06f4777c9bcdb61d10
3,889
ex
Elixir
lib/telegraph/behaviour.ex
etroynov/telegraph
e355362d2edbb1aa47669de6525c621be6d03e58
[ "MIT" ]
1
2022-03-14T18:00:31.000Z
2022-03-14T18:00:31.000Z
lib/telegraph/behaviour.ex
etroynov/telegraph
e355362d2edbb1aa47669de6525c621be6d03e58
[ "MIT" ]
2
2022-03-16T20:49:13.000Z
2022-03-23T22:08:48.000Z
lib/telegraph/behaviour.ex
etroynov/telegraph
e355362d2edbb1aa47669de6525c621be6d03e58
[ "MIT" ]
null
null
null
defmodule Telegraph.Behaviour do alias Telegraph.Model.{User, Message, Update, UserProfilePhotos, File, Error} @callback get_me :: {:ok, User.t()} | {:error, Error.t()} @callback send_message(integer, binary, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback forward_message(integer, integer, integer) :: {:ok, Message.t()} | {:error, Error.t()} @callback send_photo(integer, binary, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback send_audio(integer, binary, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback send_document(integer, binary, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback send_sticker(integer, binary, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback send_video(integer, binary, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback send_voice(integer, binary, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback send_animation(integer, binary, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback send_location(integer, float, float, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback send_venue(integer, float, float, binary, binary, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback send_contact(integer, binary, binary, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback send_chat_action(integer, binary) :: :ok | {:error, Error.t()} @callback get_user_profile_photos(integer, [{atom, any}]) :: {:ok, UserProfilePhotos.t()} | {:error, Error.t()} @callback get_updates([{atom, any}]) :: {:ok, [Update.t()]} | {:error, Error.t()} @callback set_webhook([{atom, any}]) :: :ok | {:error, Error.t()} @callback get_file(binary) :: {:ok, File.t()} | {:error, Error.t()} @callback get_file_link(File.t()) :: {:ok, binary} | {:error, Error.t()} @callback kick_chat_member(integer | binary, integer) :: :ok | {:error, Error.t()} @callback leave_chat(integer | binary) :: :ok | {:error, Error.t()} @callback unban_chat_member(integer | binary, integer) :: :ok | {:error, Error.t()} @callback get_chat(integer | binary) :: {:ok, Chat.t()} | {:error, Error.t()} @callback get_chat_administrators(integer | binary) :: {:ok, [ChatMember.t()]} | {:error, Error.t()} @callback get_chat_members_count(integer | binary) :: {:ok, integer} | {:error, Error.t()} @callback get_chat_member(integer | binary, integer) :: {:ok, ChatMember.t()} | {:error, Error.t()} @callback answer_callback_query(binary, [{atom, any}]) :: :ok | {:error, Error.t()} @callback edit_message_text(integer | binary, integer, binary, binary, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback edit_message_caption(integer | binary, integer, binary, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback edit_message_reply_markup(integer | binary, integer, binary, [{atom, any}]) :: {:ok, Message.t()} | {:error, Error.t()} @callback answer_inline_query(binary, [Telegraph.Model.InlineQueryResult.t()], [{atom, any}]) :: :ok | {:error, Error.t()} @callback send_invoice( integer | binary, binary, binary, binary, binary, binary, binary, [Telegraph.Model.LabeledPrice.t()], [{atom, any}] ) :: {:ok, Message.t()} | {:error, Error.t()} @callback answer_shipping_query(integer | binary, boolean, [{atom, any}]) :: :ok | {:error, Error.t()} @callback answer_pre_checkout_query(integer | binary, boolean, [{atom, any}]) :: :ok | {:error, Error.t()} end
59.830769
98
0.576498
79d521eca3d5239b541b33107261a767fdb0ee68
2,491
exs
Elixir
test/update_and_describe_table_test.exs
kianmeng/ex_aliyun_ots
554da4a80b7d59640f1b8aed75c2ff81678f0c4d
[ "MIT" ]
null
null
null
test/update_and_describe_table_test.exs
kianmeng/ex_aliyun_ots
554da4a80b7d59640f1b8aed75c2ff81678f0c4d
[ "MIT" ]
null
null
null
test/update_and_describe_table_test.exs
kianmeng/ex_aliyun_ots
554da4a80b7d59640f1b8aed75c2ff81678f0c4d
[ "MIT" ]
null
null
null
defmodule ExAliyunOtsTest.UpdateAndDescribeTable do use ExUnit.Case require Logger alias ExAliyunOts.Var alias ExAliyunOts.Const.{PKType, OperationType, ReturnType, RowExistence} require PKType require OperationType require ReturnType require RowExistence @instance_key EDCEXTestInstance test "create table and then update it, meanwhile describe this table" do cur_timestamp = Timex.to_unix(Timex.now()) table_name = "test_update_table_#{cur_timestamp}" var_create_table = %Var.CreateTable{ table_name: table_name, primary_keys: [{"partition_key", PKType.string()}, {"order_id", PKType.string()}] } result = ExAliyunOts.Client.create_table(@instance_key, var_create_table) assert result == :ok stream = %Var.StreamSpec{ is_enabled: true, expiration_time: 1 } var_update_table = %Var.UpdateTable{ table_name: table_name, reserved_throughput_write: 10, time_to_live: 86_500, stream_spec: stream } update_table_result = ExAliyunOts.Client.update_table(@instance_key, var_update_table) Logger.info("#{inspect(update_table_result)}") # if the error message is `Your instance is forbidden to update capacity unit`, please ensure your server instance is a high-performance instance describe_table_result = ExAliyunOts.Client.describe_table(@instance_key, table_name) Logger.info("describe_table_result: #{inspect(describe_table_result)}") {:ok, table_info} = describe_table_result assert table_info.table_meta.table_name == table_name assert table_info.table_options.deviation_cell_version_in_sec == 86_400 assert table_info.table_options.max_versions == 1 case update_table_result do # May cause "*OTSTooFrequentReservedThroughputAdjustment/Reserved throughput adjustment is too frequent" error after create table and then update table not remain interval. {:ok, _} -> assert table_info.table_options.time_to_live == 86_500 {:error, _error} -> assert table_info.table_options.time_to_live == -1 end primary_key_list = table_info.table_meta.primary_key pk1 = Enum.at(primary_key_list, 0) assert "partition_key" == pk1.name assert :STRING == pk1.type pk2 = Enum.at(primary_key_list, 1) assert "order_id" == pk2.name assert :STRING == pk2.type del_table_result = ExAliyunOts.Client.delete_table(@instance_key, table_name) assert del_table_result == :ok end end
34.597222
178
0.737455
79d52e064da7d01ec07fee98638104c3499e2338
1,494
ex
Elixir
lib/api/graphql/ecto.ex
nunopolonia/psc-api
2e358503851cc04cdaa89201a3f56586f8746736
[ "MIT" ]
1
2017-09-10T23:51:40.000Z
2017-09-10T23:51:40.000Z
lib/api/graphql/ecto.ex
nunopolonia/psc-api
2e358503851cc04cdaa89201a3f56586f8746736
[ "MIT" ]
24
2018-03-14T18:17:00.000Z
2021-03-01T07:47:53.000Z
lib/api/graphql/ecto.ex
portosummerofcode/psc-api
2e358503851cc04cdaa89201a3f56586f8746736
[ "MIT" ]
null
null
null
defmodule Api.GraphQL.EctoExtensions do import Ecto.Query alias Ecto.Queryable defp string_in_atoms(source, target, _ex_args) do if target not in Enum.map(source, &to_string/1) do # raise Exception, ex_args raise "Graphql.EctoExtensions computer says no" end String.to_existing_atom(target) end @spec orderable(Queryable.t, %{order_by: String.t}) :: Ecto.Query.t def orderable(queryable, %{order_by: order_arg}) do {field_key, assocs} = order_arg |> String.split(".") |> List.pop_at(-1) {query, last_target} = assocs |> Enum.reduce( { queryable, Queryable.to_query(queryable).from |> elem(1) }, fn assoc_key, {query, last_target} -> assoc_atom = :associations |> last_target.__schema__ |> string_in_atoms( assoc_key, detail: "invalid assoc `#{assoc_key}`" ) { from( [..., l] in query, left_join: a in assoc(l, ^assoc_atom) ), last_target.__schema__(:association, assoc_atom).related, } end ) field_atom = :fields |> last_target.__schema__ |> string_in_atoms( field_key, detail: "invalid field `#{field_key}`" ) order_by( query, [..., l], asc: field(l, ^field_atom) ) end def orderable(query, _), do: query end
23.34375
69
0.546854
79d55cdf5d68aef4c270b6b7c9b03509326ad5b3
2,584
ex
Elixir
lib/new_relic/harvest/collector/transaction_error_event/harvester.ex
tpitale/elixir_agent
f356b588fe9d7cc3b9db00d9a251e009a20b3e0e
[ "Apache-2.0" ]
227
2018-09-05T15:33:23.000Z
2022-02-25T18:12:06.000Z
lib/new_relic/harvest/collector/transaction_error_event/harvester.ex
tpitale/elixir_agent
f356b588fe9d7cc3b9db00d9a251e009a20b3e0e
[ "Apache-2.0" ]
211
2018-09-05T21:42:41.000Z
2022-03-25T17:51:56.000Z
lib/new_relic/harvest/collector/transaction_error_event/harvester.ex
tpitale/elixir_agent
f356b588fe9d7cc3b9db00d9a251e009a20b3e0e
[ "Apache-2.0" ]
84
2018-09-05T04:26:26.000Z
2022-03-09T14:28:14.000Z
defmodule NewRelic.Harvest.Collector.TransactionErrorEvent.Harvester do use GenServer @moduledoc false alias NewRelic.Harvest alias NewRelic.Harvest.Collector alias NewRelic.Error.Event def start_link(_) do GenServer.start_link(__MODULE__, []) end def init(_) do {:ok, %{ start_time: System.system_time(), start_time_mono: System.monotonic_time(), end_time_mono: nil, sampling: %{ reservoir_size: Collector.AgentRun.lookup(:error_event_reservoir_size, 10), events_seen: 0 }, error_events: [] }} end # API def report_error(%Event{} = event), do: Collector.TransactionErrorEvent.HarvestCycle |> Harvest.HarvestCycle.current_harvester() |> GenServer.cast({:report, event}) def gather_harvest, do: Collector.TransactionErrorEvent.HarvestCycle |> Harvest.HarvestCycle.current_harvester() |> GenServer.call(:gather_harvest) # Server def handle_cast(_late_msg, :completed), do: {:noreply, :completed} def handle_cast({:report, event}, state) do state = state |> store_event(event) |> store_sampling {:noreply, state} end def handle_call(_late_msg, _from, :completed), do: {:reply, :completed, :completed} def handle_call(:send_harvest, _from, state) do send_harvest(%{state | end_time_mono: System.monotonic_time()}) {:reply, :ok, :completed} end def handle_call(:gather_harvest, _from, state) do {:reply, build_payload(state), state} end # Helpers def store_event(%{sampling: %{events_seen: seen, reservoir_size: size}} = state, event) when seen < size, do: %{state | error_events: [event | state.error_events]} def store_event(state, _event), do: state def store_sampling(%{sampling: sampling} = state), do: %{state | sampling: Map.update!(sampling, :events_seen, &(&1 + 1))} def send_harvest(state) do events = build_payload(state) Collector.Protocol.error_event([Collector.AgentRun.agent_run_id(), state.sampling, events]) log_harvest(length(events), state.sampling.events_seen, state.sampling.reservoir_size) end def log_harvest(harvest_size, events_seen, reservoir_size) do NewRelic.report_metric({:supportability, "ErrorEventData"}, harvest_size: harvest_size) NewRelic.log( :debug, "Completed TransactionError Event harvest - " <> "size: #{harvest_size}, seen: #{events_seen}, max: #{reservoir_size}" ) end def build_payload(state), do: Event.format_events(state.error_events) end
27.2
95
0.684985
79d577d418a70a0ec0701d3370a85dfda93bfe70
56
ex
Elixir
testData/org/elixir_lang/parser_definition/no_parentheses_many_arguments_call_parsing_test_case/PositionalAtom.ex
keyno63/intellij-elixir
4033e319992c53ddd42a683ee7123a97b5e34f02
[ "Apache-2.0" ]
1,668
2015-01-03T05:54:27.000Z
2022-03-25T08:01:20.000Z
testData/org/elixir_lang/parser_definition/no_parentheses_many_arguments_call_parsing_test_case/PositionalAtom.ex
keyno63/intellij-elixir
4033e319992c53ddd42a683ee7123a97b5e34f02
[ "Apache-2.0" ]
2,018
2015-01-01T22:43:39.000Z
2022-03-31T20:13:08.000Z
testData/org/elixir_lang/parser_definition/no_parentheses_many_arguments_call_parsing_test_case/PositionalAtom.ex
keyno63/intellij-elixir
4033e319992c53ddd42a683ee7123a97b5e34f02
[ "Apache-2.0" ]
145
2015-01-15T11:37:16.000Z
2021-12-22T05:51:02.000Z
identifier :atom, first_keyword_key: first_keyword_value
56
56
0.892857
79d58527aab315c343c75799ba91216141856cbc
17,846
exs
Elixir
test/meeseeks/selector/xpath/parser_test.exs
mischov/meeseeks
74f84010252da3298f8c74e90fdee1ab9ad6d700
[ "Apache-2.0", "MIT" ]
291
2017-03-27T15:53:36.000Z
2022-03-14T23:01:42.000Z
test/meeseeks/selector/xpath/parser_test.exs
mischov/meeseeks
74f84010252da3298f8c74e90fdee1ab9ad6d700
[ "Apache-2.0", "MIT" ]
70
2017-03-30T23:32:34.000Z
2021-06-27T06:26:28.000Z
test/meeseeks/selector/xpath/parser_test.exs
mischov/meeseeks
74f84010252da3298f8c74e90fdee1ab9ad6d700
[ "Apache-2.0", "MIT" ]
23
2017-06-18T10:29:04.000Z
2021-11-04T13:08:12.000Z
defmodule Meeseeks.Selector.XPath.ParserTest do use ExUnit.Case alias Meeseeks.Selector.{Combinator, XPath} alias Meeseeks.Selector.XPath.{Expr, Parser, Tokenizer} # abs test "root only" do tokens = Tokenizer.tokenize("/") assert_raise ErlangError, fn -> Parser.parse_expression(tokens) end end test "abs wildcard" do tokens = Tokenizer.tokenize("/*") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Self{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "*"}] } ], type: :abs } assert Parser.parse_expression(tokens) == expression end test "abs only" do tokens = Tokenizer.tokenize("/root") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Self{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "root"}] } ], type: :abs } assert Parser.parse_expression(tokens) == expression end test "abs abbreviated step" do tokens = Tokenizer.tokenize("/root/child") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Self{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "root"}] }, %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "child"}] } ], type: :abs } assert Parser.parse_expression(tokens) == expression end test "abs explicit step" do tokens = Tokenizer.tokenize("/root/descendant::descendant") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Self{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "root"}] }, %Expr.Step{ combinator: %Combinator.Descendants{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "descendant"}] } ], type: :abs } assert Parser.parse_expression(tokens) == expression end test "abbreviated abs" do tokens = Tokenizer.tokenize("//*") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.DescendantsOrSelf{selector: nil}, predicates: [%Expr.NodeType{type: :node}] }, %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "*"}] } ], type: :abs } assert Parser.parse_expression(tokens) == expression end # rel test "rel wildcard only" do tokens = Tokenizer.tokenize("*") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "*"}] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end test "rel only" do tokens = Tokenizer.tokenize("node") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "node"}] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end test "rel appreviated step" do tokens = Tokenizer.tokenize("node/child") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "node"}] }, %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "child"}] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end test "rel explicit step" do tokens = Tokenizer.tokenize("node/ancestor::ancestor") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "node"}] }, %Expr.Step{ combinator: %Combinator.Ancestors{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "ancestor"}] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end # abbreviated step test "self node" do tokens = Tokenizer.tokenize("/./child") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Self{selector: nil}, predicates: [%Expr.NodeType{type: :node}] }, %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "child"}] } ], type: :abs } assert Parser.parse_expression(tokens) == expression end test "parent node" do tokens = Tokenizer.tokenize("../self::parent") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Parent{selector: nil}, predicates: [%Expr.NodeType{type: :node}] }, %Expr.Step{ combinator: %Combinator.Self{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "parent"}] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end test "child" do tokens = Tokenizer.tokenize("./child") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Self{selector: nil}, predicates: [%Expr.NodeType{type: :node}] }, %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "child"}] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end test "descendant or self" do tokens = Tokenizer.tokenize(".//descendant") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Self{selector: nil}, predicates: [%Expr.NodeType{type: :node}] }, %Expr.Step{ combinator: %Combinator.DescendantsOrSelf{selector: nil}, predicates: [%Expr.NodeType{type: :node}] }, %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "descendant"}] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end # abbreviated axis test "attribute axis" do tokens = Tokenizer.tokenize("@*") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %XPath.Combinator.Attributes{selector: nil}, predicates: [%XPath.Expr.AttributeNameTest{name: "*", namespace: nil}] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end # node type test "node type" do tokens = Tokenizer.tokenize("/comment()") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Self{selector: nil}, predicates: [%Expr.NodeType{type: :comment}] } ], type: :abs } assert Parser.parse_expression(tokens) == expression end # processing instruction test "processing instruction" do tokens = Tokenizer.tokenize("/processing-instruction('xml-spreadsheet')") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Self{selector: nil}, predicates: [%Expr.ProcessingInstruction{target: 'xml-spreadsheet'}] } ], type: :abs } assert Parser.parse_expression(tokens) == expression end # union test "union" do tokens = Tokenizer.tokenize("this|that") expression = %Expr.Union{ e1: %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "this"}] } ], type: :rel }, e2: %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "that"}] } ], type: :rel } } assert Parser.parse_expression(tokens) == expression end # filter test "filter" do tokens = Tokenizer.tokenize("(this|that)[@type != 'the-other']") expression = %Expr.Filter{ e: %Expr.Union{ e1: %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "this"}] } ], type: :rel }, e2: %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "that"}] } ], type: :rel } }, predicate: %Expr.Predicate{ e: %Expr.Comparative{ e1: %Expr.Path{ steps: [ %Expr.Step{ combinator: %XPath.Combinator.Attributes{selector: nil}, predicates: [%Expr.AttributeNameTest{name: "type", namespace: nil}] } ], type: :rel }, e2: %Expr.Literal{value: "the-other"}, op: :!= } } } assert Parser.parse_expression(tokens) == expression end # predicate test "predicate number" do tokens = Tokenizer.tokenize("*[2]") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [ %Expr.NameTest{namespace: nil, tag: "*"}, %Expr.Predicate{e: %Meeseeks.Selector.XPath.Expr.Number{value: 2}} ] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end test "predicate expr" do tokens = Tokenizer.tokenize("*[@id = 'good']") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [ %Expr.NameTest{namespace: nil, tag: "*"}, %Expr.Predicate{ e: %Expr.Comparative{ e1: %Expr.Path{ steps: [ %Expr.Step{ combinator: %XPath.Combinator.Attributes{selector: nil}, predicates: [%Expr.AttributeNameTest{name: "id", namespace: nil}] } ], type: :rel }, e2: %Expr.Literal{value: "good"}, op: := } } ] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end # literal test "literal" do tokens = Tokenizer.tokenize("*[@id = 'good']") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [ %Expr.NameTest{namespace: nil, tag: "*"}, %Expr.Predicate{ e: %Expr.Comparative{ e1: %Expr.Path{ steps: [ %Expr.Step{ combinator: %XPath.Combinator.Attributes{selector: nil}, predicates: [%Expr.AttributeNameTest{name: "id", namespace: nil}] } ], type: :rel }, e2: %Expr.Literal{value: "good"}, op: := } } ] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end # number test "number" do tokens = Tokenizer.tokenize("*[position() = 2]") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [ %Expr.NameTest{namespace: nil, tag: "*"}, %Expr.Predicate{ e: %Expr.Comparative{ e1: %Expr.Function{args: [], f: :position}, e2: %Expr.Number{value: 2}, op: := } } ] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end # function test "function no args" do tokens = Tokenizer.tokenize("*[last()]") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [ %Expr.NameTest{namespace: nil, tag: "*"}, %Expr.Predicate{e: %Expr.Function{args: [], f: :last}} ] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end test "function with args" do tokens = Tokenizer.tokenize("*[string(./*) = '123']") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [ %Expr.NameTest{namespace: nil, tag: "*"}, %Expr.Predicate{ e: %Expr.Comparative{ e1: %Expr.Function{ args: [ %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Self{selector: nil}, predicates: [%Expr.NodeType{type: :node}] }, %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [%Expr.NameTest{namespace: nil, tag: "*"}] } ], type: :rel } ], f: :string }, e2: %Expr.Literal{value: "123"}, op: := } } ] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end # boolean test "boolean" do tokens = Tokenizer.tokenize("*[position() = last() and @class = 'odd']") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [ %Expr.NameTest{namespace: nil, tag: "*"}, %Expr.Predicate{ e: %Expr.Boolean{ e1: %Expr.Comparative{ e1: %Expr.Function{args: [], f: :position}, e2: %Expr.Function{args: [], f: :last}, op: := }, e2: %Expr.Comparative{ e1: %Expr.Path{ steps: [ %Expr.Step{ combinator: %XPath.Combinator.Attributes{selector: nil}, predicates: [%Expr.AttributeNameTest{name: "class", namespace: nil}] } ], type: :rel }, e2: %Expr.Literal{value: "odd"}, op: := }, op: :and } } ] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end # comparative test "comparative" do tokens = Tokenizer.tokenize("*[position() <= 3]") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [ %Expr.NameTest{namespace: nil, tag: "*"}, %Expr.Predicate{ e: %Expr.Comparative{ e1: %Expr.Function{args: [], f: :position}, e2: %Expr.Number{value: 3}, op: :<= } } ] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end # arithmetic test "arithmetic" do tokens = Tokenizer.tokenize("*[last() - 1]") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [ %Expr.NameTest{namespace: nil, tag: "*"}, %Expr.Predicate{ e: %Expr.Arithmetic{ e1: %Expr.Function{args: [], f: :last}, e2: %Expr.Number{value: 1}, op: :- } } ] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end # negative test "negative" do tokens = Tokenizer.tokenize("*[-(1 - last())]") expression = %Expr.Path{ steps: [ %Expr.Step{ combinator: %Combinator.Children{selector: nil}, predicates: [ %Expr.NameTest{namespace: nil, tag: "*"}, %Expr.Predicate{ e: %Expr.Negative{ e: %Expr.Arithmetic{ e1: %Expr.Number{value: 1}, e2: %Expr.Function{args: [], f: :last}, op: :- } } } ] } ], type: :rel } assert Parser.parse_expression(tokens) == expression end # no var_refs test "no var-refs" do tokens = Tokenizer.tokenize("*[string(.) = $val]") assert_raise ErlangError, fn -> Parser.parse_expression(tokens) end end end
25.029453
92
0.504035
79d58d4239a89a32a127c7afeffbea3673d260b9
4,384
ex
Elixir
lib/bypass.ex
getong/bypass
c4d18ab4a1ccd8a0b46828913f55ae3f147100c2
[ "MIT" ]
null
null
null
lib/bypass.ex
getong/bypass
c4d18ab4a1ccd8a0b46828913f55ae3f147100c2
[ "MIT" ]
null
null
null
lib/bypass.ex
getong/bypass
c4d18ab4a1ccd8a0b46828913f55ae3f147100c2
[ "MIT" ]
null
null
null
defmodule Bypass do @moduledoc """ Bypass provides a quick way to create a custom Plug that can be put in place instead of an actual HTTP server to return prebaked responses to client requests. This module is the main interface to the library. """ defstruct pid: nil, port: nil @typedoc """ Represents a Bypass server process """ @type t :: %__MODULE__{pid: pid, port: non_neg_integer} import Bypass.Utils require Logger @doc """ Starts an Elixir process running a minimal Plug app. The process is a HTTP handler and listens to requests on a TCP port on localhost. Use the other functions in this module to declare which requests are handled and set expectations on the calls. """ def open(opts \\ []) do case DynamicSupervisor.start_child(Bypass.Supervisor, Bypass.Instance.child_spec(opts)) do {:ok, pid} -> port = Bypass.Instance.call(pid, :port) debug_log("Did open connection #{inspect(pid)} on port #{inspect(port)}") bypass = %Bypass{pid: pid, port: port} setup_framework_integration(test_framework(), bypass) bypass other -> other end end # Raise an error if called with an unknown framework # defp setup_framework_integration(:ex_unit, bypass = %{pid: pid}) do ExUnit.Callbacks.on_exit({Bypass, pid}, fn -> do_verify_expectations(bypass.pid, ExUnit.AssertionError) end) end defp setup_framework_integration(:espec, _bypass) do # Entry point for more advanced ESpec configurations end @doc """ Can be called to immediately verify if the declared request expectations have been met. Returns `:ok` on success and raises an error on failure. """ def verify_expectations!(bypass) do verify_expectations!(test_framework(), bypass) end defp verify_expectations!(:ex_unit, _bypass) do raise "Not available in ExUnit, as it's configured automatically." end if Code.ensure_loaded?(ESpec) do defp verify_expectations!(:espec, bypass) do do_verify_expectations(bypass.pid, ESpec.AssertionError) end end defp do_verify_expectations(bypass_pid, error_module) do case Bypass.Instance.call(bypass_pid, :on_exit) do :ok -> :ok :ok_call -> :ok {:error, :too_many_requests, {:any, :any}} -> raise error_module, "Expected only one HTTP request for Bypass" {:error, :too_many_requests, {method, path}} -> raise error_module, "Expected only one HTTP request for Bypass at #{method} #{path}" {:error, :unexpected_request, {:any, :any}} -> raise error_module, "Bypass got an HTTP request but wasn't expecting one" {:error, :unexpected_request, {method, path}} -> raise error_module, "Bypass got an HTTP request but wasn't expecting one at #{method} #{path}" {:error, :not_called, {:any, :any}} -> raise error_module, "No HTTP request arrived at Bypass" {:error, :not_called, {method, path}} -> raise error_module, "No HTTP request arrived at Bypass at #{method} #{path}" {:exit, {class, reason, stacktrace}} -> :erlang.raise(class, reason, stacktrace) end end @doc """ Re-opens the TCP socket on the same port. Blocks until the operation is complete. """ @spec up(Bypass.t()) :: :ok | {:error, :already_up} def up(%Bypass{pid: pid}), do: Bypass.Instance.call(pid, :up) @doc """ Closes the TCP socket. Blocks until the operation is complete. """ @spec down(Bypass.t()) :: :ok | {:error, :already_down} def down(%Bypass{pid: pid}), do: Bypass.Instance.call(pid, :down) def expect(%Bypass{pid: pid}, fun), do: Bypass.Instance.call(pid, {:expect, fun}) def expect(%Bypass{pid: pid}, methods, paths, fun), do: Bypass.Instance.call(pid, {:expect, methods, paths, fun}) def expect_once(%Bypass{pid: pid}, fun), do: Bypass.Instance.call(pid, {:expect_once, fun}) def expect_once(%Bypass{pid: pid}, methods, paths, fun), do: Bypass.Instance.call(pid, {:expect_once, methods, paths, fun}) def stub(%Bypass{pid: pid}, methods, paths, fun), do: Bypass.Instance.call(pid, {:stub, methods, paths, fun}) def pass(%Bypass{pid: pid}), do: Bypass.Instance.call(pid, :pass) defp test_framework do Application.get_env(:bypass, :test_framework, :ex_unit) end end
30.444444
94
0.666515
79d595a0849d060278c9563dbecc683a022961cb
1,593
ex
Elixir
lib/jit_jerky_web/live/shipping/address_live/form_component.ex
Wobblesday/JIT-Jerky
b60c52ee76cf9ae4836ee99f3deccda72fccc656
[ "Apache-2.0" ]
null
null
null
lib/jit_jerky_web/live/shipping/address_live/form_component.ex
Wobblesday/JIT-Jerky
b60c52ee76cf9ae4836ee99f3deccda72fccc656
[ "Apache-2.0" ]
null
null
null
lib/jit_jerky_web/live/shipping/address_live/form_component.ex
Wobblesday/JIT-Jerky
b60c52ee76cf9ae4836ee99f3deccda72fccc656
[ "Apache-2.0" ]
null
null
null
defmodule JITJerkyWeb.Shipping.AddressLive.FormComponent do use JITJerkyWeb, :live_component alias JITJerky.Shipping @impl true def update(%{address: address} = assigns, socket) do changeset = Shipping.change_address(address) {:ok, socket |> assign(assigns) |> assign(:changeset, changeset)} end @impl true def handle_event("validate", %{"address" => address_params}, socket) do changeset = socket.assigns.address |> Shipping.change_address(address_params) |> Map.put(:action, :validate) {:noreply, assign(socket, :changeset, changeset)} end def handle_event("save", %{"address" => address_params}, socket) do save_address(socket, socket.assigns.action, address_params) end defp save_address(socket, :edit, address_params) do case Shipping.update_address(socket.assigns.address, address_params) do {:ok, _address} -> {:noreply, socket |> put_flash(:info, "Address updated successfully") |> push_redirect(to: socket.assigns.return_to)} {:error, %Ecto.Changeset{} = changeset} -> {:noreply, assign(socket, :changeset, changeset)} end end defp save_address(socket, :new, address_params) do case Shipping.create_address(address_params) do {:ok, _address} -> {:noreply, socket |> put_flash(:info, "Address created successfully") |> push_redirect(to: socket.assigns.return_to)} {:error, %Ecto.Changeset{} = changeset} -> {:noreply, assign(socket, changeset: changeset)} end end end
28.446429
75
0.659134
79d5a8c975742b31bf916124d67ce5aaaf96015a
1,495
ex
Elixir
test/support/layout_view.ex
vfsoraki/phoenix_live_view
1bb2b1b7ef9a90747d5dc1dc6d11c083a9369b38
[ "MIT" ]
null
null
null
test/support/layout_view.ex
vfsoraki/phoenix_live_view
1bb2b1b7ef9a90747d5dc1dc6d11c083a9369b38
[ "MIT" ]
null
null
null
test/support/layout_view.ex
vfsoraki/phoenix_live_view
1bb2b1b7ef9a90747d5dc1dc6d11c083a9369b38
[ "MIT" ]
null
null
null
defmodule Phoenix.LiveViewTest.LayoutView do use Phoenix.View, root: "" alias Phoenix.LiveViewTest.Router.Helpers, as: Routes import Phoenix.LiveView.Helpers def render("app.html", assigns) do # Assert those assigns are always available _ = assigns.live_module _ = assigns.live_action ["LAYOUT", assigns.inner_content] end def render("live.html", assigns) do ~L""" LIVELAYOUTSTART-<%= @val %>-<%= @inner_content %>-LIVELAYOUTEND """ end def render("live-override.html", assigns) do ~L""" LIVEOVERRIDESTART-<%= @val %>-<%= @inner_content %>-LIVEOVERRIDEEND """ end def render("widget.html", assigns) do ~L""" WIDGET:<%= live_render(@conn, Phoenix.LiveViewTest.ClockLive) %> """ end def render("styled.html", assigns) do ~L""" <html> <head> <link rel="stylesheet" href="/css/custom.css"/> <link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/> <link rel="stylesheet" href="//example.com/a.css"/> <link rel="stylesheet" href="https://example.com/b.css"/> <style>body { background-color: #eee; }</style> <script>console.log("script")</script> </head> <body> <%= @inner_content %> </body> </html> """ end end defmodule Phoenix.LiveViewTest.AssignsLayoutView do use Phoenix.View, root: "" def render("app.html", assigns) do ["title: #{assigns.title}", assigns.inner_content] end end
25.775862
88
0.61806
79d5bcdb4a142b5be145ba0d8655b9f14c9d8f14
561
ex
Elixir
web/router.ex
praveenperera/phoenix-dokku-example
fc4bfe98e016dfe6eb1f74449b3a8d292dbce137
[ "MIT" ]
1
2015-10-05T20:58:46.000Z
2015-10-05T20:58:46.000Z
web/router.ex
praveenperera/phoenix-dokku-example
fc4bfe98e016dfe6eb1f74449b3a8d292dbce137
[ "MIT" ]
null
null
null
web/router.ex
praveenperera/phoenix-dokku-example
fc4bfe98e016dfe6eb1f74449b3a8d292dbce137
[ "MIT" ]
null
null
null
defmodule PhoenixDokkuExample.Router do use PhoenixDokkuExample.Web, :router pipeline :browser do plug :accepts, ["html"] plug :fetch_session plug :fetch_flash plug :protect_from_forgery plug :put_secure_browser_headers end pipeline :api do plug :accepts, ["json"] end scope "/", PhoenixDokkuExample do pipe_through :browser # Use the default browser stack get "/", PageController, :index end # Other scopes may use custom stacks. # scope "/api", PhoenixDokkuExample do # pipe_through :api # end end
20.777778
57
0.700535
79d5db1b828c3e8252d44d21b36a7a9664a5daad
2,768
ex
Elixir
priv/perf/apps/load_test/lib/scenario/spend_eth_utxo.ex
boolafish/elixir-omg
46b568404972f6e4b4da3195d42d4fb622edb934
[ "Apache-2.0" ]
null
null
null
priv/perf/apps/load_test/lib/scenario/spend_eth_utxo.ex
boolafish/elixir-omg
46b568404972f6e4b4da3195d42d4fb622edb934
[ "Apache-2.0" ]
null
null
null
priv/perf/apps/load_test/lib/scenario/spend_eth_utxo.ex
boolafish/elixir-omg
46b568404972f6e4b4da3195d42d4fb622edb934
[ "Apache-2.0" ]
null
null
null
# Copyright 2019-2020 OmiseGO Pte Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. defmodule LoadTest.Scenario.SpendEthUtxo do @moduledoc """ Spends a utxo in a transaction. Can be done repeatedly by setting `transactions_per_session` Returns the first output of the spent transaction in the session. Normally this will be the change output. ## configuration values - `sender` the owner of the utxo - `receiver` the receiver's account - `amount` the amount to spend. If amount + fee is less than the value of the utxo then the change will be sent back to the sender - `transactions_per_session` the number of transactions to send. Each transaction after the first will spend the change output of the previous transaction - `transaction_delay` delay in milliseconds before sending the transaction. Used to control the tx rate. """ use Chaperon.Scenario alias Chaperon.Session alias Chaperon.Timing def run(session) do fee_amount = Application.fetch_env!(:load_test, :fee_amount) sender = config(session, [:sender]) receiver = config(session, [:receiver]) amount = config(session, [:amount], nil) test_currency = config(session, [:test_currency], nil) delay = config(session, [:transaction_delay], 0) transactions_per_session = config(session, [:transactions_per_session]) repeat( session, :submit_transaction, [amount, fee_amount, sender, receiver, test_currency, delay], transactions_per_session ) end def submit_transaction(session, nil, fee_amount, sender, receiver, currency, delay) do utxo = session.assigned.utxo amount = utxo.amount - fee_amount submit_transaction(session, amount, fee_amount, sender, receiver, currency, delay) end def submit_transaction(session, amount, fee_amount, sender, receiver, currency, delay) do Process.sleep(delay) utxo = session.assigned.utxo start = Timing.timestamp() [next_utxo | _] = LoadTest.ChildChain.Transaction.spend_utxo(utxo, amount, fee_amount, sender, receiver, currency) session |> Session.assign(utxo: next_utxo) |> Session.add_metric( {:call, {LoadTest.Scenario.SpendEthUtxo, "submit_transaction"}}, Timing.timestamp() - start ) end end
36.421053
118
0.732659
79d5e4323e665e9a6e710172d4ea1664d49982ae
3,774
ex
Elixir
lib/llp/characters/characters.ex
Danwhy/llp
63d4efa78b56351c9d96c46024291c828722c3fe
[ "MIT" ]
2
2019-01-02T11:02:59.000Z
2019-04-15T10:07:40.000Z
lib/llp/characters/characters.ex
Danwhy/llp
63d4efa78b56351c9d96c46024291c828722c3fe
[ "MIT" ]
null
null
null
lib/llp/characters/characters.ex
Danwhy/llp
63d4efa78b56351c9d96c46024291c828722c3fe
[ "MIT" ]
null
null
null
defmodule Llp.Characters do @moduledoc """ The Characters context. """ import Ecto.Query, warn: false alias Llp.Repo alias Llp.Characters.Radical @doc """ Returns the list of radicals. ## Examples iex> list_radicals() [%Radical{}, ...] """ def list_radicals do Repo.all(Radical) end @doc """ Gets a single radical by id. Raises `Ecto.NoResultsError` if the Radical does not exist. ## Examples iex> get_radical!(123) %Radical{} iex> get_radical!(456) ** (Ecto.NoResultsError) """ def get_radical!(id), do: Repo.get!(Radical, id) @doc """ Gets a single radical by radical character. Raises `Ecto.NoResultsError` if the Radical does not exist. ## Examples iex> get_radical!("一") %Radical{} iex> get_radical!("右") ** (Ecto.NoResultsError) """ def get_radical_by_character!(character) do Repo.get_by!(Radical, radical: character) end @doc """ Creates a radical. ## Examples iex> create_radical(%{field: value}) {:ok, %Radical{}} iex> create_radical(%{field: bad_value}) {:error, %Ecto.Changeset{}} """ def create_radical(attrs \\ %{}) do %Radical{} |> Radical.changeset(attrs) |> Repo.insert() end @doc """ Updates a radical. ## Examples iex> update_radical(radical, %{field: new_value}) {:ok, %Radical{}} iex> update_radical(radical, %{field: bad_value}) {:error, %Ecto.Changeset{}} """ def update_radical(%Radical{} = radical, attrs) do radical |> Radical.changeset(attrs) |> Repo.update() end @doc """ Deletes a Radical. ## Examples iex> delete_radical(radical) {:ok, %Radical{}} iex> delete_radical(radical) {:error, %Ecto.Changeset{}} """ def delete_radical(%Radical{} = radical) do Repo.delete(radical) end @doc """ Returns an `%Ecto.Changeset{}` for tracking radical changes. ## Examples iex> change_radical(radical) %Ecto.Changeset{source: %Radical{}} """ def change_radical(%Radical{} = radical) do Radical.changeset(radical, %{}) end alias Llp.Characters.Kanji @doc """ Returns the list of kanji. ## Examples iex> list_kanji() [%Kanji{}, ...] """ def list_kanji do Repo.all(Kanji) end @doc """ Gets a single kanji. Raises `Ecto.NoResultsError` if the Kanji does not exist. ## Examples iex> get_kanji!(123) %Kanji{} iex> get_kanji!(456) ** (Ecto.NoResultsError) """ def get_kanji!(id), do: Repo.get!(Kanji, id) @doc """ Creates a kanji. ## Examples iex> create_kanji(%{field: value}) {:ok, %Kanji{}} iex> create_kanji(%{field: bad_value}) {:error, %Ecto.Changeset{}} """ def create_kanji(radical, attrs \\ %{}) do radical |> Ecto.build_assoc(:kanji) |> Kanji.changeset(attrs) |> Repo.insert() end @doc """ Updates a kanji. ## Examples iex> update_kanji(kanji, %{field: new_value}) {:ok, %Kanji{}} iex> update_kanji(kanji, %{field: bad_value}) {:error, %Ecto.Changeset{}} """ def update_kanji(%Kanji{} = kanji, attrs) do kanji |> Kanji.changeset(attrs) |> Repo.update() end @doc """ Deletes a Kanji. ## Examples iex> delete_kanji(kanji) {:ok, %Kanji{}} iex> delete_kanji(kanji) {:error, %Ecto.Changeset{}} """ def delete_kanji(%Kanji{} = kanji) do Repo.delete(kanji) end @doc """ Returns an `%Ecto.Changeset{}` for tracking kanji changes. ## Examples iex> change_kanji(kanji) %Ecto.Changeset{source: %Kanji{}} """ def change_kanji(%Kanji{} = kanji) do Kanji.changeset(kanji, %{}) end end
17.154545
62
0.591415
79d5ebde54001a402b6140adabf069b278895cf2
87
ex
Elixir
lib/tint/din99/conversions/from_din99.ex
tlux/tint
742b3cc8ffd5e90bc78fe0413286af8ec593298c
[ "MIT" ]
14
2019-10-09T19:36:04.000Z
2022-01-28T12:00:56.000Z
lib/tint/din99/conversions/from_din99.ex
tlux/tint
742b3cc8ffd5e90bc78fe0413286af8ec593298c
[ "MIT" ]
null
null
null
lib/tint/din99/conversions/from_din99.ex
tlux/tint
742b3cc8ffd5e90bc78fe0413286af8ec593298c
[ "MIT" ]
null
null
null
defimpl Tint.DIN99.Convertible, for: Tint.DIN99 do def convert(color), do: color end
21.75
50
0.758621
79d6016c4f070b40384bcf846c60a791faf3eeb0
184
ex
Elixir
lib/kv.ex
mingderwang/kv
79b10f372509089a463e871e40ad84b1abaf9d6c
[ "MIT" ]
null
null
null
lib/kv.ex
mingderwang/kv
79b10f372509089a463e871e40ad84b1abaf9d6c
[ "MIT" ]
null
null
null
lib/kv.ex
mingderwang/kv
79b10f372509089a463e871e40ad84b1abaf9d6c
[ "MIT" ]
null
null
null
defmodule KV do @moduledoc """ Documentation for KV. """ @doc """ Hello world. ## Examples iex> KV.hello() :world """ def hello do :world end end
9.684211
23
0.527174
79d6667d273cbc33f12a7e5ca7e7101cc0715b75
608
exs
Elixir
test/web/views/error_view_test.exs
KZeillmann/MenuPlanner
56bd6afca8e321261720dc290f180f4944b8b483
[ "MIT" ]
null
null
null
test/web/views/error_view_test.exs
KZeillmann/MenuPlanner
56bd6afca8e321261720dc290f180f4944b8b483
[ "MIT" ]
null
null
null
test/web/views/error_view_test.exs
KZeillmann/MenuPlanner
56bd6afca8e321261720dc290f180f4944b8b483
[ "MIT" ]
null
null
null
defmodule MenuPlanner.Web.ErrorViewTest do use MenuPlanner.Web.ConnCase, async: true # Bring render/3 and render_to_string/3 for testing custom views import Phoenix.View test "renders 404.html" do assert render_to_string(MenuPlanner.Web.ErrorView, "404.html", []) == "Page not found" end test "render 500.html" do assert render_to_string(MenuPlanner.Web.ErrorView, "500.html", []) == "Internal server error" end test "render any other" do assert render_to_string(MenuPlanner.Web.ErrorView, "505.html", []) == "Internal server error" end end
27.636364
73
0.689145
79d6825462330dcfd75191b16a5300107d624d94
583
exs
Elixir
plugins/ucc_chat/test/ucc_chat/web/views/error_view_test.exs
josephkabraham/ucx_ucc
0dbd9e3eb5940336b4870cff033482ceba5f6ee7
[ "MIT" ]
null
null
null
plugins/ucc_chat/test/ucc_chat/web/views/error_view_test.exs
josephkabraham/ucx_ucc
0dbd9e3eb5940336b4870cff033482ceba5f6ee7
[ "MIT" ]
null
null
null
plugins/ucc_chat/test/ucc_chat/web/views/error_view_test.exs
josephkabraham/ucx_ucc
0dbd9e3eb5940336b4870cff033482ceba5f6ee7
[ "MIT" ]
null
null
null
defmodule UccChatWeb.ErrorViewTest do use UccChatWeb.ConnCase, async: true # Bring render/3 and render_to_string/3 for testing custom views import Phoenix.View test "renders 404.html" do assert render_to_string(UccChatWeb.ErrorView, "404.html", []) == "Page not found" end test "render 500.html" do assert render_to_string(UccChatWeb.ErrorView, "500.html", []) == "Internal server error" end test "render any other" do assert render_to_string(UccChatWeb.ErrorView, "505.html", []) == "Internal server error" end end
26.5
68
0.684391
79d6a0901526ef66c59592886bf7b6a6282547c4
1,320
ex
Elixir
lib/policr_mini_bot/runner.ex
skyplaying/policr-mini
ac265daa251fd76b770d0ce08c67075a6a57f796
[ "MIT" ]
null
null
null
lib/policr_mini_bot/runner.ex
skyplaying/policr-mini
ac265daa251fd76b770d0ce08c67075a6a57f796
[ "MIT" ]
2
2022-02-25T06:15:30.000Z
2022-02-25T06:15:33.000Z
lib/policr_mini_bot/runner.ex
skyplaying/policr-mini
ac265daa251fd76b770d0ce08c67075a6a57f796
[ "MIT" ]
null
null
null
defmodule PolicrMiniBot.Runner do @moduledoc """ 定时任务功能。 """ defmodule Job do @moduledoc false use TypedStruct typedstruct do field :name, String.t() field :name_text, String.t() field :schedule_text, String.t() field :next_run_datetime, NaiveDateTime.t() field :timezone, String end def from({name, job}) when is_atom(name) and is_struct(job, Quantum.Job) do %__MODULE__{ name: name, next_run_datetime: Crontab.Scheduler.get_next_run_date!(job.schedule), timezone: job.timezone |> Atom.to_string() |> String.upcase() } |> put_text() end @spec put_text(map) :: map def put_text(%{name: :expired_check} = job) do %{job | name_text: "过期验证检查", schedule_text: "每 5 分钟"} end def put_text(%{name: :working_check} = job) do %{job | name_text: "工作状态检查", schedule_text: "每 55 分钟"} end def put_text(%{name: :left_check} = job) do %{job | name_text: "退出检查", schedule_text: "每日"} end def put_text(%{name: :third_parties_running_days_update} = job) do %{job | name_text: "第三方实例运行天数更新", schedule_text: "每日"} end end @spec jobs() :: [Job.t()] def jobs do quantom_jobs = PolicrMiniBot.Scheduler.jobs() Enum.map(quantom_jobs, &Job.from/1) end end
24.90566
79
0.624242
79d6c4c242d1c5a1bd9b54ed39518c21b35dcb7f
240
exs
Elixir
test/tirexs/search/size_test.exs
DataKrewTech/tirexs
8238da373f4547d27eea57a10826114e947aa66b
[ "Apache-2.0" ]
384
2015-03-09T05:03:42.000Z
2022-02-27T00:45:58.000Z
test/tirexs/search/size_test.exs
DataKrewTech/tirexs
8238da373f4547d27eea57a10826114e947aa66b
[ "Apache-2.0" ]
144
2015-03-06T11:19:49.000Z
2021-06-11T11:26:39.000Z
test/tirexs/search/size_test.exs
DataKrewTech/tirexs
8238da373f4547d27eea57a10826114e947aa66b
[ "Apache-2.0" ]
97
2015-03-21T13:58:38.000Z
2022-01-07T14:40:49.000Z
Code.require_file "../../../test_helper.exs", __ENV__.file defmodule Tirexs.Search.SizeTest do use ExUnit.Case import Tirexs.Search test "size" do size = size 10 expected = [size: 10] assert size == expected end end
16
58
0.670833
79d6d6f87cf52abab7521c95e984114bb0a5f165
5,514
exs
Elixir
lib/elixir/test/elixir/protocol/consolidation_test.exs
irisTa56/elixir
0a953d75fb2cbdc6f3d33040aa60738d85512a1f
[ "Apache-2.0" ]
null
null
null
lib/elixir/test/elixir/protocol/consolidation_test.exs
irisTa56/elixir
0a953d75fb2cbdc6f3d33040aa60738d85512a1f
[ "Apache-2.0" ]
null
null
null
lib/elixir/test/elixir/protocol/consolidation_test.exs
irisTa56/elixir
0a953d75fb2cbdc6f3d33040aa60738d85512a1f
[ "Apache-2.0" ]
null
null
null
Code.require_file("../test_helper.exs", __DIR__) path = Path.expand("../../ebin", __DIR__) File.mkdir_p!(path) files = Path.wildcard(PathHelpers.fixture_path("consolidation/*")) Kernel.ParallelCompiler.compile_to_path(files, path) defmodule Protocol.ConsolidationTest do use ExUnit.Case, asnyc: true alias Protocol.ConsolidationTest.{Sample, WithAny} defimpl WithAny, for: Map do def ok(map) do {:ok, map} end end defimpl WithAny, for: Any do def ok(any) do {:ok, any} end end defmodule NoImplStruct do defstruct a: 0, b: 0 end defmodule ImplStruct do @derive [WithAny] defstruct a: 0, b: 0 defimpl Sample do @compile {:no_warn_undefined, Unknown} def ok(struct) do Unknown.undefined(struct) end end end Code.append_path(path) # Any is ignored because there is no fallback :code.purge(Sample) :code.delete(Sample) {:ok, binary} = Protocol.consolidate(Sample, [Any, ImplStruct]) :code.load_binary(Sample, 'protocol_test.exs', binary) @sample_binary binary # Any should be moved to the end :code.purge(WithAny) :code.delete(WithAny) {:ok, binary} = Protocol.consolidate(WithAny, [Any, ImplStruct, Map]) :code.load_binary(WithAny, 'protocol_test.exs', binary) test "consolidated?/1" do assert Protocol.consolidated?(WithAny) refute Protocol.consolidated?(Enumerable) end test "consolidation prevents new implementations" do output = ExUnit.CaptureIO.capture_io(:stderr, fn -> defimpl WithAny, for: Integer do def ok(_any), do: :ok end end) assert output =~ ~r"the .+WithAny protocol has already been consolidated" after :code.purge(WithAny.Integer) :code.delete(WithAny.Integer) end test "consolidated implementations without any" do assert is_nil(Sample.impl_for(:foo)) assert is_nil(Sample.impl_for(fn x -> x end)) assert is_nil(Sample.impl_for(1)) assert is_nil(Sample.impl_for(1.1)) assert is_nil(Sample.impl_for([])) assert is_nil(Sample.impl_for([1, 2, 3])) assert is_nil(Sample.impl_for({})) assert is_nil(Sample.impl_for({1, 2, 3})) assert is_nil(Sample.impl_for("foo")) assert is_nil(Sample.impl_for(<<1>>)) assert is_nil(Sample.impl_for(self())) assert is_nil(Sample.impl_for(%{})) assert is_nil(Sample.impl_for(hd(:erlang.ports()))) assert is_nil(Sample.impl_for(make_ref())) assert Sample.impl_for(%ImplStruct{}) == Sample.Protocol.ConsolidationTest.ImplStruct assert Sample.impl_for(%NoImplStruct{}) == nil end test "consolidated implementations with any and tuple fallback" do assert WithAny.impl_for(%NoImplStruct{}) == WithAny.Any # Derived assert WithAny.impl_for(%ImplStruct{}) == WithAny.Any assert WithAny.impl_for(%{__struct__: "foo"}) == WithAny.Map assert WithAny.impl_for(%{}) == WithAny.Map assert WithAny.impl_for(self()) == WithAny.Any end test "consolidation keeps docs" do {:ok, {Sample, [{'Docs', docs_bin}]}} = :beam_lib.chunks(@sample_binary, ['Docs']) {:docs_v1, _, _, _, _, _, docs} = :erlang.binary_to_term(docs_bin) ok_doc = List.keyfind(docs, {:function, :ok, 1}, 0) assert {{:function, :ok, 1}, _, ["ok(term)"], %{"en" => "Ok"}, _} = ok_doc end test "consolidation keeps chunks" do deprecated = [{{:ok, 1}, "Reason"}] assert deprecated == Sample.__info__(:deprecated) {:ok, {Sample, [{'ExCk', check_bin}]}} = :beam_lib.chunks(@sample_binary, ['ExCk']) assert {:elixir_checker_v1, contents} = :erlang.binary_to_term(check_bin) export_info = %{deprecated_reason: "Reason", kind: :def, type: [[var: 0]]} assert {{:ok, 1}, export_info} in contents.exports end test "consolidation keeps source" do assert Sample.__info__(:compile)[:source] end test "consolidated keeps callbacks" do {:ok, callbacks} = Code.Typespec.fetch_callbacks(@sample_binary) assert callbacks != [] end test "consolidation errors on missing BEAM files" do defprotocol(NoBeam, do: nil) assert Protocol.consolidate(String, []) == {:error, :not_a_protocol} assert Protocol.consolidate(NoBeam, []) == {:error, :no_beam_info} end test "consolidation updates attributes" do assert Sample.__protocol__(:consolidated?) assert Sample.__protocol__(:impls) == {:consolidated, [ImplStruct]} assert WithAny.__protocol__(:consolidated?) assert WithAny.__protocol__(:impls) == {:consolidated, [Any, ImplStruct, Map]} end test "consolidation extracts protocols" do protos = Protocol.extract_protocols([:code.lib_dir(:elixir, :ebin)]) assert Enumerable in protos assert Inspect in protos end test "consolidation extracts implementations with charlist path" do protos = Protocol.extract_impls(Enumerable, [:code.lib_dir(:elixir, :ebin)]) assert List in protos assert Function in protos end test "consolidation extracts implementations with binary path" do protos = Protocol.extract_impls(Enumerable, [Application.app_dir(:elixir, "ebin")]) assert List in protos assert Function in protos end test "protocol not implemented" do message = "protocol Protocol.ConsolidationTest.Sample not implemented for :foo of type Atom. " <> "This protocol is implemented for the following type(s): Protocol.ConsolidationTest.ImplStruct" assert_raise Protocol.UndefinedError, message, fn -> sample = Sample sample.ok(:foo) end end end
31.508571
103
0.688429
79d6e2a546def62bf09c63a688a8f52b1c8fb612
1,063
ex
Elixir
lib/news/content/commands/title.ex
randomlabs/news
6aa200858bac69613af1de91420c6425f4517853
[ "MIT" ]
3
2015-08-12T20:45:57.000Z
2015-10-26T09:20:10.000Z
lib/news/content/commands/title.ex
randomlabs/news
6aa200858bac69613af1de91420c6425f4517853
[ "MIT" ]
15
2015-08-12T16:20:42.000Z
2015-10-12T16:12:15.000Z
lib/news/content/commands/title.ex
randomlabs/news
6aa200858bac69613af1de91420c6425f4517853
[ "MIT" ]
1
2015-08-20T17:43:10.000Z
2015-08-20T17:43:10.000Z
defmodule News.Content.Commands.Title do @behaviour News.Content.Commands.Behaviour def commands, do: ~w(title) def validate(changeset, context=%{module: News.Comment}, _, args) do unless News.Flag.on_model?(context.user, "admin") do Ecto.Changeset.add_error(changeset, :text, News.td("commands.title_forbidden")) else changeset end end def validate(changeset, _, _, _) do Ecto.Changeset.add_error(changeset, :text, News.td("commands.title_error")) end def after_save(changeset, _, _, _), do: changeset def finalize(comment, context=%{module: News.Comment}, _, args) do comment = News.Repo.preload(comment, :story) title = Enum.join(args, " ") old_title = comment.story.title News.Repo.update!(%News.Story{comment.story | title: title}) meta = News.td("commands.title_changed", [old: old_title, new: title]) News.Flag.add_to_model(comment, "admin", comment.user_id) %News.Comment{comment | meta: [meta|comment.meta], flags: ["A"|comment.flags]} end def finalize(model, _, _, _), do: model end
37.964286
85
0.699906
79d7c439e1aeb758ca4eb13bce3c149182143f3e
808
exs
Elixir
test/vector_test.exs
kianmeng/vector_ex
c89241b76c0d37f01e52e1e10ccea86fbdce4913
[ "MIT" ]
16
2016-03-29T11:44:45.000Z
2020-01-14T20:48:15.000Z
test/vector_test.exs
kianmeng/vector_ex
c89241b76c0d37f01e52e1e10ccea86fbdce4913
[ "MIT" ]
3
2019-02-28T02:17:01.000Z
2021-12-23T12:26:20.000Z
test/vector_test.exs
kianmeng/vector_ex
c89241b76c0d37f01e52e1e10ccea86fbdce4913
[ "MIT" ]
7
2017-04-28T17:25:17.000Z
2021-05-17T13:00:00.000Z
defmodule VectorTest do use ExUnit.Case, async: true import Vector doctest Vector test "basis vectors" do assert unit(basis(:x)) == basis(:x) assert unit(basis(:y)) == basis(:y) assert unit(basis(:z)) == basis(:z) assert dot(basis(:x), basis(:y)) == 0 assert dot(basis(:y), basis(:z)) == 0 assert dot(basis(:x), basis(:z)) == 0 assert cross_norm(basis(:x), basis(:y)) == 1 assert cross_norm(basis(:y), basis(:z)) == 1 assert cross_norm(basis(:x), basis(:z)) == 1 end test "component of a vector" do assert component({-1, 2}, :x) == -1 assert component({-1, 2}, :y) == 2 assert component({-1, 2}, :z) == 0 assert component({-1, 2, 1}, :x) == -1 assert component({-1, 2, 1}, :y) == 2 assert component({-1, 2, 1}, :z) == 1 end end
26.064516
48
0.563119
79d7de6ae9b5a3029a4c5b4e854b1a56007463ce
363
exs
Elixir
priv/repo/seeds.exs
obahareth/crypto-monitor
bd9e9f1e9627fad582329afe2c66e2de4c95768b
[ "MIT" ]
null
null
null
priv/repo/seeds.exs
obahareth/crypto-monitor
bd9e9f1e9627fad582329afe2c66e2de4c95768b
[ "MIT" ]
null
null
null
priv/repo/seeds.exs
obahareth/crypto-monitor
bd9e9f1e9627fad582329afe2c66e2de4c95768b
[ "MIT" ]
null
null
null
# Script for populating the database. You can run it as: # # mix run priv/repo/seeds.exs # # Inside the script, you can read and write to any of your # repositories directly: # # CryptoMonitor.Repo.insert!(%CryptoMonitor.SomeSchema{}) # # We recommend using the bang functions (`insert!`, `update!` # and so on) as they will fail if something goes wrong.
30.25
61
0.716253
79d802dca5ab5c77d522fe371b13d90c9ad9d470
456
ex
Elixir
lib/ash_policy_authorizer/check/actor_attribute_has_any.ex
frankdugan3/ash_policy_authorizer
e3da0f69c34daea187597f9b1764f0756b0e3b9c
[ "MIT" ]
null
null
null
lib/ash_policy_authorizer/check/actor_attribute_has_any.ex
frankdugan3/ash_policy_authorizer
e3da0f69c34daea187597f9b1764f0756b0e3b9c
[ "MIT" ]
null
null
null
lib/ash_policy_authorizer/check/actor_attribute_has_any.ex
frankdugan3/ash_policy_authorizer
e3da0f69c34daea187597f9b1764f0756b0e3b9c
[ "MIT" ]
null
null
null
defmodule AshPolicyAuthorizer.Check.ActorAttributeHasAny do @moduledoc false use AshPolicyAuthorizer.SimpleCheck @impl true def describe(opts) do "actor.#{opts[:attribute]} has any of #{inspect(opts[:values])}" end @impl true def match?(nil, _, _), do: false def match?(actor, _context, opts) do List.wrap(Map.get(actor, opts[:attribute], [])) |> Enum.any?(fn value -> Enum.any?(opts[:values], &(&1 == value)) end) end end
25.333333
74
0.671053
79d80382ccee121891be371fddb49d39e888b992
1,903
ex
Elixir
lib/koans/09_map_sets.ex
thaberl13/elixir-koans-1
e86e060621124dc331abb38d761d9653441673d7
[ "MIT" ]
1,944
2016-04-24T02:46:10.000Z
2022-03-29T00:19:17.000Z
lib/koans/09_map_sets.ex
thaberl13/elixir-koans-1
e86e060621124dc331abb38d761d9653441673d7
[ "MIT" ]
157
2016-04-23T18:40:24.000Z
2022-02-10T14:00:45.000Z
lib/koans/09_map_sets.ex
thaberl13/elixir-koans-1
e86e060621124dc331abb38d761d9653441673d7
[ "MIT" ]
636
2016-04-23T17:18:00.000Z
2022-03-23T10:04:06.000Z
defmodule MapSets do use Koans @intro "My name is Set, MapSet." @set MapSet.new([1, 2, 3, 4, 5]) koan "I do not allow duplication" do new_set = MapSet.new([1, 1, 2, 3, 3, 3]) assert MapSet.size(new_set) == ___ end def sorted?(set) do list = MapSet.to_list(set) sorted = Enum.sort(list) list == sorted end koan "You cannot depend on my order" do new_set = MapSet.new(1..33) assert sorted?(new_set) == ___ # Note: The number "33" is actually special here. Erlang uses a different # implementation for maps after 32 elements which does not maintain order. # http://stackoverflow.com/a/40408469 # What do you think this answer to this assertion is? assert sorted?(@set) == ___ end koan "Does this value exist in the map set?" do assert MapSet.member?(@set, 3) == ___ end koan "I am merely another collection, but you can perform some operations on me" do new_set = MapSet.new(@set, fn x -> 3 * x end) assert MapSet.member?(new_set, 15) == ___ assert MapSet.member?(new_set, 1) == ___ end koan "Add this value into a map set" do modified_set = MapSet.put(@set, 6) assert MapSet.member?(modified_set, 6) == ___ end koan "Delete this value from the map set" do modified_set = MapSet.delete(@set, 1) assert MapSet.member?(modified_set, 1) == ___ end koan "Are these maps twins?" do new_set = MapSet.new([1, 2, 3]) assert MapSet.equal?(@set, new_set) == ___ end koan "I want only the common values in both sets" do intersection_set = MapSet.intersection(@set, MapSet.new([5, 6, 7])) assert MapSet.member?(intersection_set, 5) == ___ end koan "Unify my sets" do new_set = MapSet.union(@set, MapSet.new([1, 5, 6, 7])) assert MapSet.size(new_set) == ___ end koan "I want my set in a list" do assert MapSet.to_list(@set) == ___ end end
24.714286
85
0.648975
79d808ebce1d7f8f13badc70e64be807a61a17d8
315
exs
Elixir
v02/ch14/case2.edit2.exs
oiax/elixir-primer
c8b89a29f108cc335b8e1341b7a1e90ec12adc66
[ "MIT" ]
null
null
null
v02/ch14/case2.edit2.exs
oiax/elixir-primer
c8b89a29f108cc335b8e1341b7a1e90ec12adc66
[ "MIT" ]
null
null
null
v02/ch14/case2.edit2.exs
oiax/elixir-primer
c8b89a29f108cc335b8e1341b7a1e90ec12adc66
[ "MIT" ]
null
null
null
list = [100, [1, 2, 3], %{value: 7}, %User{name: "Alice"}, true] for e <- list do x = case e do n when is_integer(n) -> n l when is_list(l) -> Enum.join(l, ":") %{__struct__: _} = u -> "name = #{u.name}" m when is_map(m) -> "value = #{m.value}" b when is_boolean(b) -> b end IO.puts x end
26.25
64
0.520635
79d8155818fa29551896e07cfdbc2f082d99dd1b
1,870
exs
Elixir
chapter2/exlivery/test/orders/create_or_update_test.exs
mCodex/rocketseat-ignite-elixir
bdb48db778c36b2325c75a41b4d6f7ef77b03cf5
[ "MIT" ]
1
2021-07-23T19:48:27.000Z
2021-07-23T19:48:27.000Z
chapter2/exlivery/test/orders/create_or_update_test.exs
mCodex/rocketseat-ignite-elixir
bdb48db778c36b2325c75a41b4d6f7ef77b03cf5
[ "MIT" ]
null
null
null
chapter2/exlivery/test/orders/create_or_update_test.exs
mCodex/rocketseat-ignite-elixir
bdb48db778c36b2325c75a41b4d6f7ef77b03cf5
[ "MIT" ]
null
null
null
defmodule Exlivery.Orders.CreateOrUpdateTest do use ExUnit.Case import Exlivery.Factory alias Exlivery.Orders.CreateOrUpdate alias Exlivery.Users.Agent, as: UserAgent describe "call/1" do setup do cpf = "123456" user = build(:user, cpf: cpf) Exlivery.start_agents() UserAgent.save(user) item1 = %{ category: :pizza, description: "Pizza", quantity: 1, unity_price: "35.50" } item2 = %{ category: :pizza, description: "Pizza 2", quantity: 1, unity_price: "32.00" } {:ok, user_cpf: cpf, item1: item1, item2: item2} end test "when all params are valid, returns the order", %{ user_cpf: cpf, item1: item1, item2: item2 } do params = %{user_cpf: cpf, items: [item1, item2]} response = CreateOrUpdate.call(params) assert {:ok, _uuid} = response end test "when there is no user with given cpf, returns an error", %{ item1: item1, item2: item2 } do params = %{user_cpf: "invalid_cpf", items: [item1, item2]} response = CreateOrUpdate.call(params) assert {:error, _message} = response end test "when there are invalid items, returns an error", %{ user_cpf: cpf, item1: item1, item2: item2 } do params = %{user_cpf: cpf, items: [%{item1 | quantity: 0}, item2]} response = CreateOrUpdate.call(params) expected_response = {:error, "Invalid items"} assert response == expected_response end test "when there are no items, returns an error", %{ user_cpf: cpf } do params = %{user_cpf: cpf, items: []} response = CreateOrUpdate.call(params) expected_response = {:error, "Invalid Parameters"} assert response == expected_response end end end
22
71
0.596257
79d82a2fd0d4d9cbe70e911734ce4a92d5c2724e
1,824
ex
Elixir
clients/dlp/lib/google_api/dlp/v2/model/google_privacy_dlp_v2_chars_to_ignore.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/dlp/lib/google_api/dlp/v2/model/google_privacy_dlp_v2_chars_to_ignore.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/dlp/lib/google_api/dlp/v2/model/google_privacy_dlp_v2_chars_to_ignore.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
1
2020-11-10T16:58:27.000Z
2020-11-10T16:58:27.000Z
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2CharsToIgnore do @moduledoc """ Characters to skip when doing deidentification of a value. These will be left alone and skipped. ## Attributes - charactersToSkip (String.t): Defaults to: `null`. - commonCharactersToIgnore (String.t): Defaults to: `null`. - Enum - one of [COMMON_CHARS_TO_IGNORE_UNSPECIFIED, NUMERIC, ALPHA_UPPER_CASE, ALPHA_LOWER_CASE, PUNCTUATION, WHITESPACE] """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :charactersToSkip => any(), :commonCharactersToIgnore => any() } field(:charactersToSkip) field(:commonCharactersToIgnore) end defimpl Poison.Decoder, for: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2CharsToIgnore do def decode(value, options) do GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2CharsToIgnore.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.DLP.V2.Model.GooglePrivacyDlpV2CharsToIgnore do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
35.076923
126
0.754934
79d89db621f4ef05cf2c4ac368841c927810e9be
10,959
ex
Elixir
lib/erlef_web/views/grant_view.ex
ferd/website
400409d05ba91ff2a84179ed9a769196aee8f564
[ "Apache-2.0" ]
null
null
null
lib/erlef_web/views/grant_view.ex
ferd/website
400409d05ba91ff2a84179ed9a769196aee8f564
[ "Apache-2.0" ]
null
null
null
lib/erlef_web/views/grant_view.ex
ferd/website
400409d05ba91ff2a84179ed9a769196aee8f564
[ "Apache-2.0" ]
null
null
null
defmodule ErlefWeb.StipendView do use ErlefWeb, :view # Currently values chosen for select simply go into an html doc so we map name to name as to avoid # stipend reviewers having to look up the country name for agiven code. @country_data [ {"Select your country", ""}, {"Afghanistan", "Afghanistan"}, {"Albania", "Albania"}, {"Algeria", "Algeria"}, {"American Samoa", "American Samoa"}, {"Andorra", "Andorra"}, {"Angola", "Angola"}, {"Anguilla", "Anguilla"}, {"Antarctica", "Antarctica"}, {"Antigua And Barbuda", "Antigua And Barbuda"}, {"Argentina", "Argentina"}, {"Armenia", "Armenia"}, {"Aruba", "Aruba"}, {"Australia", "Australia"}, {"Austria", "Austria"}, {"Azerbaijan", "Azerbaijan"}, {"Bahamas", "Bahamas"}, {"Bahrain", "Bahrain"}, {"Bangladesh", "Bangladesh"}, {"Barbados", "Barbados"}, {"Belarus", "Belarus"}, {"Belgium", "Belgium"}, {"Belize", "Belize"}, {"Benin", "Benin"}, {"Bermuda", "Bermuda"}, {"Bhutan", "Bhutan"}, {"Bolivia", "Bolivia"}, {"Bosnia And Herzegovina", "Bosnia And Herzegovina"}, {"Botswana", "Botswana"}, {"Bouvet Island", "Bouvet Island"}, {"Brazil", "Brazil"}, {"British Indian Ocean Territory", "British Indian Ocean Territory"}, {"Brunei Darussalam", "Brunei Darussalam"}, {"Bulgaria", "Bulgaria"}, {"Burkina Faso", "Burkina Faso"}, {"Burundi", "Burundi"}, {"Cambodia", "Cambodia"}, {"Cameroon", "Cameroon"}, {"Canada", "Canada"}, {"Cape Verde", "Cape Verde"}, {"Cayman Islands", "Cayman Islands"}, {"Central African Republic", "Central African Republic"}, {"Chad", "Chad"}, {"Chile", "Chile"}, {"China", "China"}, {"Christmas Island", "Christmas Island"}, {"Cocos (keeling) Islands", "Cocos (keeling) Islands"}, {"Colombia", "Colombia"}, {"Comoros", "Comoros"}, {"Congo", "Congo"}, {"Congo, The Democratic Republic Of The", "Congo, The Democratic Republic Of The"}, {"Cook Islands", "Cook Islands"}, {"Costa Rica", "Costa Rica"}, {"Cote D'ivoire", "Cote D'ivoire"}, {"Croatia", "Croatia"}, {"Cuba", "Cuba"}, {"Cyprus", "Cyprus"}, {"Czech Republic", "Czech Republic"}, {"Denmark", "Denmark"}, {"Djibouti", "Djibouti"}, {"Dominica", "Dominica"}, {"Dominican Republic", "Dominican Republic"}, {"East Timor", "East Timor"}, {"Ecuador", "Ecuador"}, {"Egypt", "Egypt"}, {"El Salvador", "El Salvador"}, {"Equatorial Guinea", "Equatorial Guinea"}, {"Eritrea", "Eritrea"}, {"Estonia", "Estonia"}, {"Ethiopia", "Ethiopia"}, {"Falkland Islands (malvinas)", "Falkland Islands (malvinas)"}, {"Faroe Islands", "Faroe Islands"}, {"Fiji", "Fiji"}, {"Finland", "Finland"}, {"France", "France"}, {"French Guiana", "French Guiana"}, {"French Polynesia", "French Polynesia"}, {"French Southern Territories", "French Southern Territories"}, {"Gabon", "Gabon"}, {"Gambia", "Gambia"}, {"Georgia", "Georgia"}, {"Germany", "Germany"}, {"Ghana", "Ghana"}, {"Gibraltar", "Gibraltar"}, {"Greece", "Greece"}, {"Greenland", "Greenland"}, {"Grenada", "Grenada"}, {"Guadeloupe", "Guadeloupe"}, {"Guam", "Guam"}, {"Guatemala", "Guatemala"}, {"Guinea", "Guinea"}, {"Guinea-bissau", "Guinea-bissau"}, {"Guyana", "Guyana"}, {"Haiti", "Haiti"}, {"Heard Island And Mcdonald Islands", "Heard Island And Mcdonald Islands"}, {"Holy See (vatican City State)", "Holy See (vatican City State)"}, {"Honduras", "Honduras"}, {"Hong Kong", "Hong Kong"}, {"Hungary", "Hungary"}, {"Iceland", "Iceland"}, {"India", "India"}, {"Indonesia", "Indonesia"}, {"Iran, Islamic Republic Of", "Iran, Islamic Republic Of"}, {"Iraq", "Iraq"}, {"Ireland", "Ireland"}, {"Israel", "Israel"}, {"Italy", "Italy"}, {"Jamaica", "Jamaica"}, {"Japan", "Japan"}, {"Jordan", "Jordan"}, {"Kazakstan", "Kazakstan"}, {"Kenya", "Kenya"}, {"Kiribati", "Kiribati"}, {"Korea, Democratic People's Republic Of", "Korea, Democratic People's Republic Of"}, {"Korea, Republic Of", "Korea, Republic Of"}, {"Kosovo", "Kosovo"}, {"Kuwait", "Kuwait"}, {"Kyrgyzstan", "Kyrgyzstan"}, {"Lao People's Democratic Republic", "Lao People's Democratic Republic"}, {"Latvia", "Latvia"}, {"Lebanon", "Lebanon"}, {"Lesotho", "Lesotho"}, {"Liberia", "Liberia"}, {"Libyan Arab Jamahiriya", "Libyan Arab Jamahiriya"}, {"Liechtenstein", "Liechtenstein"}, {"Lithuania", "Lithuania"}, {"Luxembourg", "Luxembourg"}, {"Macau", "Macau"}, {"Macedonia, The Former Yugoslav Republic Of", "Macedonia, The Former Yugoslav Republic Of"}, {"Madagascar", "Madagascar"}, {"Malawi", "Malawi"}, {"Malaysia", "Malaysia"}, {"Maldives", "Maldives"}, {"Mali", "Mali"}, {"Malta", "Malta"}, {"Marshall Islands", "Marshall Islands"}, {"Martinique", "Martinique"}, {"Mauritania", "Mauritania"}, {"Mauritius", "Mauritius"}, {"Mayotte", "Mayotte"}, {"Mexico", "Mexico"}, {"Micronesia, Federated States Of", "Micronesia, Federated States Of"}, {"Moldova, Republic Of", "Moldova, Republic Of"}, {"Monaco", "Monaco"}, {"Mongolia", "Mongolia"}, {"Montenegro", "Montenegro"}, {"Montserrat", "Montserrat"}, {"Morocco", "Morocco"}, {"Mozambique", "Mozambique"}, {"Myanmar", "Myanmar"}, {"Namibia", "Namibia"}, {"Nauru", "Nauru"}, {"Nepal", "Nepal"}, {"Netherlands", "Netherlands"}, {"Netherlands Antilles", "Netherlands Antilles"}, {"New Caledonia", "New Caledonia"}, {"New Zealand", "New Zealand"}, {"Nicaragua", "Nicaragua"}, {"Niger", "Niger"}, {"Nigeria", "Nigeria"}, {"Niue", "Niue"}, {"Norfolk Island", "Norfolk Island"}, {"Northern Mariana Islands", "Northern Mariana Islands"}, {"Norway", "Norway"}, {"Oman", "Oman"}, {"Pakistan", "Pakistan"}, {"Palau", "Palau"}, {"Palestinian Territory, Occupied", "Palestinian Territory, Occupied"}, {"Panama", "Panama"}, {"Papua New Guinea", "Papua New Guinea"}, {"Paraguay", "Paraguay"}, {"Peru", "Peru"}, {"Philippines", "Philippines"}, {"Pitcairn", "Pitcairn"}, {"Poland", "Poland"}, {"Portugal", "Portugal"}, {"Puerto Rico", "Puerto Rico"}, {"Qatar", "Qatar"}, {"Reunion", "Reunion"}, {"Romania", "Romania"}, {"Russian Federation", "Russian Federation"}, {"Rwanda", "Rwanda"}, {"Saint Helena", "Saint Helena"}, {"Saint Kitts And Nevis", "Saint Kitts And Nevis"}, {"Saint Lucia", "Saint Lucia"}, {"Saint Pierre And Miquelon", "Saint Pierre And Miquelon"}, {"Saint Vincent And The Grenadines", "Saint Vincent And The Grenadines"}, {"Samoa", "Samoa"}, {"San Marino", "San Marino"}, {"Sao Tome And Principe", "Sao Tome And Principe"}, {"Saudi Arabia", "Saudi Arabia"}, {"Senegal", "Senegal"}, {"Serbia", "Serbia"}, {"Seychelles", "Seychelles"}, {"Sierra Leone", "Sierra Leone"}, {"Singapore", "Singapore"}, {"Slovakia", "Slovakia"}, {"Slovenia", "Slovenia"}, {"Solomon Islands", "Solomon Islands"}, {"Somalia", "Somalia"}, {"South Africa", "South Africa"}, {"South Georgia And The South Sandwich Islands", "South Georgia And The South Sandwich Islands"}, {"Spain", "Spain"}, {"Sri Lanka", "Sri Lanka"}, {"Sudan", "Sudan"}, {"Suriname", "Suriname"}, {"Svalbard And Jan Mayen", "Svalbard And Jan Mayen"}, {"Swaziland", "Swaziland"}, {"Sweden", "Sweden"}, {"Switzerland", "Switzerland"}, {"Syrian Arab Republic", "Syrian Arab Republic"}, {"Taiwan, Province Of China", "Taiwan, Province Of China"}, {"Tajikistan", "Tajikistan"}, {"Tanzania, United Republic Of", "Tanzania, United Republic Of"}, {"Thailand", "Thailand"}, {"Togo", "Togo"}, {"Tokelau", "Tokelau"}, {"Tonga", "Tonga"}, {"Trinidad And Tobago", "Trinidad And Tobago"}, {"Tunisia", "Tunisia"}, {"Turkey", "Turkey"}, {"Turkmenistan", "Turkmenistan"}, {"Turks And Caicos Islands", "Turks And Caicos Islands"}, {"Tuvalu", "Tuvalu"}, {"Uganda", "Uganda"}, {"Ukraine", "Ukraine"}, {"United Arab Emirates", "United Arab Emirates"}, {"United Kingdom", "United Kingdom"}, {"United States", "United States"}, {"United States Minor Outlying Islands", "United States Minor Outlying Islands"}, {"Uruguay", "Uruguay"}, {"Uzbekistan", "Uzbekistan"}, {"Vanuatu", "Vanuatu"}, {"Venezuela", "Venezuela"}, {"Viet Nam", "Viet Nam"}, {"Virgin Islands, British", "Virgin Islands, British"}, {"Virgin Islands, U.s.", "Virgin Islands, U.s."}, {"Wallis And Futuna", "Wallis And Futuna"}, {"Western Sahara", "Western Sahara"}, {"Yemen", "Yemen"}, {"Zambia", "Zambia"}, {"Zimbabwe", "Zimbabwe"} ] def stipend_type_select(form) do select( form, :stipend_type, [ [key: "--", value: "", "data-type": "none", "data-requires-coc": "false"], [ key: "Conference", value: "conference", "data-type": "conference", "data-requires-coc": "true" ], [ key: "Development Work", value: "Development Work", "data-type": "devel_work", "data-requires-coc": "false" ], [ key: "Event Site Subscription", value: "Event Site Subscription", "data-type": "event_site_sub", "data-requires-coc": "false" ], [ key: "Kids Coding Camp", value: "Kids Coding Camp", "data-type": "kids_camp", "data-requires-coc": "false" ], [key: "Sprint", value: "Sprint", "data-type": "sprint", "data-requires-coc": "false"], [ key: "Training Program", value: "Training Program", "data-type": "training", "data-requires-coc": "false" ], [ key: "Workshop-Education", value: "Workshop-Education", "data-type": "workshop-edu", "data-requires-coc": "true" ], [ key: "Workshop-Women", value: "Workshop-Women", "data-type": "workshop-women", "data-requires-coc": "true" ], [key: "Other", value: "Other", "data-type": "other", "data-requires-coc": "false"] ], id: "stipend_type", class: "form-control" ) end def payment_method_select(form) do select( form, :payment_method, [[key: "--", value: ""], "Paypal", "Zelle", "Check", "Wire"], class: "form-control", required: "true" ) end def country_select(form) do select(form, :country, @country_data, class: "selectpicker form-control", "data-live-search": "true" ) end end
33.616564
100
0.560544
79d8b0e4eb8246364b3b2be3dae902cc14ff7bd4
1,779
ex
Elixir
deps/absinthe/lib/absinthe/phase/document/validation/no_unused_variables.ex
JoakimEskils/elixir-absinthe
d81e24ec7c7b1164e6d152101dd50422f192d7e9
[ "MIT" ]
3
2017-06-22T16:33:58.000Z
2021-07-07T15:21:09.000Z
lib/absinthe/phase/document/validation/no_unused_variables.ex
bruce/absinthe
19b63d3aaa9fb75aad01ffd5e91d89e0b30d7f91
[ "MIT" ]
null
null
null
lib/absinthe/phase/document/validation/no_unused_variables.ex
bruce/absinthe
19b63d3aaa9fb75aad01ffd5e91d89e0b30d7f91
[ "MIT" ]
null
null
null
defmodule Absinthe.Phase.Document.Validation.NoUnusedVariables do @moduledoc false # Validates document to ensure that the only variables that are used in a # document are defined on the operation. alias Absinthe.{Blueprint, Phase} use Absinthe.Phase use Absinthe.Phase.Validation @doc """ Run the validation. """ @spec run(Blueprint.t, Keyword.t) :: Phase.result_t def run(input, _options \\ []) do result = Blueprint.prewalk(input, &handle_node(&1, input.operations)) {:ok, result} end def handle_node(%Blueprint.Document.VariableDefinition{} = node, operations) do errors = for op <- operations do for var <- op.variable_definitions, var.name == node.name do if Enum.find(op.variable_uses, &(&1.name == var.name)) do [] else [error(node, op)] end end end |> List.flatten case errors do [] -> node errors -> %{node | errors: errors ++ node.errors} |> flag_invalid(:unused) end end def handle_node(node, _) do node end # Generate the error for the node @spec error(Blueprint.Document.VariableDefinition.t, Blueprint.Document.Operation.t) :: Phase.Error.t defp error(node, operation) do %Phase.Error{ phase: __MODULE__, message: error_message(node.name, operation.name), locations: [node.source_location, operation.source_location], } end @doc """ Generate an error message for an unused variable. """ @spec error_message(String.t, nil | String.t) :: String.t def error_message(name, nil) do ~s(Variable "#{name}" is never used.) end def error_message(name, operation_name) do ~s(Variable "#{name}" is never used in operation "#{operation_name}".) end end
26.552239
103
0.654862
79d8db1ade9efa780d045dc30b9f83ce5991e242
635
ex
Elixir
Microsoft.Azure.Management.Database.MySql/lib/microsoft/azure/management/database/my_sql/model/firewall_rule.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.Database.MySql/lib/microsoft/azure/management/database/my_sql/model/firewall_rule.ex
chgeuer/ex_microsoft_azure_management
99cd9f7f2ff1fdbe69ca5bac55b6e2af91ba3603
[ "Apache-2.0" ]
null
null
null
Microsoft.Azure.Management.Database.MySql/lib/microsoft/azure/management/database/my_sql/model/firewall_rule.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.Database.MySql.Model.FirewallRule do @moduledoc """ Represents a server firewall rule. """ @derive [Poison.Encoder] defstruct [ :"id", :"name", :"type" ] @type t :: %__MODULE__{ :"id" => String.t, :"name" => String.t, :"type" => String.t } end defimpl Poison.Decoder, for: Microsoft.Azure.Management.Database.MySql.Model.FirewallRule do def decode(value, _options) do value end end
21.166667
92
0.677165
79d922e4c083ea0b6a0d41f458377e4a38621223
1,680
exs
Elixir
config/dev.exs
jdalberg/hello
fcf54ad9c74cdfd8538a7081ce35c144c87698d6
[ "MIT" ]
1
2018-08-19T14:33:44.000Z
2018-08-19T14:33:44.000Z
config/dev.exs
jdalberg/hello
fcf54ad9c74cdfd8538a7081ce35c144c87698d6
[ "MIT" ]
null
null
null
config/dev.exs
jdalberg/hello
fcf54ad9c74cdfd8538a7081ce35c144c87698d6
[ "MIT" ]
null
null
null
use Mix.Config # For development, we disable any cache and enable # debugging and code reloading. # # The watchers configuration can be used to run external # watchers to your application. For example, we use it # with brunch.io to recompile .js and .css sources. config :hello, HelloWeb.Endpoint, http: [port: 4000], debug_errors: true, code_reloader: true, check_origin: false, watchers: [node: ["node_modules/rollup/bin/rollup", "-c", "-w", cd: Path.expand("../assets", __DIR__)]] # ## SSL Support # # In order to use HTTPS in development, a self-signed # certificate can be generated by running the following # command from your terminal: # # openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout priv/server.key -out priv/server.pem # # The `http:` config above can be replaced with: # # https: [port: 4000, keyfile: "priv/server.key", certfile: "priv/server.pem"], # # If desired, both `http:` and `https:` keys can be # configured to run both http and https servers on # different ports. # Watch static and templates for browser reloading. config :hello, HelloWeb.Endpoint, live_reload: [ patterns: [ ~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$}, ~r{priv/gettext/.*(po)$}, ~r{lib/hello_web/views/.*(ex)$}, ~r{lib/hello_web/templates/.*(eex)$} ] ] # Do not include metadata nor timestamps in development logs config :logger, :console, format: "[$level] $message\n" # Set a higher stacktrace during development. Avoid configuring such # in production as building large stacktraces may be expensive. config :phoenix, :stacktrace_depth, 20
34.285714
170
0.705357
79d94c8827b625f4502f7edeb96b25740de1188a
1,445
ex
Elixir
lib/type/error_reason.ex
wses-yoshida/antikythera
e108e59d2339edd0b0fad31ad4f41f56df45be55
[ "Apache-2.0" ]
null
null
null
lib/type/error_reason.ex
wses-yoshida/antikythera
e108e59d2339edd0b0fad31ad4f41f56df45be55
[ "Apache-2.0" ]
null
null
null
lib/type/error_reason.ex
wses-yoshida/antikythera
e108e59d2339edd0b0fad31ad4f41f56df45be55
[ "Apache-2.0" ]
null
null
null
# Copyright(c) 2015-2019 ACCESS CO., LTD. All rights reserved. use Croma defmodule Antikythera.ErrorReason do @moduledoc """ Type module for error that describes what went wrong during a process execution. Possible values for `t:t/0` are: - `{:error, Exception.t}` : An exception was thrown and was not handled. - `:timeout` : Execution timed out. - `:killed` : Process was brutally killed, typically due to heap limit violation. - `{:throw, any}` : A value was thrown but not caught. - `{:exit, any}` : Process exited before completing the execution. """ @type t :: {:error, Exception.t} | {:throw, any} | {:exit, any} | :timeout | :killed defun valid?(t :: term) :: boolean do {:error, %{__exception__: _}} -> true {:throw, _ } -> true {:exit , _ } -> true :timeout -> true :killed -> true _ -> false end @type gear_action_error_reason :: t | :timeout_in_epool_checkout @type stack_item :: {module, atom, arity | [any], [{:file, charlist} | {:line, pos_integer}]} @type stacktrace :: [stack_item] defun format(reason :: gear_action_error_reason, stacktrace :: stacktrace) :: String.t do ({kind, value}, stacktrace) -> Exception.format(kind, value, stacktrace) (reason_atom , _ ) -> "** #{reason_atom}" end end
37.051282
97
0.580623
79d958c7b4c317168304d5d0fc4b15510661ade8
13,251
ex
Elixir
lib/reflux/dns/packet.ex
lowlandresearch/reflux
1fa23e4d609bfa0a27f5f231abbfa28c8835f1f2
[ "MIT" ]
null
null
null
lib/reflux/dns/packet.ex
lowlandresearch/reflux
1fa23e4d609bfa0a27f5f231abbfa28c8835f1f2
[ "MIT" ]
null
null
null
lib/reflux/dns/packet.ex
lowlandresearch/reflux
1fa23e4d609bfa0a27f5f231abbfa28c8835f1f2
[ "MIT" ]
null
null
null
defmodule DNS do def int_bool(<< bit :: 1 >>) do int_bool(bit) end def int_bool(n) do if n != 0, do: true, else: false end def bool_int(bool) do if (bool), do: 1, else: 0 end def bin_slice(binary, start) do binary_part(binary, start, byte_size(binary) - start) end def bin_slice(binary, start, stop) do binary_part(binary, start, stop) end @doc "Simple encoding (no compression)" @spec encode_name(binary) :: {:ok, binary} def encode_name(name) do { :ok, name |> String.split(".") |> Enum.map(fn (s) -> << byte_size(s) >> <> s end) |> Enum.join("") |> (fn (s) -> s <> "\x00" end).() } end @doc """ Given a DNS packet, locate and return the binary buffer of resource records """ @spec rr_buffer(binary) :: {:ok, binary} | {:error, :atom} def rr_buffer(packet) do case packet do << _tid :: 16, _flags :: 16, _qs :: 16, _a :: 16, _au :: 16, _add :: 16, buffer :: binary >> -> if byte_size(buffer) > 0 do {:ok, buffer} else {:error, :rr_buffer_empty} end _ -> {:error, :rr_buffer_malformed} end end @doc """ Given a DNS packet, locate and return the binary buffer of resource records """ def rr_buffer!(packet) do case rr_buffer(packet) do {:ok, buffer} -> buffer {:error, error} -> raise error end end @spec decode_name(binary, binary) :: {:ok, binary} | {:error, :atom} def decode_name(packet, buffer) do decode_name(packet, [], buffer) end @spec decode_name(binary, List.t, binary) :: {:ok, binary} | {:error, :atom} def decode_name(_data, labels, << 0, _rest :: binary >>) do {:ok, labels |> Enum.reverse |> Enum.join(".")} end @spec decode_name(binary, List.t, binary) :: {:ok, binary} | {:error, :atom} def decode_name(packet, labels, buffer) do case buffer do << 1::1, 1::1, ref :: 14, rest :: binary >> -> if ref < (byte_size(packet) - byte_size(rest)) do decode_name( packet, labels, bin_slice(packet, ref) ) else {:error, :not_backward_reference} end << 0::1, 0::1, size :: 6, rest :: binary >> -> << label :: bytes-size(size), rest :: binary >> = rest decode_name(packet, [label] ++ labels , rest) _ -> {:error, :bad_rr_name_encoding} end end @spec data_after_name(binary) :: {:ok, binary} | {:error, :atom} def data_after_name(buffer) do case buffer do << 0, buffer :: binary >> -> {:ok, buffer} << 1::1, 1::1, _ref :: 14, buffer :: binary >> -> {:ok, buffer} << 0::1, 0::1, size :: 6, buffer :: binary >> -> data_after_name(bin_slice(buffer, size)) _ -> {:error, :bad_rr_name_encoding} end end @spec rr_fields(binary) :: {:ok, {map, binary}} | {:error, :atom} def rr_fields(buffer) do case buffer do << type :: 16, flush :: 1, class :: 15, rest :: binary >> -> {:ok, {%{type: type, flush: int_bool(flush), class: class}, rest}} _ -> {:error, :bad_rr_data} end end @spec rr_answer_fields(binary) :: {:ok, {map, binary}} | {:error, :atom} def rr_answer_fields(buffer) do case buffer do << ttl :: 32, size :: 16, rdata_rest :: binary >> -> if byte_size(rdata_rest) >= size do << rdata :: bytes-size(size), rest :: binary >> = rdata_rest {:ok, {%{ttl: ttl, data: rdata}, rest}} else require IEx; IEx.pry {:error, {:rdata_size_too_large, size, rdata_rest}} end _ -> {:error, :bad_rr_data} end end end defmodule DNS.RR.Properties do @doc """ The resource record class (e.g. IN) as atom """ @spec class(map) :: :IN | :CH | :unhandled def class(%{class: class}) do case class do 1 -> :IN 3 -> :CH _ -> :unhandled end end @doc """ The resource record type (e.g. A, AAAA, PTR) as atom """ @spec type(map) :: :atom def type(%{type: type}) do case type do 1 -> :A 2 -> :NS 5 -> :CNAME 6 -> :SOA 12 -> :PTR 15 -> :MX 16 -> :TXT 24 -> :SIG 25 -> :KEY 28 -> :AAAA 29 -> :LOC 33 -> :SRV 37 -> :CERT 39 -> :DNAME 43 -> :DS 45 -> :IPSECKEY 46 -> :RRSIG 47 -> :NSEC 48 -> :DNSKEY 50 -> :NSEC3 51 -> :NSEC3PARAM 250 -> :TSIG 251 -> :IXFR 252 -> :AXFR _ -> :unhandled end end end # Elixir binary pattern matching of Integer or Convert Integer to # binary # # https://stackoverflow.com/a/43073250 defmodule DNS.RR do @moduledoc """ DNS resource record """ # import DNS, only: [ # bool_int: 1, bin_slice: 2, bin_slice: 3, # ] defstruct [ name: "", type: 0, flush: false, class: 1, # RR class (IN by default) ttl: 0, # Time to live data: "", # Data associated with this Resource Record ] @spec raw_name(binary, binary) :: {:ok, {binary, binary}} | {:error, :atom} def raw_name(buffer, name \\ "") do # IO.inspect(buffer, binaries: :as_strings, label: "buffer") # IO.inspect(name, binaries: :as_strings, label: "name") case buffer do << 0, buffer :: binary >> -> {:ok, {name, buffer}} << 1::1, 1::1, ref :: 14, buffer :: binary >> -> {:ok, {name <> << 1::1, 1::1, ref >>, buffer}} << 0::1, 0::1, size :: 6, buffer :: binary >> -> # IO.inspect(size) raw_name( DNS.bin_slice(buffer, size), name <> << 0::1, 0::1, size :: 6 >> <> DNS.bin_slice(buffer, 0, size) ) _ -> {:error, :bad_rr_name_encoding} end end defimpl PacketEncoder do @spec to_bitstring(DNS.RR.t) :: binary def to_bitstring(rr = %DNS.RR{}) do with {:ok, name} <- DNS.encode_name(rr.name) do name <> << rr.type :: 16, DNS.bool_int(rr.flush) :: 1, rr.class :: 15, rr.ttl :: 32, byte_size(rr.data) :: 16 >> <> rr.data end end end @spec from_bitstring(binary, binary) :: {:ok, {DNS.RR.t, binary}} | {:error, :atom} def from_bitstring(packet, buffer) do with {:ok, name} <- DNS.decode_name(packet, buffer), {:ok, rr_rest} <- DNS.data_after_name(buffer), {:ok, {fields, answer_rest}} <- DNS.rr_fields(rr_rest), {:ok, {answer_fields, rest}} <- DNS.rr_answer_fields(answer_rest) do {:ok, { %DNS.RR{name: name} |> Map.merge(fields) |> Map.merge(answer_fields), rest }} end end end defmodule DNS.Query do @moduledoc """ DNS Query """ import DNS, only: [ encode_name: 1, decode_name: 2, data_after_name: 1, rr_fields: 1, ] defstruct [ name: "", type: 0, flush: false, class: 1, ] defimpl PacketEncoder do @spec to_bitstring(DNS.Query.t) :: binary def to_bitstring(query = %DNS.Query{}) do with {:ok, name} <- encode_name(query.name) do name <> << query.type :: 16, query.class :: 16, >> end end end @spec from_bitstring(binary, binary) :: {:ok, {DNS.Query.t, binary}} | {:error, :atom} def from_bitstring(packet, buffer) do with {:ok, name} <- DNS.decode_name(packet, buffer), {:ok, rr_rest} <- DNS.data_after_name(buffer), {:ok, {fields, rest}} <- DNS.rr_fields(rr_rest) do {:ok, { %DNS.Query{name: name} |> Map.merge(fields), rest }} end end end defmodule DNS.Packet do import DNS, only: [ bool_int: 1, int_bool: 1, ] defstruct [ tid: 0, response: false, opcode: 0, authoritative: false, truncated: false, recursion_desired: false, recursion_available: false, z: 0, answer_is_auth: false, non_auth_data_ok: false, response_code: 0, queries: [], answers: [], nameservers: [], additional: [], ] # @type t :: %__MODULE__{ # tid: integer, flags: integer, # questions: integer, answer_rrs: integer, # authority_rrs: integer, additional_rrs: integer, # queries: List.t, answers: List.t, nameservers: [], records: [], # } # ("Tid", "\x00\x00"), # ("Flags", "\x84\x00"), # ("Question", "\x00\x00"), # ("AnswerRRS", "\x00\x01"), # ("AuthorityRRS", "\x00\x00"), # ("AdditionalRRS", "\x00\x00"), # ("AnswerName", ""), # ("AnswerNameNull", "\x00"), # ("Type", "\x00\x01"), # ("Class", "\x00\x01"), # ("TTL", "\x00\x00\x00\x78"),##Poison for 2mn. # ("IPLen", "\x00\x04"), # ("IP", "\x00\x00\x00\x00"), defimpl PacketEncoder do @spec to_bitstring(DNS.Packet.t) :: binary def to_bitstring(packet = %DNS.Packet{}) do << packet.tid :: 16, bool_int(packet.response) :: 1, packet.opcode :: 4, bool_int(packet.authoritative) :: 1, bool_int(packet.truncated) :: 1, bool_int(packet.recursion_desired) :: 1, bool_int(packet.recursion_available) :: 1, packet.z :: 1, bool_int(packet.answer_is_auth) :: 1, bool_int(packet.non_auth_data_ok) :: 1, packet.response_code :: 4, Enum.count(packet.queries) :: 16, Enum.count(packet.answers) :: 16, Enum.count(packet.nameservers) :: 16, Enum.count(packet.additional) :: 16 >> <> ( packet.queries |> Enum.map(&PacketEncoder.to_bitstring/1) |> Enum.join("") ) <> ( packet.answers |> Enum.map(&PacketEncoder.to_bitstring/1) |> Enum.join("") ) <> ( packet.nameservers |> Enum.map(&PacketEncoder.to_bitstring/1) |> Enum.join("") ) <> ( packet.additional |> Enum.map(&PacketEncoder.to_bitstring/1) |> Enum.join("") ) end end def parse_header(packet) do case packet do << tid :: 16, response :: 1, opcode :: 4, authoritative :: 1, truncated :: 1, recursion_desired :: 1, recursion_available :: 1, z :: 1, answer_is_auth :: 1, non_auth_data_ok :: 1, response_code :: 4, n_queries :: 16, n_answers :: 16, n_nameservers :: 16, n_additional :: 16, rr_rest :: binary >> -> { :ok, {%{ tid: tid, response: int_bool(response), opcode: opcode, authoritative: int_bool(authoritative), truncated: int_bool(truncated), recursion_desired: int_bool(recursion_desired), recursion_available: int_bool(recursion_available), z: z, answer_is_auth: int_bool(answer_is_auth), non_auth_data_ok: int_bool(non_auth_data_ok), response_code: response_code, }, %{ n_queries: n_queries, n_answers: n_answers, n_nameservers: n_nameservers, n_additional: n_additional, }, rr_rest} } _ -> {:error, :malformed_dns_header} end end def parse_rrs(n, from_bitstring, packet, buffer, rrs \\ []) def parse_rrs(0, _from_bitstring, _packet, buffer, rrs) do {:ok, {rrs |> Enum.reverse, buffer}} end def parse_rrs(n, from_bitstring, packet, buffer, rrs) do # IO.inspect(buffer) with {:ok, {rr, buffer}} <- from_bitstring.(packet, buffer) do parse_rrs(n - 1, from_bitstring, packet, buffer, [rr] ++ rrs) end end @spec from_bitstring(binary) :: {:ok, DNS.Packet.t} def from_bitstring(packet) do with {:ok, {header, counts, rest}} <- parse_header(packet), {:ok, {questions, rest}} <- parse_rrs( counts.n_queries, &DNS.Query.from_bitstring/2, packet, rest ), {:ok, {answers, rest}} <- parse_rrs( counts.n_answers, &DNS.RR.from_bitstring/2, packet, rest ), {:ok, {nameservers, rest}} <- parse_rrs( counts.n_nameservers, &DNS.RR.from_bitstring/2, packet, rest ), {:ok, {additional, ""}} <- parse_rrs( counts.n_additional, &DNS.RR.from_bitstring/2, packet, rest ) do %DNS.Packet{} |> Map.merge(header) |> Map.merge( %{queries: questions, answers: answers, nameservers: nameservers, additional: additional} ) end end @doc """ What is the response code (as an atom) for this DNS packet? """ @spec response_code(map) :: :atom def response_code(%{response_code: code}) do case code do 0 -> :NOERROR 1 -> :FORMERR 2 -> :SERVFAIL 3 -> :NXDOMAIN 4 -> :NOTIMPL 5 -> :REFUSED 6 -> :YXDOMAIN 7 -> :YXRRSET 8 -> :NXRRSET 9 -> :NOTAUTH 10 -> :NOTZONE 16 -> :BADVERS_OR_BADSIG 17 -> :BADKEY 18 -> :BADTIME 19 -> :BADMODE 20 -> :BADNAME 21 -> :BADALG 22 -> :BADTRUNC _ -> :unhandled end end end
27.09816
88
0.530073
79d9609db8a7dcccab159305bd3b1896b00ff0bf
2,252
exs
Elixir
test/liblink/socket/recvmsg/init_state_test.exs
Xerpa/liblink
7b983431c5b391bb8cf182edd9ca4937601eea35
[ "Apache-2.0" ]
3
2018-10-26T12:55:15.000Z
2019-05-03T22:41:34.000Z
test/liblink/socket/recvmsg/init_state_test.exs
Xerpa/liblink
7b983431c5b391bb8cf182edd9ca4937601eea35
[ "Apache-2.0" ]
4
2018-08-26T14:43:57.000Z
2020-09-23T21:14:56.000Z
test/liblink/socket/recvmsg/init_state_test.exs
Xerpa/liblink
7b983431c5b391bb8cf182edd9ca4937601eea35
[ "Apache-2.0" ]
null
null
null
# Copyright 2018 (c) Xerpa # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. defmodule Liblink.Socket.Recvmsg.InitStateTest do use ExUnit.Case, async: true alias Liblink.Socket.Device alias Liblink.Socket.Recvmsg.Fsm alias Liblink.Socket.Recvmsg.RecvState alias Liblink.Socket.Recvmsg.InitState alias Liblink.Socket.Recvmsg.TermState @moduletag capture_log: true test "can halt" do {InitState, data} = Fsm.new() assert {:halt, :ok, {TermState, _}} = InitState.halt(data) end test "can attach" do {InitState, data} = Fsm.new() assert {:cont, :ok, {RecvState, n_data}} = InitState.attach(%Device{}, data) assert %Device{} == n_data.device end test "can't recvmsg" do {InitState, data} = Fsm.new() assert {:cont, {:error, :badstate}, {InitState, _}} = InitState.recvmsg(data) end test "can't poll" do {InitState, data} = Fsm.new() assert {:cont, {:error, :badstate}, {InitState, _}} = InitState.poll(self(), data) end test "can't halt_poll" do {InitState, data} = Fsm.new() assert {:cont, {:error, :badstate}, {InitState, _}} = InitState.halt_poll(:erlang.make_ref(), data) end test "can't consume" do {InitState, data} = Fsm.new() assert {:cont, {:error, :badstate}, {InitState, _}} = InitState.consume(self(), data) end test "can't receive messages" do {InitState, data} = Fsm.new() assert {:cont, {:error, :badstate}, {InitState, _}} = InitState.on_liblink_message([], data) end test "can't receive monitor messages" do {InitState, data} = Fsm.new() message = {:DOWN, :erlang.make_ref(), :process, self(), :normal} assert {:cont, :ok, {InitState, _}} = InitState.on_monitor_message(message, data) end end
28.871795
96
0.676732
79d990cabb60bfa31c9bf5ee593c7e6091533314
1,607
ex
Elixir
clients/area120_tables/lib/google_api/area120_tables/v1alpha1/model/batch_update_rows_response.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
clients/area120_tables/lib/google_api/area120_tables/v1alpha1/model/batch_update_rows_response.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
clients/area120_tables/lib/google_api/area120_tables/v1alpha1/model/batch_update_rows_response.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.Area120Tables.V1alpha1.Model.BatchUpdateRowsResponse do @moduledoc """ Response message for TablesService.BatchUpdateRows. ## Attributes * `rows` (*type:* `list(GoogleApi.Area120Tables.V1alpha1.Model.Row.t)`, *default:* `nil`) - The updated rows. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :rows => list(GoogleApi.Area120Tables.V1alpha1.Model.Row.t()) } field(:rows, as: GoogleApi.Area120Tables.V1alpha1.Model.Row, type: :list) end defimpl Poison.Decoder, for: GoogleApi.Area120Tables.V1alpha1.Model.BatchUpdateRowsResponse do def decode(value, options) do GoogleApi.Area120Tables.V1alpha1.Model.BatchUpdateRowsResponse.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Area120Tables.V1alpha1.Model.BatchUpdateRowsResponse do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
34.191489
113
0.756067
79da871b2d616ee54db64c46c91c58ec98b42fab
1,769
ex
Elixir
lib/wallet_ms/api_wallet/api_wallet.ex
Arqui2018/2F_wallet_ms
3b5cdb71f1590f7340460f13a086918448bc3fae
[ "MIT" ]
null
null
null
lib/wallet_ms/api_wallet/api_wallet.ex
Arqui2018/2F_wallet_ms
3b5cdb71f1590f7340460f13a086918448bc3fae
[ "MIT" ]
null
null
null
lib/wallet_ms/api_wallet/api_wallet.ex
Arqui2018/2F_wallet_ms
3b5cdb71f1590f7340460f13a086918448bc3fae
[ "MIT" ]
null
null
null
defmodule WalletMs.ApiWallet do @moduledoc """ The ApiWallet context. """ import Ecto.Query, warn: false alias WalletMs.Repo alias WalletMs.ApiWallet.Wallet @doc """ Returns the list of wallets. ## Examples iex> list_wallets() [%Wallet{}, ...] """ def list_wallets do Repo.all(Wallet) end @doc """ Gets a single wallet. Raises `Ecto.NoResultsError` if the Wallet does not exist. ## Examples iex> get_wallet!(123) %Wallet{} iex> get_wallet!(456) ** (Ecto.NoResultsError) """ def get_wallet!(id), do: Repo.get!(Wallet, id) @doc """ Creates a wallet. ## Examples iex> create_wallet(%{field: value}) {:ok, %Wallet{}} iex> create_wallet(%{field: bad_value}) {:error, %Ecto.Changeset{}} """ def create_wallet(attrs \\ %{}) do %Wallet{} |> Wallet.changeset(attrs) |> Repo.insert() end @doc """ Updates a wallet. ## Examples iex> update_wallet(wallet, %{field: new_value}) {:ok, %Wallet{}} iex> update_wallet(wallet, %{field: bad_value}) {:error, %Ecto.Changeset{}} """ def update_wallet(%Wallet{} = wallet, attrs) do wallet |> Wallet.changeset(attrs) |> Repo.update() end @doc """ Deletes a Wallet. ## Examples iex> delete_wallet(wallet) {:ok, %Wallet{}} iex> delete_wallet(wallet) {:error, %Ecto.Changeset{}} """ def delete_wallet(%Wallet{} = wallet) do Repo.delete(wallet) end @doc """ Returns an `%Ecto.Changeset{}` for tracking wallet changes. ## Examples iex> change_wallet(wallet) %Ecto.Changeset{source: %Wallet{}} """ def change_wallet(%Wallet{} = wallet) do Wallet.changeset(wallet, %{}) end end
16.847619
61
0.59186
79dab823ce8be68fa82b5d1d4becb3ab1befd847
1,070
ex
Elixir
apps/core/lib/core/legal_entities/related_legal_entity.ex
ehealth-ua/ehealth.api
4ffe26a464fe40c95fb841a4aa2e147068f65ca2
[ "Apache-2.0" ]
8
2019-06-14T11:34:49.000Z
2021-08-05T19:14:24.000Z
apps/core/lib/core/legal_entities/related_legal_entity.ex
edenlabllc/ehealth.api.public
4ffe26a464fe40c95fb841a4aa2e147068f65ca2
[ "Apache-2.0" ]
1
2019-07-08T15:20:22.000Z
2019-07-08T15:20:22.000Z
apps/core/lib/core/legal_entities/related_legal_entity.ex
ehealth-ua/ehealth.api
4ffe26a464fe40c95fb841a4aa2e147068f65ca2
[ "Apache-2.0" ]
6
2018-05-11T13:59:32.000Z
2022-01-19T20:15:22.000Z
defmodule Core.LegalEntities.RelatedLegalEntity do @moduledoc false use Ecto.Schema import Ecto.Changeset alias Core.LegalEntities.LegalEntity @derive {Jason.Encoder, except: [:__meta__]} @required_fields ~w(merged_from_id merged_to_id reason is_active inserted_by)a @optional_fields ~w(id)a @primary_key {:id, :binary_id, autogenerate: true} schema "related_legal_entities" do field(:reason, :string) field(:is_active, :boolean, default: false) field(:inserted_by, Ecto.UUID) belongs_to(:merged_from, LegalEntity, type: Ecto.UUID) belongs_to(:merged_to, LegalEntity, type: Ecto.UUID) timestamps(type: :utc_datetime_usec, updated_at: false) end def changeset(%__MODULE__{} = entity, attrs) do entity |> cast(attrs, @required_fields ++ @optional_fields) |> foreign_key_constraint(:merged_to_id) |> foreign_key_constraint(:merged_from_id) |> unique_constraint(:merged_to, name: :merged_ids_index, message: "related legal entity already created") |> validate_required(@required_fields) end end
31.470588
110
0.742991
79dad6843a63e6d1b17cd3c62f878cc39ef55046
232
exs
Elixir
config/test.exs
juanzapa/distributed-performance-analyzer
d5f0e8cd6051281d76413236076c45fbaf36b6ba
[ "MIT" ]
1
2020-06-07T01:35:24.000Z
2020-06-07T01:35:24.000Z
config/test.exs
juanzapa/distributed-performance-analyzer
d5f0e8cd6051281d76413236076c45fbaf36b6ba
[ "MIT" ]
null
null
null
config/test.exs
juanzapa/distributed-performance-analyzer
d5f0e8cd6051281d76413236076c45fbaf36b6ba
[ "MIT" ]
1
2020-02-20T14:19:05.000Z
2020-02-20T14:19:05.000Z
use Mix.Config config :perf_analizer, host: {:http, "127.0.0.1", 3000}, request: %{method: "GET", path: "/", headers: [], body: ""}, execution: %{steps: 0, increment: 1, duration: 10}, distributed: :none
33.142857
67
0.560345
79dadb7444504ebe37e68ac260bd4838f325c39c
6,345
ex
Elixir
lib/faktory_worker/worker.ex
vukanac/faktory_worker
d3905f4c63988f1374d18e747fdd364a0d1ddbf2
[ "MIT" ]
null
null
null
lib/faktory_worker/worker.ex
vukanac/faktory_worker
d3905f4c63988f1374d18e747fdd364a0d1ddbf2
[ "MIT" ]
null
null
null
lib/faktory_worker/worker.ex
vukanac/faktory_worker
d3905f4c63988f1374d18e747fdd364a0d1ddbf2
[ "MIT" ]
null
null
null
defmodule FaktoryWorker.Worker do @moduledoc false require Logger alias FaktoryWorker.ConnectionManager alias FaktoryWorker.Telemetry alias FaktoryWorker.ErrorFormatter alias FaktoryWorker.QueueManager @type t :: %__MODULE__{} @five_seconds 5_000 @faktory_default_reserve_for 1800 @default_delay 5_000 defstruct [ :conn_pid, :disable_fetch, :fetch_ref, :process_wid, :worker_state, :queues, :faktory_name, :job_ref, :job_id, :job, :job_timeout_ref, :retry_interval ] @spec new(opts :: keyword()) :: __MODULE__.t() def new(opts) do faktory_name = Keyword.get(opts, :faktory_name, FaktoryWorker) process_wid = Keyword.fetch!(opts, :process_wid) retry_interval = Keyword.get(opts, :retry_interval, @five_seconds) disable_fetch = Keyword.get(opts, :disable_fetch) # Delay connection startup to stagger worker connections. Without this # all workers try to connect at the same time and it can't handle the load delay_max = Application.get_env(:faktory_worker, :worker_startup_delay) || @default_delay Process.sleep(Enum.random(1..delay_max)) {:ok, conn_pid} = opts |> Keyword.get(:connection, []) |> Keyword.put(:is_worker, true) |> Keyword.put(:process_wid, process_wid) |> ConnectionManager.Server.start_link() %__MODULE__{ conn_pid: conn_pid, disable_fetch: disable_fetch, process_wid: process_wid, worker_state: :ok, faktory_name: faktory_name, retry_interval: retry_interval } |> schedule_fetch() end @spec send_fetch(state :: __MODULE__.t()) :: state :: __MODULE__.t() def send_fetch(%{worker_state: worker_state} = state) when worker_state == :ok do job_supervisor = job_supervisor_name(state) queues = checkout_queues(state) fetch_ref = Task.Supervisor.async_nolink( job_supervisor, fn -> send_command(state.conn_pid, {:fetch, queues}) end ) %{state | fetch_ref: fetch_ref, queues: queues} end def send_fetch(state), do: state @spec stop_job(state :: __MODULE__.t()) :: __MODULE__.t() def stop_job(%{job_ref: job_ref} = state) when job_ref != nil do state |> job_supervisor_name() |> Task.Supervisor.terminate_child(job_ref.pid) ack_job(state, {:error, "Job Timeout"}) end def stop_job(state), do: state @spec ack_job(state :: __MODULE__.t(), :ok | {:error, any()}) :: __MODULE__.t() def ack_job(state, :ok) do checkin_queues(state) state.conn_pid |> send_command({:ack, state.job_id}) |> handle_ack_response(:ok, state) end def ack_job(state, {:error, reason}) do checkin_queues(state) backtrace_length = Map.get(state.job, "backtrace", 30) error = ErrorFormatter.format_error(reason, backtrace_length) payload = %{ jid: state.job_id, errtype: error.type, message: error.message, backtrace: error.stacktrace } state.conn_pid |> send_command({:fail, payload}) |> handle_ack_response(:error, state) end def handle_fetch_response({:ok, job}, state) when is_map(job) do job_supervisor = job_supervisor_name(state) job_module = job["jobtype"] |> String.split(".") |> Enum.map(&String.to_atom/1) |> Module.safe_concat() job_ref = Task.Supervisor.async_nolink( job_supervisor, job_module, :perform, job["args"], shutdown: :brutal_kill ) reserve_for_seconds = Map.get(job, "reserve_for", @faktory_default_reserve_for) # set a timeout for the job process of the configured reserve_for # time minus 20 seconds to ensure the job is stopped before faktory # can expire and retry it on the server timeout_duration = (reserve_for_seconds - 20) * 1000 timeout_ref = Process.send_after(self(), :job_timeout, timeout_duration) %{ state | worker_state: :running_job, job_timeout_ref: timeout_ref, job_ref: job_ref, job_id: job["jid"], job: job } end def handle_fetch_response({:ok, _}, state), do: schedule_fetch(state) def handle_fetch_response({:error, reason}, state) do Telemetry.execute(:fetch, {:error, reason}, %{wid: state.process_wid}) Process.send_after(self(), :fetch, state.retry_interval) state end @spec checkin_queues(state :: __MODULE__.t()) :: :ok def checkin_queues(%{queues: nil}), do: :ok def checkin_queues(%{queues: queues} = state) do QueueManager.checkin_queues(queue_manager_name(state), queues) end defp schedule_fetch(%{disable_fetch: true} = state), do: state defp schedule_fetch(%{worker_state: worker_state} = state) when worker_state == :ok do Process.send_after(self(), :fetch, 50) state end defp handle_ack_response({:ok, _}, ack_type, state) do Telemetry.execute(:ack, ack_type, %{ jid: state.job_id, args: state.job["args"], jobtype: state.job["jobtype"] }) cancel_timer(state.job_timeout_ref) schedule_fetch(%{ state | worker_state: :ok, queues: nil, job_timeout_ref: nil, job_ref: nil, job_id: nil, job: nil }) end defp handle_ack_response({:error, _}, ack_type, state) do Telemetry.execute(:failed_ack, ack_type, %{ jid: state.job_id, args: state.job["args"], jobtype: state.job["jobtype"] }) cancel_timer(state.job_timeout_ref) schedule_fetch(%{ state | worker_state: :ok, queues: nil, job_timeout_ref: nil, job_ref: nil, job_id: nil, job: nil }) end defp checkout_queues(%{queues: nil} = state) do QueueManager.checkout_queues(queue_manager_name(state)) end defp checkout_queues(%{queues: queues}), do: queues defp job_supervisor_name(%{faktory_name: faktory_name}) do FaktoryWorker.JobSupervisor.format_supervisor_name(faktory_name) end defp queue_manager_name(%{faktory_name: faktory_name}) do QueueManager.format_queue_manager_name(faktory_name) end defp cancel_timer(nil), do: :ok defp cancel_timer(timer_ref) do Process.cancel_timer(timer_ref) end defp send_command(conn_pid, command) do ConnectionManager.Server.send_command(conn_pid, command) end end
26.219008
93
0.666194