Current section
Files
Jump to
Current section
Files
lib/bibbidi/commands/network/set_cache_behavior.ex
# Generated by mix bibbidi.gen — do not edit manually
defmodule Bibbidi.Commands.Network.SetCacheBehavior do
@moduledoc """
Command struct for `network.setCacheBehavior`.
[WebDriver BiDi Spec](https://w3c.github.io/webdriver-bidi/#command-network-setCacheBehavior)
## Fields
- `cache_behavior` - `"default"` or `"bypass"` (required)
- `contexts` - list of `t:Bibbidi.Types.BrowsingContext.t/0` (optional)
"""
@derive Bibbidi.Telemetry.Metadata
@schema Zoi.struct(__MODULE__, %{
cache_behavior: Zoi.union([Zoi.string(), Zoi.string()]),
contexts: Zoi.list(Bibbidi.Types.BrowsingContext.schema()) |> Zoi.optional(),
meta: Zoi.any() |> Zoi.optional()
})
@opts_schema Zoi.keyword(contexts: Zoi.list(Zoi.any()) |> Zoi.optional())
@result_schema Zoi.map(Zoi.string(), Zoi.any())
@type t :: unquote(Zoi.type_spec(@schema))
@type opts :: unquote(Zoi.type_spec(@opts_schema))
@type result :: unquote(Zoi.type_spec(@result_schema))
@enforce_keys Zoi.Struct.enforce_keys(@schema)
defstruct Zoi.Struct.struct_fields(@schema)
@doc "Returns the Zoi schema for this command struct."
def schema, do: @schema
@doc "Returns the Zoi schema for the keyword options."
def opts_schema, do: @opts_schema
@doc "Returns the Zoi schema for the result type."
def result_schema, do: @result_schema
defimpl Bibbidi.Encodable do
def method(_), do: "network.setCacheBehavior"
def params(cmd) do
optional = [
{:contexts, cmd.contexts}
]
Enum.reduce(optional, %{cacheBehavior: cmd.cache_behavior}, fn
{_key, nil}, acc -> acc
{key, value}, acc -> Map.put(acc, key, value)
end)
end
end
end