text:
# Algorithms that share some allocation-specific infrastructure based on
# mixed-integer programming using JuMP.

# A shared context for the MIP pipeline. The JuMP variable representing the
# allocation (as an n-by-m matrix) is kept in alloc_var. The res field should be
# a named tuple of any extra data to be splatted in at the end of the result.
mutable struct MIPContext{V <: Additive, M, A, S}
    profile::V
    alloc_var::A
    model::M
    solver::S
    alloc::Union{Allocation, Nothing}
    res::NamedTuple
end
MIPContext(v, a, m, s) = MIPContext(v, a, m, s, nothing, (;))

# Internal MIP-building functions

# The init_mip and solve_mip functions are used to set up a MIP based on a
# valuation profile, and then to solve the MIP and produce an Allocation. After
# this, a final stage (such as mnw_result) should be used, to wrap the
# allocation and any other result variables (such as the objective value) in a
# named tuple.
#
# The "enforce" functions add constraints to the MIP, while the "achieve"
# functions also modify the objective function. At most one "achieve" function
# should be used in a single pipeline; otherwise, the second one would
# overwrite the objective of the first one.

# Set up a MIPContext with based on an additive valuation profile. Initializes a
# JuMP model with constraints ensuring a valid allocation.
function init_mip(V::Additive, solver)

    model = Model(solver)

    N = agents(V)
    M = items(V)

    @variable(model, A[N, M], binary=true)

    for g in M
        # Each item allocated to at exactly one agent
        @constraint(model, sum(A[i, g] for i in N) == 1)
    end

    return MIPContext(V, A, model, solver)

end

# Shortcut, so you can use a matrix instead of an Additive valuation profile,
# including in the alloc_... functions that rely on init_mip.
init_mip(V::Matrix, solver) = init_mip(Additive(V), solver)

# Solves the MIP model and constructs the actual Allocation object in the
# MIPContext.
# ϵ: https://www.gurobi.com/documentation/9.1/refman/intfeastol.html
function solve_mip(ctx; ϵ=1e-5, check=check_partition)

    optimize!(ctx.model)

    @assert termination_status(ctx.model) in conf.MIP_SUCCESS

    V = ctx.profile
    ctx.alloc = Allocation(na(V), ni(V))

    for i in agents(V), g in items(V)
        val = JuMP.value(ctx.alloc_var[i, g])
        @assert val ≤ ϵ || val ≥ 1 - ϵ
        val ≥ 1.0 - ϵ && give!(ctx.alloc, i, g)
    end

    isnothing(check) || check(ctx.alloc)

    return ctx

end

## Objective-modifying pipeline steps (achieve_...)

# Set up objective and constraints to make sure the JuMP model produces an MNW
# allocation, using a slightly adapted version of the approach of Caragiannis
# et al. (https://doi.org/10.1145/3355902).
achieve_mnw(mnw_warn) = function(ctx)

    V, A, model = ctx.profile, ctx.alloc_var, ctx.model

    @assert isintegral(V)
    @assert isnonnegative(V)

    N = [i for (i, g) in bipartite_matching(matrix(V))]

    M = items(V)

    v_max = Float64(maximum(value(V, i, M) for i in N))

    mnw_prec = true

    for (k, name) in [1 => "PO", 2 => "EF1", length(N) => "MNW"]
        if log(v_max^k) - log(v_max^k - 1) == 0.0
            if name == "MNW"
                mnw_prec = false
                !mnw_warn && continue
            end
            @warn("Precision possibly insufficient to guarantee $name")
        end
    end

    ctx.res = (ctx.res..., mnw_prec = mnw_prec)

    @variable(model, W[N])

    @objective(model, Max, sum(W))

    A = ctx.alloc_var

    for i in N, k = 1:2:v_max
        @constraint(model, W[i] <=
                log(k) + (log(k + 1) - log(k)) *
                (sum(A[i, g] * value(V, i, g) for g = M) - k))
    end

    for i in N
        @constraint(model, sum(A[i, g] * value(V, i, g) for g in M) >= 1)
    end

    return ctx

end

# Set up objective and constraints to make sure the JuMP model produces an
# egalitarian/maximin allocation.
achieve_mm(cutoff=nothing) = function(ctx)

    V, A, model = ctx.profile, ctx.alloc_var, ctx.model

    N, M = agents(V), items(V)

    @variable(model, v_min)

    for i in N
        @constraint(model, v_min <= sum(A[i, g] * value(V, i, g) for g in M))
    end

    isnothing(cutoff) || @constraint(model, v_min <= cutoff)

    @objective(model, Max, v_min)

    return ctx

end

# Set up objective and constraints to make sure the JuMP model produces a
# minimum ordered weighted average, by utility rank, using wt as the weight
# function (cf., Lesca & Perny, 2010)
achieve_ggi(wt) = function(ctx)

    V, A, model = ctx.profile, ctx.alloc_var, ctx.model

    N, n, M = agents(V), na(V), items(V)

    @variable(model, r[N])
    @variable(model, b[N, N] >= 0)

    omega = [i == n ? wt(i, n) : wt(i, n) - wt(i + 1, n) for i in N]

    @objective(model, Max,
        sum(omega[j] * (j * r[j] - sum(b[i, j] for i in N)) for j in N))

    for i in N, j in N
        @constraint(model,
            r[j] - b[i, j] <= sum(A[i, g] * value(V, i, g) for g in M))
    end

    return ctx

end

## Objective-preserving pipeline steps (enforce_...)

# Enforce no constraints on the JuMP model.
enforce(C::Nothing) = identity

# Enforce cardinality constraints on the JuMP model.
enforce(C::Counts) = function(ctx)

    V, A, model = ctx.profile, ctx.alloc_var, ctx.model

    for S in C, i in agents(V)
        @constraint(model, sum(A[i, g] for g in S) <= S.threshold)
    end

    return ctx

end

# Enforce item conflict constraints on the JuMP model.
enforce(C::Conflicts) = function(ctx)

    V, A, model = ctx.profile, ctx.alloc_var, ctx.model

    G = graph(C)

    @assert nv(G) == ni(V)

    for e in edges(G)
        g, h = src(e), dst(e)
        for i in agents(V)
            @constraint(model, A[i, g] + A[i, h] <= 1)
        end
    end

    return ctx

end

# Enforce envy-freeness up to a single object (EF1) on the JuMP model.
function enforce_ef1(ctx)

    V, A, model = ctx.profile, ctx.alloc_var, ctx.model

    N, M = agents(V), items(V)

    # D[i, j, g]: Item g dropped for i to not envy j
    @variable(model, D[N, N, M], binary=true)

    for i in N, j in N

        # Drop at most one item for envy-freeness
        @constraint(model, sum(D[i, j, g] for g in M) <= 1)

        for g in M
            # Drop only items allocated to j to make i not envy j
            @constraint(model, D[i, j, g] <= A[j, g])
        end

    end

    for i in N, j in N

        i == j && continue

        # Agent i's value for her own bundle
        vii = sum(value(V, i, g) * A[i, g] for g in M)

        # Agent i's value for j's bundle, without dropped item
        vij1 = sum(value(V, i, g) * (A[j, g] - D[i, j, g]) for g in M)

        # No envy, once an item is (possibly) dropped:
        @constraint(model, vii >= vij1)

    end

    return ctx

end

# Enforce envy-freeness up to any object (EFX) on the JuMP model.
function enforce_efx(ctx)

    V, A, model = ctx.profile, ctx.alloc_var, ctx.model

    N, M = agents(V), items(V)

    for i in N, j in N

        i == j && continue

        # Agent i's value for her own bundle
        vii = sum(value(V, i, g) * A[i, g] for g in M)

        # Value large enough to skip the constraint:
        huge = value(V, i, M)

        # For each possibly dropped item d ...
        for d in M

            # Agent i's value for j's bundle, without d
            vijx = sum(value(V, i, g) * A[j, g] for g in M if g ≠ d)

            # If d isn't allocated to j, we skip this constraint:
            skip = huge * (1 - A[j, d])

            # No envy, once d is dropped (or if d isn't assigned to j):
            @constraint(model, vii + skip >= vijx)

        end

    end

    return ctx

end

# Actual allocation methods

# Generic function to extract the allocation at the end of the pipeline. Many
# allocation methods may want their own `..._result` functions, adding other
# fields to the named tuple being returned.
alloc_result(ctx) = (alloc=ctx.alloc, model=ctx.model, ctx.res...)

"""
    alloc_ef1(V, C; solver=conf.MIP_SOLVER)

Create an `Allocation` that is envy-free up to one item (EF1), based on the
valuation profile `V`, possibly subject to the constraints given by the
`Constraint` object `C`. The solution is found using a straightforward
mixed-integer program, and is most suitable for constraints where no specialized
algorithm exists. For example, without constraints, a straightforward round
robin picking sequence yields EF1, and a similar strategy works for cardinality
constraints. (It is still possible to use this function without constraints, by
explicitly supplying `nothing` for the constraint argument `C`.) The return
value is a named tuple with the fields `alloc` (the `Allocation`) and `model`
(the JuMP model used in the computation).

Note that for some constraints, there may not *be* an EF1 allocation, in which
case the function will fail with an exception.
"""
function alloc_ef1(V, C; solver=conf.MIP_SOLVER)

    init_mip(V, solver) |>
    enforce_ef1 |>
    enforce(C) |>
    solve_mip |>
    alloc_result

end

"""
    alloc_efx(V[, C]; solver=conf.MIP_SOLVER)

Create an `Allocation` that is envy-free up to any item (EFX), based on the
valuation profile `V`, possibly subject to the constraints given by the
`Constraint` object `C`. The solution is found using a straightforward
mixed-integer program. The return value is a named tuple with the fields `alloc`
(the `Allocation`) and `model` (the JuMP model used in the computation).

Note that while some constraints may prevent an exact EFX allocation, it is
currently (Mar 2021) an open question whether EFX always exists in the
unconstrained case (see, e.g., [*Improving EFX Guarantees through Rainbow Cycle
Number*](https://arxiv.org/abs/2103.01628) by Chaudhury et al.).
"""
function alloc_efx(V, C=nothing; solver=conf.MIP_SOLVER)

    init_mip(V, solver) |>
    enforce_efx |>
    enforce(C) |>
    solve_mip |>
    alloc_result

end

# Extract the allocation and the MNW value (excluding agents with a utility of
# zero) at the end of the pipeline. Strictly speaking, we needn't include the
# mnw field here, as it's a separate calculations; however, it's convenient if
# you supply a matrix as the argument for alloc_mnw function, since we have
# access to the valuation profile here. (Also, the cost of nash_welfare will
# generally be very low, compared to the actual MIP solving.)
function mnw_result(ctx)
    V, A = ctx.profile, ctx.alloc
    return (alloc=A, model=ctx.model, mnw=nash_welfare(V, A), ctx.res...)
end

"""
    alloc_mnw(V[, C]; mnw_warn=false, solver=conf.MIP_SOLVER)

Create an `Allocation` attaining maximum Nash welfare (MNW), based on the
valuation profile `V`, possibly subject to the constraints given by the
`Constraint` object `C`. The solution is found using the approach of Caragiannis
et al. in their 2019 paper [The Unreasonable Fairness of Maximum Nash
Welfare](https://doi.org/10.1145/3355902), with two minor modifications:

1. Rather than hard-coding a maximum valuation (arising from the assumption that
   the values of each agent sum to 1000), this maximum is extracted from `V`;
   and

2. Extra constraints are permitted (through the object `C`), possibly lowering
   the attainable MNW.

Because of how the integer program is constructed, it may be affected by
precision effects, where a high number of agents can make it impossible to
guarantee Pareto optimalty (PO), EF1 or MNW. If the precision is too low, the
appropriate warning will be issued, but the computation is not halted. Note that
these warnings are quite conservative (see note below). This is particularly
true of the one for MNW, which is disabled by default, in part because of its
sensitivity, and in part because it will generally be useful to find solutions
that satisfy PO and EF1, even if it may not be exactly MNW. The MNW warning can
be enabled by setting the `mnw_warn` keyword to `true`.

!!! note

    The warnings are based on the lower bounds described by Caragiannis et al.
    On the one hand, the bound is only used to test whether current
    floating-point precision is sufficient; any tolerance or gap used by the
    solver is not used, which might in principle mean that false negative are
    possible. On the other hand, these bounds, especially the one for exact MNW,
    may in practice be quite loose, with small variations in agent utilities
    leading to large changes in objective value, unless the changes are finely
    tuned to cancel out.

The return value is a named tuple with fields `alloc` (the `Allocation`),
`mnw` (the achieved Nash welfare for the agents with nonzero utility),
`mnw_prec` (whether or not there was enough precision to satisfy the lower bound
guaranteeing exact MNW) and `model` (the JuMP model used in the computation).
"""
function alloc_mnw(V, C=nothing; mnw_warn=false, solver=conf.MIP_SOLVER)

    init_mip(V, solver) |>
    achieve_mnw(mnw_warn) |>
    enforce(C) |>
    solve_mip |>
    mnw_result

end

"""
    alloc_mnw_ef1(V, C; mnw_warn=true, solver=conf.MIP_SOLVER)

Equivalent to `alloc_mnw`, except that EF1 is enforced. Without any added
constraints, MNW implies EF1, so this function is not needed in that case.
Therefore the argument `C` is not optional.
"""
function alloc_mnw_ef1(V, C; mnw_warn=true, solver=conf.MIP_SOLVER)

    init_mip(V, solver) |>
    achieve_mnw(mnw_warn) |>
    enforce_ef1 |>
    enforce(C) |>
    solve_mip |>
    mnw_result

end

# Extract the allocation and the maximin value at the end of the pipeline.
function mm_result(ctx)
    return (alloc=ctx.alloc,
            model=ctx.model,
            mm=objective_value(ctx.model),
            ctx.res...)
end

"""
    alloc_mm(V[, C]; cutoff=nothing, solver=conf.MIP_SOLVER)

Create an egalitarion or maximin `Allocation`, i.e., one where the minimum
bundle value is maximized. The `cutoff`, if any, is a level at which we are
satisfied, i.e., any allocation where all agents attain this value is
acceptable. The return value is a named tuple with fields `alloc` (the
`Allocation`), `mm` (the lowest agent utility) and `model` (the JuMP model
used in the computation).
"""
function alloc_mm(V, C=nothing; cutoff=nothing, solver=conf.MIP_SOLVER)

    init_mip(V, solver) |>
    achieve_mm(cutoff) |>
    enforce(C) |>
    solve_mip |>
    mm_result

end

"""
    mms(V, i[, C]; solver=conf.MIP_SOLVER)

Determine the maximin share of agent `i`, i.e., the bundle value she is
guaranteed to attain if she partitions the items and the other agents choose
their bundles. Useful, e.g., as a point of reference when determining the
empirical approximation ratios of approximate MMS allocation algorithms. Also
used as a subroutine in `alloc_mms`. The return value is a named tuple with the
fields `mms` (the maximin share of agent `i`) and `model` (the JuMP model used
in the computation).
"""
function mms(V::Additive, i, C=nothing; solver=conf.MIP_SOLVER)

    # Let all agents be clones of agent i
    Vi = Additive([value(V, i, g) for _ in agents(V), g in items(V)])

    # maximin in this scenario is MMS for agent i
    res = alloc_mm(Vi, C, solver=solver)

    return (mms=res.mm, model=res.model)

end

"""
    mms_alpha(V, A, mmss)

Utility function to find the fraction of the maximin share guarantee attained by
the allocation `A`, under the valuation profile `V`, where `mmss[i]` is the MMS
of agent `i`. This makes it possible, for example, to use the `mmss` field from
the result of `alloc_mms` to find the MMS approximation provided by an
allocation constructed by other means. For example:

    mmss = alloc_mms(V).mmss
    A = alloc_rand(V).alloc
    alpha = mms_alpha(V, A, mmss)

"""
function mms_alpha(V, A, mmss)
    vals = [value(V, i, A) for i in agents(A)]
    return minimum(vals ./ mmss)
end

"""
    alloc_mms(V[, C]; cutoff=false, solver=conf.MIP_SOLVER)

Find an MMS allocation, i.e., one that satisfies the *maximin share
guarantee*, where each agent gets a bundle it weakly prefers to its maximin
share (introduced by Budish, in his 2011 paper [The Combinatorial Assignment
Problem: Approximate Competitive Equilibrium from Equal
Incomes](https://doi.org/10.1086/664613)). The return value is a named tuple
with fields `alloc` (the `Allocation`), `mmss`, the individual MMS values for
the instance, `alpha`, the lowest fraction of MMS that any agent achieves
(is at least 1 exactly when the allocation is MMS), `model` (the JuMP model used
in computing `alpha`) and `mms_models` (the JuMP models used to compute the
individual maximin shares). If `cutoff` is set to `true`, this fraction is
capped at 1.
"""
function alloc_mms(V::Additive, C=nothing; cutoff=false, solver=conf.MIP_SOLVER)

    N, M = agents(V), items(V)

    X = zeros(na(V), ni(V))

    ress = [mms(V, i, C, solver=solver) for i in N]

    # individual MMS values -- also included in the result
    mmss = [res.mms for res in ress]

    mms_models = [res.model for res in ress]

    for i in N

        for g in M
            X[i, g] = value(V, i, g) / mmss[i]
        end

    end

    max_alpha = cutoff ? 1.0 : nothing

    # maximin with scaled values is as close to the MMS guarantee as possible
    res = alloc_mm(Additive(X), C, cutoff=max_alpha, solver=solver)

    return (alloc=res.alloc, model=res.model, mms_models=mms_models,
            alpha=res.mm, mmss=mmss)

end

alloc_mms(V::Matrix, C=nothing; cutoff=false, solver=conf.MIP_SOLVER) =
    alloc_mms(Additive(V), C, cutoff=cutoff, solver=solver)

# Extract the allocation at the end of the pipeline.
function ggi_result(ctx)
    return (alloc=ctx.alloc, model=ctx.model, ctx.res...)
end

"""
    wt_gini(i, n)

The (unnormalized) weights used in the ordered weighted average in the Gini
social-evaluation function, where the utility of the `i`th agent, ordered by
increasing utility, is given weight ``2(n - i) + 1``. (The normalized weights
yielding the original Gini social-evaluation function are divided by ``n^2``,
but this makes no difference to the optimization problem.)
"""
wt_gini(i, n) = 2(n - i) + 1

"""
    alloc_ggi(V[, C]; wt=wt_gini, solver=conf.MIP_SOLVER)

Maximizes a generalized Gini index (GGI), also known as a generalized Gini
social-evaluation functions. The function being maximized is an ordered weighted
average (OWA) of agent utilities, utilities, where the weight is based on
utility rank `i`, from the least happy (`1`) to the most happy (`n`),
parameterized by the function `wt(i, n)`. It is generally assumed that the
weights are nondecreasing in `i`. Note that there is no need to use normalized
weights (i.e., to produce a weighted average, despite the term OWA), as is often
the case when such measures are used to measure *in*equality (e.g., by
subtracting the OWA from an ordinary average, cf. [“Generalized gini inequality
indices”](https://doi.org/10.1016/0165-4896(81)90018-4) by John A. Weymark).

The default `wt_gini` gives the (non-normalized) weights of the original Gini
social-evaluation. Two other notable cases for `wt` are `(i, _) -> i == 1`,
which yields a maximin allocation, and `(i, _) -> 1`, which yields a purely
utilitarian allocation (with no consideration for fairness). The solution method
used is based on that of Lesca and Perny (linear formulation ``\\Pi'_W``,
without ``\\alpha``, ``\\alpha'``, ``\\beta`` and ``\\beta'``) in their paper
2010 paper [“LP Solvable Models for Multiagent Fair Allocation
Problems”](https://doi.org/10.3233/978-1-60750-606-5-393). The return value is a
named tuple with the fields `alloc` (the `Allocation` that has been produced)
and `model` (the JuMP model used in the computation).

In the original inequality measures, the mean agent utility is included as a
normalizing term, which is harmless for the case of identical valuations
functions (and when looking at, say, the distribution of incomes), but when
valuations differ, this mean will vary with the allocations. As pointed out by
Lesca and Perny, such a measure is not monotone with Pareto dominance -- the
optimization will tend to drive the mean utility *down*. Therefore only the term
measuring (in)equality (i.e., the ordered weighted sum of agent utilities) is
used.
"""
function alloc_ggi(V, C=nothing; wt=wt_gini, solver=conf.MIP_SOLVER)

    init_mip(V, solver) |>
    achieve_ggi(wt) |>
    enforce(C) |>
    solve_mip |>
    ggi_result

end


text:
using DiffEqBase, OrdinaryDiffEq, Sundials, ApproxFun
using Base.Test

S=Fourier()
u0=Fun(θ->cos(cos(θ-0.1)),S)
c=Fun(cos,S)

prob = SpectralTimeSteppingProblem((t,u)->u''+(c+1)*u',u0,(0.,1.))
@time u=solve(prob,Tsit5());
@time u=solve(prob,CVODE_BDF());
@time u=solve(prob,ode45());
@time u=solve(prob,radau());

ext: jl


text:
using Test
using Blink
using WebIO

if !(@isdefined DummyConnection)
    include("./test-utils.jl")
end

w = open_window()

@testset "RPCs work as expected" begin
    x = Ref{Any}(nothing)
    setx(newx) = x[] = newx

    onclick = js"""
    async function() {
        await $setx("foo");
    }
    """
    body!(w, dom"button#mybutton"(events=Dict("click" => onclick)))
    sleep(0.5)

    @js w document.getElementById("mybutton").click()
    sleep(0.1)

    @test x[] == "foo"
end

w = Window(Dict(:show => true))
opentools(w)
@testset "RPCs throw if Julia throws" begin
    @testset "Raised errors are propagated." begin
        wascalled = Ref(false)
        @js w window.lastException = nothing

        function throwjuliaerror(x)
            wascalled[] = true
            error(x)
        end

        onclick = js"""
        async function() {
            try {
                await $throwjuliaerror("this is my error");
            } catch (e) {
                window.lastException = e.message;
            }
        }
        """
        body!(w, dom"button#mybutton"(events=Dict("click" => onclick)))
        sleep(0.5)
        @js w document.getElementById("mybutton").click()
        sleep(0.5)
        @test wascalled[]
        @test occursin("this is my error", @js w window.lastException)
    end

    @testset "Invalid method invocations raise errors" begin
        wascalled = Ref(false)
        @js w window.lastException = nothing
        function takes3args(x, y, z)
            wascalled[] = true
            return x + y + z
        end
        onclick = js"""
        async function() {
            try {
                await $takes3args(1, 2);
            } catch (e) {
                window.lastException = e.message;
            }
        }
        """
        body!(w, dom"button#mybutton"(events=Dict("click" => onclick)))
        sleep(0.5)
        @js w document.getElementById("mybutton").click()
        sleep(0.5)
        # Should not have actually been invoked at all.
        @test wascalled[] == false
        @test occursin("no method matching", @js w window.lastException)
    end
end

@testset "RPC Request Handler" begin
    c = DummyConnection()
    # Force the split function to be inserted into the RPC map.
    js"$split"

    WebIO.dispatch(c, Dict(
        "type" => "request",
        "request" => "rpc",
        "requestId" => "foo",
        "rpcId" => string(hash(split)),
        "arguments" => ["foo bar"],
    ))
    r = take!(c)
    @test r["requestId"] == "foo"
    @test !haskey(r, "exception")
    @test r["result"] == ["foo", "bar"]

    WebIO.dispatch(c, Dict(
        "type" => "request",
        "request" => "rpc",
        "requestId" => "bar",
        "rpcId" => string(hash(split)),
        "arguments" => [123],
    ))
    r = take!(c)
    @test r["requestId"] == "bar"
    @test haskey(r, "exception")
    @test occursin("no method matching", r["exception"])
    @test !haskey(r, "result")

    WebIO.dispatch(c, Dict(
        "type" => "request",
        "request" => "rpc",
        "requestId" => "bar",
        "rpcId" => string(hash(split)),
        "arguments" => [123],
    ))
    r = take!(c)
    @test r["requestId"] == "bar"
    @test haskey(r, "exception")
    @test occursin("no method matching", r["exception"])
    @test !haskey(r, "result")

    @testset "Exception is returned when using unknown RPC" begin
    # unknown rpc
        WebIO.dispatch(c, Dict(
            "type" => "request",
            "request" => "rpc",
            "requestId" => "bar",
            "rpcId" => "1234",
            "arguments" => [123],
        ))
        r = take!(c)
        @test r["requestId"] == "bar"
        @test haskey(r, "exception")
        @test occursin("unknown rpc", r["exception"])
        @test !haskey(r, "result")
    end
end


text:
# This file was generated by the Julia Swagger Code Generator
# Do not modify this file directly. Modify the swagger specification instead.

struct StorageV1beta1Api <: SwaggerApi
    client::Swagger.Client
end

"""

create a CSIDriver
Param: body::IoK8sApiStorageV1beta1CSIDriver (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiStorageV1beta1CSIDriver
"""
function createStorageV1beta1CSIDriver(_api::StorageV1beta1Api, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "POST", IoK8sApiStorageV1beta1CSIDriver, "/apis/storage.k8s.io/v1beta1/csidrivers", ["BearerToken"], body)
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

create a CSINode
Param: body::IoK8sApiStorageV1beta1CSINode (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiStorageV1beta1CSINode
"""
function createStorageV1beta1CSINode(_api::StorageV1beta1Api, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "POST", IoK8sApiStorageV1beta1CSINode, "/apis/storage.k8s.io/v1beta1/csinodes", ["BearerToken"], body)
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

create a StorageClass
Param: body::IoK8sApiStorageV1beta1StorageClass (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiStorageV1beta1StorageClass
"""
function createStorageV1beta1StorageClass(_api::StorageV1beta1Api, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "POST", IoK8sApiStorageV1beta1StorageClass, "/apis/storage.k8s.io/v1beta1/storageclasses", ["BearerToken"], body)
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

create a VolumeAttachment
Param: body::IoK8sApiStorageV1beta1VolumeAttachment (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiStorageV1beta1VolumeAttachment
"""
function createStorageV1beta1VolumeAttachment(_api::StorageV1beta1Api, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "POST", IoK8sApiStorageV1beta1VolumeAttachment, "/apis/storage.k8s.io/v1beta1/volumeattachments", ["BearerToken"], body)
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

delete a CSIDriver
Param: name::String (required)
Param: pretty::String
Param: body::IoK8sApimachineryPkgApisMetaV1DeleteOptions
Param: dryRun::String
Param: gracePeriodSeconds::Int32
Param: orphanDependents::Bool
Param: propagationPolicy::String
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteStorageV1beta1CSIDriver(_api::StorageV1beta1Api, name::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/storage.k8s.io/v1beta1/csidrivers/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "gracePeriodSeconds", gracePeriodSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "orphanDependents", orphanDependents)  # type Bool
    Swagger.set_param(_ctx.query, "propagationPolicy", propagationPolicy)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

delete a CSINode
Param: name::String (required)
Param: pretty::String
Param: body::IoK8sApimachineryPkgApisMetaV1DeleteOptions
Param: dryRun::String
Param: gracePeriodSeconds::Int32
Param: orphanDependents::Bool
Param: propagationPolicy::String
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteStorageV1beta1CSINode(_api::StorageV1beta1Api, name::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/storage.k8s.io/v1beta1/csinodes/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "gracePeriodSeconds", gracePeriodSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "orphanDependents", orphanDependents)  # type Bool
    Swagger.set_param(_ctx.query, "propagationPolicy", propagationPolicy)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

delete collection of CSIDriver
Param: pretty::String
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteStorageV1beta1CollectionCSIDriver(_api::StorageV1beta1Api; pretty=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/storage.k8s.io/v1beta1/csidrivers", ["BearerToken"])
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

delete collection of CSINode
Param: pretty::String
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteStorageV1beta1CollectionCSINode(_api::StorageV1beta1Api; pretty=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/storage.k8s.io/v1beta1/csinodes", ["BearerToken"])
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

delete collection of StorageClass
Param: pretty::String
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteStorageV1beta1CollectionStorageClass(_api::StorageV1beta1Api; pretty=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/storage.k8s.io/v1beta1/storageclasses", ["BearerToken"])
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

delete collection of VolumeAttachment
Param: pretty::String
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteStorageV1beta1CollectionVolumeAttachment(_api::StorageV1beta1Api; pretty=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/storage.k8s.io/v1beta1/volumeattachments", ["BearerToken"])
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

delete a StorageClass
Param: name::String (required)
Param: pretty::String
Param: body::IoK8sApimachineryPkgApisMetaV1DeleteOptions
Param: dryRun::String
Param: gracePeriodSeconds::Int32
Param: orphanDependents::Bool
Param: propagationPolicy::String
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteStorageV1beta1StorageClass(_api::StorageV1beta1Api, name::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/storage.k8s.io/v1beta1/storageclasses/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "gracePeriodSeconds", gracePeriodSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "orphanDependents", orphanDependents)  # type Bool
    Swagger.set_param(_ctx.query, "propagationPolicy", propagationPolicy)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

delete a VolumeAttachment
Param: name::String (required)
Param: pretty::String
Param: body::IoK8sApimachineryPkgApisMetaV1DeleteOptions
Param: dryRun::String
Param: gracePeriodSeconds::Int32
Param: orphanDependents::Bool
Param: propagationPolicy::String
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteStorageV1beta1VolumeAttachment(_api::StorageV1beta1Api, name::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/storage.k8s.io/v1beta1/volumeattachments/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "gracePeriodSeconds", gracePeriodSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "orphanDependents", orphanDependents)  # type Bool
    Swagger.set_param(_ctx.query, "propagationPolicy", propagationPolicy)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

get available resources
Return: IoK8sApimachineryPkgApisMetaV1APIResourceList
"""
function getStorageV1beta1APIResources(_api::StorageV1beta1Api; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1APIResourceList, "/apis/storage.k8s.io/v1beta1/", ["BearerToken"])
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

list or watch objects of kind CSIDriver
Param: pretty::String
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApiStorageV1beta1CSIDriverList
"""
function listStorageV1beta1CSIDriver(_api::StorageV1beta1Api; pretty=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiStorageV1beta1CSIDriverList, "/apis/storage.k8s.io/v1beta1/csidrivers", ["BearerToken"])
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

list or watch objects of kind CSINode
Param: pretty::String
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApiStorageV1beta1CSINodeList
"""
function listStorageV1beta1CSINode(_api::StorageV1beta1Api; pretty=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiStorageV1beta1CSINodeList, "/apis/storage.k8s.io/v1beta1/csinodes", ["BearerToken"])
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

list or watch objects of kind StorageClass
Param: pretty::String
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApiStorageV1beta1StorageClassList
"""
function listStorageV1beta1StorageClass(_api::StorageV1beta1Api; pretty=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiStorageV1beta1StorageClassList, "/apis/storage.k8s.io/v1beta1/storageclasses", ["BearerToken"])
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

list or watch objects of kind VolumeAttachment
Param: pretty::String
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApiStorageV1beta1VolumeAttachmentList
"""
function listStorageV1beta1VolumeAttachment(_api::StorageV1beta1Api; pretty=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiStorageV1beta1VolumeAttachmentList, "/apis/storage.k8s.io/v1beta1/volumeattachments", ["BearerToken"])
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

partially update the specified CSIDriver
Param: name::String (required)
Param: body::IoK8sApimachineryPkgApisMetaV1Patch (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Param: force::Bool
Return: IoK8sApiStorageV1beta1CSIDriver
"""
function patchStorageV1beta1CSIDriver(_api::StorageV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PATCH", IoK8sApiStorageV1beta1CSIDriver, "/apis/storage.k8s.io/v1beta1/csidrivers/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_param(_ctx.query, "force", force)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json-patch+json", "application/merge-patch+json", "application/strategic-merge-patch+json"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

partially update the specified CSINode
Param: name::String (required)
Param: body::IoK8sApimachineryPkgApisMetaV1Patch (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Param: force::Bool
Return: IoK8sApiStorageV1beta1CSINode
"""
function patchStorageV1beta1CSINode(_api::StorageV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PATCH", IoK8sApiStorageV1beta1CSINode, "/apis/storage.k8s.io/v1beta1/csinodes/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_param(_ctx.query, "force", force)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json-patch+json", "application/merge-patch+json", "application/strategic-merge-patch+json"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

partially update the specified StorageClass
Param: name::String (required)
Param: body::IoK8sApimachineryPkgApisMetaV1Patch (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Param: force::Bool
Return: IoK8sApiStorageV1beta1StorageClass
"""
function patchStorageV1beta1StorageClass(_api::StorageV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PATCH", IoK8sApiStorageV1beta1StorageClass, "/apis/storage.k8s.io/v1beta1/storageclasses/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_param(_ctx.query, "force", force)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json-patch+json", "application/merge-patch+json", "application/strategic-merge-patch+json"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

partially update the specified VolumeAttachment
Param: name::String (required)
Param: body::IoK8sApimachineryPkgApisMetaV1Patch (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Param: force::Bool
Return: IoK8sApiStorageV1beta1VolumeAttachment
"""
function patchStorageV1beta1VolumeAttachment(_api::StorageV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PATCH", IoK8sApiStorageV1beta1VolumeAttachment, "/apis/storage.k8s.io/v1beta1/volumeattachments/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_param(_ctx.query, "force", force)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json-patch+json", "application/merge-patch+json", "application/strategic-merge-patch+json"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

read the specified CSIDriver
Param: name::String (required)
Param: pretty::String
Param: exact::Bool
Param: __export__::Bool
Return: IoK8sApiStorageV1beta1CSIDriver
"""
function readStorageV1beta1CSIDriver(_api::StorageV1beta1Api, name::String; pretty=nothing, exact=nothing, __export__=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiStorageV1beta1CSIDriver, "/apis/storage.k8s.io/v1beta1/csidrivers/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "exact", exact)  # type Bool
    Swagger.set_param(_ctx.query, "export", __export__)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

read the specified CSINode
Param: name::String (required)
Param: pretty::String
Param: exact::Bool
Param: __export__::Bool
Return: IoK8sApiStorageV1beta1CSINode
"""
function readStorageV1beta1CSINode(_api::StorageV1beta1Api, name::String; pretty=nothing, exact=nothing, __export__=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiStorageV1beta1CSINode, "/apis/storage.k8s.io/v1beta1/csinodes/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "exact", exact)  # type Bool
    Swagger.set_param(_ctx.query, "export", __export__)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

read the specified StorageClass
Param: name::String (required)
Param: pretty::String
Param: exact::Bool
Param: __export__::Bool
Return: IoK8sApiStorageV1beta1StorageClass
"""
function readStorageV1beta1StorageClass(_api::StorageV1beta1Api, name::String; pretty=nothing, exact=nothing, __export__=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiStorageV1beta1StorageClass, "/apis/storage.k8s.io/v1beta1/storageclasses/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "exact", exact)  # type Bool
    Swagger.set_param(_ctx.query, "export", __export__)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

read the specified VolumeAttachment
Param: name::String (required)
Param: pretty::String
Param: exact::Bool
Param: __export__::Bool
Return: IoK8sApiStorageV1beta1VolumeAttachment
"""
function readStorageV1beta1VolumeAttachment(_api::StorageV1beta1Api, name::String; pretty=nothing, exact=nothing, __export__=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiStorageV1beta1VolumeAttachment, "/apis/storage.k8s.io/v1beta1/volumeattachments/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "exact", exact)  # type Bool
    Swagger.set_param(_ctx.query, "export", __export__)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

replace the specified CSIDriver
Param: name::String (required)
Param: body::IoK8sApiStorageV1beta1CSIDriver (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiStorageV1beta1CSIDriver
"""
function replaceStorageV1beta1CSIDriver(_api::StorageV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", IoK8sApiStorageV1beta1CSIDriver, "/apis/storage.k8s.io/v1beta1/csidrivers/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

replace the specified CSINode
Param: name::String (required)
Param: body::IoK8sApiStorageV1beta1CSINode (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiStorageV1beta1CSINode
"""
function replaceStorageV1beta1CSINode(_api::StorageV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", IoK8sApiStorageV1beta1CSINode, "/apis/storage.k8s.io/v1beta1/csinodes/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

replace the specified StorageClass
Param: name::String (required)
Param: body::IoK8sApiStorageV1beta1StorageClass (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiStorageV1beta1StorageClass
"""
function replaceStorageV1beta1StorageClass(_api::StorageV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", IoK8sApiStorageV1beta1StorageClass, "/apis/storage.k8s.io/v1beta1/storageclasses/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

replace the specified VolumeAttachment
Param: name::String (required)
Param: body::IoK8sApiStorageV1beta1VolumeAttachment (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiStorageV1beta1VolumeAttachment
"""
function replaceStorageV1beta1VolumeAttachment(_api::StorageV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", IoK8sApiStorageV1beta1VolumeAttachment, "/apis/storage.k8s.io/v1beta1/volumeattachments/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "dryRun", dryRun)  # type String
    Swagger.set_param(_ctx.query, "fieldManager", fieldManager)  # type String
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

watch changes to an object of kind CSIDriver. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.
Param: name::String (required)
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: pretty::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1WatchEvent
"""
function watchStorageV1beta1CSIDriver(_api::StorageV1beta1Api, name::String; __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1WatchEvent, "/apis/storage.k8s.io/v1beta1/watch/csidrivers/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

watch individual changes to a list of CSIDriver. deprecated: use the 'watch' parameter with a list operation instead.
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: pretty::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1WatchEvent
"""
function watchStorageV1beta1CSIDriverList(_api::StorageV1beta1Api; __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1WatchEvent, "/apis/storage.k8s.io/v1beta1/watch/csidrivers", ["BearerToken"])
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

watch changes to an object of kind CSINode. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.
Param: name::String (required)
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: pretty::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1WatchEvent
"""
function watchStorageV1beta1CSINode(_api::StorageV1beta1Api, name::String; __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1WatchEvent, "/apis/storage.k8s.io/v1beta1/watch/csinodes/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

watch individual changes to a list of CSINode. deprecated: use the 'watch' parameter with a list operation instead.
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: pretty::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1WatchEvent
"""
function watchStorageV1beta1CSINodeList(_api::StorageV1beta1Api; __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1WatchEvent, "/apis/storage.k8s.io/v1beta1/watch/csinodes", ["BearerToken"])
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

watch changes to an object of kind StorageClass. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.
Param: name::String (required)
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: pretty::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1WatchEvent
"""
function watchStorageV1beta1StorageClass(_api::StorageV1beta1Api, name::String; __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1WatchEvent, "/apis/storage.k8s.io/v1beta1/watch/storageclasses/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

watch individual changes to a list of StorageClass. deprecated: use the 'watch' parameter with a list operation instead.
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: pretty::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1WatchEvent
"""
function watchStorageV1beta1StorageClassList(_api::StorageV1beta1Api; __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1WatchEvent, "/apis/storage.k8s.io/v1beta1/watch/storageclasses", ["BearerToken"])
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

watch changes to an object of kind VolumeAttachment. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.
Param: name::String (required)
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: pretty::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1WatchEvent
"""
function watchStorageV1beta1VolumeAttachment(_api::StorageV1beta1Api, name::String; __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1WatchEvent, "/apis/storage.k8s.io/v1beta1/watch/volumeattachments/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

"""

watch individual changes to a list of VolumeAttachment. deprecated: use the 'watch' parameter with a list operation instead.
Param: __continue__::String
Param: fieldSelector::String
Param: labelSelector::String
Param: limit::Int32
Param: pretty::String
Param: resourceVersion::String
Param: timeoutSeconds::Int32
Param: watch::Bool
Return: IoK8sApimachineryPkgApisMetaV1WatchEvent
"""
function watchStorageV1beta1VolumeAttachmentList(_api::StorageV1beta1Api; __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1WatchEvent, "/apis/storage.k8s.io/v1beta1/watch/volumeattachments", ["BearerToken"])
    Swagger.set_param(_ctx.query, "continue", __continue__)  # type String
    Swagger.set_param(_ctx.query, "fieldSelector", fieldSelector)  # type String
    Swagger.set_param(_ctx.query, "labelSelector", labelSelector)  # type String
    Swagger.set_param(_ctx.query, "limit", limit)  # type Int32
    Swagger.set_param(_ctx.query, "pretty", pretty)  # type String
    Swagger.set_param(_ctx.query, "resourceVersion", resourceVersion)  # type String
    Swagger.set_param(_ctx.query, "timeoutSeconds", timeoutSeconds)  # type Int32
    Swagger.set_param(_ctx.query, "watch", watch)  # type Bool
    Swagger.set_header_accept(_ctx, ["application/json", "application/yaml", "application/vnd.kubernetes.protobuf", "application/json;stream=watch", "application/vnd.kubernetes.protobuf;stream=watch"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["*/*"] : [_mediaType])
    Swagger.exec(_ctx)
end

export createStorageV1beta1CSIDriver, createStorageV1beta1CSINode, createStorageV1beta1StorageClass, createStorageV1beta1VolumeAttachment, deleteStorageV1beta1CSIDriver, deleteStorageV1beta1CSINode, deleteStorageV1beta1CollectionCSIDriver, deleteStorageV1beta1CollectionCSINode, deleteStorageV1beta1CollectionStorageClass, deleteStorageV1beta1CollectionVolumeAttachment, deleteStorageV1beta1StorageClass, deleteStorageV1beta1VolumeAttachment, getStorageV1beta1APIResources, listStorageV1beta1CSIDriver, listStorageV1beta1CSINode, listStorageV1beta1StorageClass, listStorageV1beta1VolumeAttachment, patchStorageV1beta1CSIDriver, patchStorageV1beta1CSINode, patchStorageV1beta1StorageClass, patchStorageV1beta1VolumeAttachment, readStorageV1beta1CSIDriver, readStorageV1beta1CSINode, readStorageV1beta1StorageClass, readStorageV1beta1VolumeAttachment, replaceStorageV1beta1CSIDriver, replaceStorageV1beta1CSINode, replaceStorageV1beta1StorageClass, replaceStorageV1beta1VolumeAttachment, watchStorageV1beta1CSIDriver, watchStorageV1beta1CSIDriverList, watchStorageV1beta1CSINode, watchStorageV1beta1CSINodeList, watchStorageV1beta1StorageClass, watchStorageV1beta1StorageClassList, watchStorageV1beta1VolumeAttachment, watchStorageV1beta1VolumeAttachmentList


text:
#=

# 7: Water collapse in 3D

A three dimensional variant of dam-break example.

=#

module collapse3d

using Printf
import SmoothedParticles

#=
Declare constant parameters
=#

##physical
const dr = 5.0e-3          #average particle distance (decrease to make finer simulation)
const h = 2.0*dr           #size of kernel support
const rho0 = 1000.   	   #fluid density
const m = rho0*dr^3        #particle mass
const c = 50.0             #numerical speed of sound
const g = -9.8*VECZ        #gravitational acceleration
const mu = 8.4e-4          #dynamic viscosity of water
const nu = 1.0e-4          #pressure stabilization

##geometrical
const water_column_width = 0.142
const water_column_height = 0.293
const box_height = 0.35
const box_width = 0.584
const box_depth = 0.15
const wall_width = 2.5*dr

##temporal
const dt = 0.1*h/c
const t_end = 0.5
const dt_frame = t_end/200

##particle types
const FLUID = 0.
const WALL = 1.

#=
Declare variables to be stored in a Particle
=#

mutable struct Particle <: AbstractParticle
	x::RealVector #position
	v::RealVector #velocity
	a::RealVector #acceleration
	P::Float64 #pressure
	rho::Float64 #density
	Drho::Float64 #rate of density
	type::Float64 #particle_type
	Particle(x, type) = new(
		x, VEC0, VEC0,
		0.,
		rho0, 0.,
		type
	)
end

#=
Define geometry and make particles
=#

function make_system()
	grid = Grid(dr, :cubic)
	box = Box(0., 0., 0., box_width, box_height, box_depth)
	fluid = Box(0., 0., 0., water_column_width, water_column_height, box_depth)
	walls = BoundaryLayer(box, grid, wall_width)
	walls = Specification(walls, x -> (x[2] < box_height))
	domain = SmoothedParticles.boundarybox(walls)
	sys = ParticleSystem(Particle, domain, h)
	generate_particles!(sys, grid, fluid, x -> Particle(x, FLUID))
	generate_particles!(sys, grid, walls, x -> Particle(x, WALL))
	return sys
end

#=
Define particle interactions
=#

@inbounds function balance_of_mass!(p::Particle, q::Particle, r::Float64)
	ker = m*rDwendland3(h,r)
	p.Drho += ker*(dot(p.x-q.x, p.v-q.v) + 2*nu*(p.rho-q.rho))
end

function find_pressure!(p::Particle)
	p.rho += p.Drho*dt
	p.Drho = 0.0
	p.P = c^2*(p.rho - rho0)
end

@inbounds function internal_force!(p::Particle, q::Particle, r::Float64)
	if p.type == FLUID
		ker = m*rDwendland3(h,r)
		p.a += -ker*(p.P/rho0^2 + q.P/rho0^2)*(p.x - q.x)
		p.a += +2*ker*mu/rho0^2*(p.v - q.v)
	end
end

function move!(p::Particle)
	p.a = VEC0
	if p.type == FLUID
		p.x += dt*p.v
	end
end

function accelerate!(p::Particle)
	if p.type == FLUID
		p.v += 0.5*dt*(p.a + g)
	end
end

function energy(p::Particle)::Float64
	kinetic = 0.5*m*dot(p.v, p.v)
	potential = -m*dot(g, p.x)
	internal =  0.5*m*c^2*(p.rho - rho0)^2/rho0^2
	return kinetic + potential + internal
end

#=
Put everything into a time loop
=#
function main()
	sys = make_system()
	out = new_pvd_file("results/collapse3d")
    println("# of parts = ", length(sys.particles))
	#a modified Verlet scheme
	@time for k = 0 : Int64(round(t_end/dt))
	#move particles
		apply!(sys, move!)
		create_cell_list!(sys)
		apply!(sys, balance_of_mass!)
		apply!(sys, find_pressure!)
		apply!(sys, internal_force!)
		apply!(sys, accelerate!)
		#save data at selected frames
		if (k % Int64(round(dt_frame/dt)) == 0)
			@printf("t = %.6e\n", k*dt)
			@printf("E = %.6e\n", sum(energy, sys.particles))
			@printf("\n")
			save_frame!(out, sys, :v, :P, :rho, :type)
		end
		#accelerate
		apply!(sys, accelerate!)
	end
	save_pvd_file(out)
end ## function main

end ## module


text:
"""
Seems OK
"""
function test_drop()
    snp = rand(0:1, 10, 8)
    ped = [1 2
           3 4
           ]
    r = ones(10).* 0.1
    r[1] = .5
    off = gdrop(snp, ped, r)
    [snp off]
end


text:
VERSION < v"0.7.0-beta2.199" && __precompile__()

"""
The Conda module provides access to the [conda](http://conda.pydata.org/) packages
manager to install binary dependencies of other Julia packages.

The main functions in Conda are:

- `Conda.add(package)`: install a package;
- `Conda.rm(package)`: remove (uninstall) a package;
- `Conda.update()`: update all installed packages to the latest version;
- `Conda.list()`: list all installed packages.
- `Conda.add_channel(channel)`: add a channel to the list of channels;
- `Conda.channels()`: get the current list of channels;
- `Conda.rm_channel(channel)`: remove a channel from the list of channels;
```
"""
module Conda
using Compat, JSON, VersionParsing

const deps_file = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")

if isfile(deps_file)
    # Includes definition for ROOTENV, and MINICONDA_VERSION
    include(deps_file)
else
    error("Conda is not properly configured.  Run Pkg.build(\"Conda\") before importing the Conda module.")
end

const Environment = Union{AbstractString,Symbol}

"Prefix for installation of the environment"
function prefix(name::Symbol)
    sname = string(name)
    if isempty(sname)
        throw(ArgumentError("Environment name should be non empty."))
    end
    return joinpath(ROOTENV, "envs", sname)
end

function prefix(path::AbstractString)
    if !isdir(path)
        throw(ArgumentError("Path to conda environment is not valid: $path"))
    end
    return path
end

const PREFIX = prefix(ROOTENV)

"Prefix for the executable files installed with the packages"
function bin_dir(env::Environment)
    return Compat.Sys.iswindows() ? joinpath(prefix(env), "Library", "bin") : joinpath(prefix(env), "bin")
end
const BINDIR = bin_dir(ROOTENV)

"Prefix for the shared libraries installed with the packages"
function lib_dir(env::Environment)
    return Compat.Sys.iswindows() ? joinpath(prefix(env), "Library", "bin") : joinpath(prefix(env), "lib")
end
const LIBDIR = lib_dir(ROOTENV)

"Prefix for the python scripts. On UNIX, this is the same than Conda.BINDIR"
function script_dir(env::Environment)
    return Compat.Sys.iswindows() ? joinpath(prefix(env), "Scripts") : bin_dir(env)
end
const SCRIPTDIR = script_dir(ROOTENV)

"Prefix where the `python` command lives"
function python_dir(env::Environment)
    return Compat.Sys.iswindows() ? prefix(env) : bin_dir(env)
end
const PYTHONDIR = python_dir(ROOTENV)

# note: the same conda program is used for all environments
const conda = if Compat.Sys.iswindows()
    p = script_dir(ROOTENV)
    conda_bat = joinpath(p, "conda.bat")
    isfile(conda_bat) ? conda_bat : joinpath(p, "conda.exe")
else
    joinpath(bin_dir(ROOTENV), "conda")
end

"Path to the condarc file"
conda_rc(env::Environment) = joinpath(prefix(env), "condarc-julia.yml")
const CONDARC = conda_rc(ROOTENV)

"""
Use a cleaned up environment for the command `cmd`.

Any environment variable starting by CONDA or PYTHON will interact with the run.
"""
function _set_conda_env(cmd, env::Environment=ROOTENV)
    env_var = copy(ENV)
    to_remove = String[]
    for var in keys(env_var)
        if startswith(var, "CONDA") || startswith(var, "PYTHON")
            push!(to_remove, var)
        end
    end
    for var in to_remove
        pop!(env_var, var)
    end
    env_var["PYTHONIOENCODING"]="UTF-8"
    env_var["CONDARC"] = conda_rc(env)
    env_var["CONDA_PREFIX"] = prefix(env)
    setenv(cmd, env_var)
end

"Run conda command with environment variables set."
function runconda(args::Cmd, env::Environment=ROOTENV)
    _install_conda(env)
    Compat.@info("Running $(`conda $args`) in $(env==ROOTENV ? "root" : env) environment")
    run(_set_conda_env(`$conda $args`, env))
    return nothing
end

"Run conda command with environment variables set and return the json output as a julia object"
function parseconda(args::Cmd, env::Environment=ROOTENV)
    _install_conda(env)
    JSON.parse(read(_set_conda_env(`$conda $args --json`, env), String))
end

"Get the miniconda installer URL."
function _installer_url()
    res = "https://repo.continuum.io/miniconda/Miniconda$(MINICONDA_VERSION)-latest-"
    if Compat.Sys.isapple()
        res *= "MacOSX"
    elseif Compat.Sys.islinux()
        res *= "Linux"
    elseif Compat.Sys.iswindows()
        if MINICONDA_VERSION == "3"
            # Quick fix for:
            # * https://github.com/JuliaLang/IJulia.jl/issues/739
            # * https://github.com/ContinuumIO/anaconda-issues/issues/10082
            # * https://github.com/conda/conda/issues/7789
            res = "https://repo.continuum.io/miniconda/Miniconda$(MINICONDA_VERSION)-4.5.4-"
        end
        res *= "Windows"
    else
        error("Unsuported OS.")
    end
    res *= Sys.WORD_SIZE == 64 ? "-x86_64" : "-x86"
    res *= Compat.Sys.iswindows() ? ".exe" : ".sh"
    return res
end

"Suppress progress bar in continuous integration environments"
_quiet() = get(ENV, "CI", "false") == "true" ? `-q` : ``

"Install miniconda if it hasn't been installed yet; _install_conda(true) installs Conda even if it has already been installed."
function _install_conda(env::Environment, force::Bool=false)
    if force || !isfile(Conda.conda)
        Compat.@info("Downloading miniconda installer ...")
        if Compat.Sys.isunix()
            installer = joinpath(PREFIX, "installer.sh")
        end
        if Compat.Sys.iswindows()
            installer = joinpath(PREFIX, "installer.exe")
        end
        download(_installer_url(), installer)

        Compat.@info("Installing miniconda ...")
        if Compat.Sys.isunix()
            chmod(installer, 33261)  # 33261 corresponds to 755 mode of the 'chmod' program
            run(`$installer -b -f -p $PREFIX`)
        end
        if Compat.Sys.iswindows()
            run(Cmd(`$installer /S /AddToPath=0 /RegisterPython=0 /D=$PREFIX`, windows_verbatim=true))
        end
        Conda.add_channel("defaults")
        # Update conda because conda 4.0 is needed and miniconda download installs only 3.9
        runconda(`update $(_quiet()) -y conda`)
    end
    if !isdir(prefix(env))
        runconda(`create $(_quiet()) -y -p $(prefix(env))`)
    end
end

const PkgOrPkgs = Union{AbstractString, AbstractVector{<: AbstractString}}

"Install a new package or packages."
function add(pkg::PkgOrPkgs, env::Environment=ROOTENV)
    runconda(`install $(_quiet()) -y $pkg`, env)
end

"Uninstall a package or packages."
function rm(pkg::PkgOrPkgs, env::Environment=ROOTENV)
    runconda(`remove $(_quiet()) -y $pkg`, env)
end

"Update all installed packages."
function update(env::Environment=ROOTENV)
    if env == ROOTENV
        runconda(`update $(_quiet()) -y --all conda`, env)
    else
        runconda(`update $(_quiet()) -y --all`, env)
    end
end

"List all installed packages as an dict of tuples with (version_number, fullname)."
function  _installed_packages_dict(env::Environment=ROOTENV)
    _install_conda(env)
    package_dict = Dict{String, Tuple{VersionNumber, String}}()
    for line in eachline(_set_conda_env(`$conda list`, env))
        line = chomp(line)
        if !startswith(line, "#")
            name, version, build_string = split(line)
            try
                package_dict[name] = (vparse(version), line)
            catch
                package_dict[name] = (v"9999.9999.9999", line)
                warn("Failed parsing string: \"$(version)\" to a version number. Please open an issue!")
            end
        end
    end
    return package_dict
end

"List all installed packages as an array."
_installed_packages(env::Environment=ROOTENV) = keys(_installed_packages_dict(env))

"List all installed packages to standard output."
function list(env::Environment=ROOTENV)
    runconda(`list`, env)
end

"Get the exact version of a package as a `VersionNumber`."
function version(name::AbstractString, env::Environment=ROOTENV)
    packages = parseconda(`list`, env)
    for package in packages
        pname = get(package, "name", "")
        startswith(pname, name) && return vparse(package["version"])
    end
    error("Could not find the $name package")
end

"Search packages for a string"
function search(package::AbstractString, env::Environment=ROOTENV)
    return collect(keys(parseconda(`search $package`, env)))
end

"Search a specific version of a package"
function search(package::AbstractString, _ver::Union{AbstractString,VersionNumber}, env::Environment=ROOTENV)
    ret=parseconda(`search $package`, env)
    out = String[]
    ver = string(_ver)
    verv = vparse(ver)
    for k in keys(ret)
      for i in 1:length(ret[k])
        kver = ret[k][i]["version"]
        (kver==ver || vparse(kver)==verv) && push!(out,k)
      end
    end
    out
end

"Check if a given package exists."
function exists(package::AbstractString, env::Environment=ROOTENV)
    if occursin("==", package)
      pkg,ver=split(package,"==")  # Remove version if provided
      return pkg in search(pkg,ver,env)
    else
      if package in search(package,env)
        # Found exactly this package
        return true
      else
        return false
      end
    end
end

"Get the list of channels used to search packages"
function channels(env::Environment=ROOTENV)
    ret=parseconda(`config --get channels`, env)
    if haskey(ret["get"], "channels")
        return collect(String, ret["get"]["channels"])
    else
        return String[]
    end
end

"Add a channel to the list of channels"
function add_channel(channel::AbstractString, env::Environment=ROOTENV)
    runconda(`config --add channels $channel --force`, env)
end

"Remove a channel from the list of channels"
function rm_channel(channel::AbstractString, env::Environment=ROOTENV)
    runconda(`config --remove channels $channel --force`, env)
end

end


text:
# This file is a part of Julia. License is MIT: https://julialang.org/license

mutable struct PipeServer <: LibuvServer
    handle::Ptr{Cvoid}
    status::Int
    cond::Base.ThreadSynchronizer
    function PipeServer(handle::Ptr{Cvoid}, status)
        p = new(handle,
                status,
                Base.ThreadSynchronizer())
        associate_julia_struct(p.handle, p)
        finalizer(uvfinalize, p)
        return p
    end
end

function PipeServer()
    pipe = PipeServer(Libc.malloc(Base._sizeof_uv_named_pipe), StatusUninit)
    iolock_begin()
    err = ccall(:uv_pipe_init, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cint), eventloop(), pipe.handle, 0)
    uv_error("failed to create pipe server", err)
    pipe.status = StatusInit
    iolock_end()
    return pipe
end

## server functions ##

accept(server::PipeServer) = accept(server, PipeEndpoint())

function accept_nonblock(server::PipeServer, client::PipeEndpoint)
    iolock_begin()
    if client.status != StatusInit
        error("client is already in use or has been closed")
    end
    err = ccall(:uv_accept, Int32, (Ptr{Cvoid}, Ptr{Cvoid}), server.handle, client.handle)
    if err == 0
        client.status = StatusOpen
    end
    iolock_end()
    return err
end

function accept_nonblock(server::PipeServer)
    client = PipeEndpoint()
    uv_error("accept", accept_nonblock(server, client) != 0)
    return client
end

function bind(server::PipeServer, name::AbstractString)
    iolock_begin()
    @assert server.status == StatusInit
    err = ccall(:uv_pipe_bind, Int32, (Ptr{Cvoid}, Cstring),
                server, name)
    if err != 0
        iolock_end()
        if err != UV_EADDRINUSE && err != UV_EACCES
            #TODO: this codepath is currently not tested
            throw(_UVError("bind", err))
        else
            return false
        end
    end
    server.status = StatusOpen
    iolock_end()
    return true
end

"""
    listen(path::AbstractString) -> PipeServer

Create and listen on a named pipe / UNIX domain socket.
"""
function listen(path::AbstractString)
    sock = PipeServer()
    bind(sock, path) || throw(ArgumentError("could not listen on path $path"))
    return listen(sock)
end

function connect!(sock::PipeEndpoint, path::AbstractString)
    iolock_begin()
    @assert sock.status == StatusInit
    req = Libc.malloc(Base._sizeof_uv_connect)
    uv_req_set_data(req, C_NULL)
    ccall(:uv_pipe_connect, Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}), req, sock.handle, path,
          uv_jl_connectcb::Ptr{Cvoid})
    sock.status = StatusConnecting
    iolock_end()
    return sock
end

"""
    connect(path::AbstractString) -> PipeEndpoint

Connect to the named pipe / UNIX domain socket at `path`.
"""
connect(path::AbstractString) = connect(PipeEndpoint(), path)

max_stars_repo_name: TimoLarson/julia

max_issues_repo_name: AsForMe/julia

max_forks_repo_name: AsForMe/julia


text:
export Mixture, PackedMixture

_defaultNamesMixtures(N::Int) = ((Symbol[Symbol("c$i") for i in 1:N])...,)

"""
$(TYPEDEF)

A `Mixture` object for use with either a `<: AbstractPrior` or `<: AbstractRelative`.

Notes
- The internal data representation is a `::NamedTuple`, which allows total type-stability for all component types.
- Various construction helpers can accept a variety of inputs, including `<: AbstractArray` and `Tuple`.

DevNotes
- TODO on sampling see #1099 and #1094 and #1069

Example
```juila
# prior factor
msp = Mixture(PriorSphere1,
              [model=Normal(0,0.1), Uniform(-pi/1,pi/2)],
              [0.5;0.5])

addFactor!(fg, [:head], msp, tags=[:MAGNETOMETER;])

# Or relative
mlr = Mixture(LinearRelative,
              (correlator=AliasingScalarSampler(...), naive=Normal(0.5,5), lucky=Uniform(0,10)),
              [0.5;0.4;0.1])

addFactor!(fg, [:x0;:x1], mlr)
```
"""
struct Mixture{N, F<:FunctorInferenceType, S, T<:Tuple} <: FunctorInferenceType
  mechanics::F
  components::NamedTuple{S,T}
  diversity::Distributions.Categorical
  dims::Int
  labels::Vector{Int}
end

Mixture(f::Type{F},
        z::NamedTuple{S,T},
        c::Distributions.DiscreteNonParametric ) where {F<:FunctorInferenceType, S, T} = Mixture{length(z),F,S,T}(f(LinearAlgebra.I), z, c, size( rand(z[1],1), 1), zeros(Int, 0))
Mixture(f::F,
        z::NamedTuple{S,T},
        c::Distributions.DiscreteNonParametric ) where {F<:FunctorInferenceType, S, T} = Mixture{length(z),F,S,T}(f, z, c, size( rand(z[1],1), 1), zeros(Int, 0))
Mixture(f::Union{F,Type{F}},z::NamedTuple{S,T},
        c::AbstractVector{<:Real}) where {F<:FunctorInferenceType,S,T} = Mixture(f, z, Categorical([c...]) )
Mixture(f::Union{F,Type{F}},
        z::NamedTuple{S,T},
        c::NTuple{N,<:Real}) where {N,F<:FunctorInferenceType,S,T} = Mixture(f, z, [c...] )
Mixture(f::Union{F,Type{F}},
        z::Tuple,
        c::Union{<:Distributions.DiscreteNonParametric, <:AbstractVector{<:Real}, <:NTuple{N,<:Real}} ) where {F<:FunctorInferenceType, N} = Mixture(f,NamedTuple{_defaultNamesMixtures(length(z))}(z), c )
Mixture(f::Union{F,Type{F}},
        z::AbstractVector{<:SamplableBelief},
        c::Union{<:Distributions.DiscreteNonParametric, <:AbstractVector{<:Real}, <:NTuple{N,<:Real}} ) where {F <: FunctorInferenceType, N} = Mixture(f,(z...,), c )

function Base.resize!(mp::Mixture, s::Int)
  resize!(mp.labels, s)
end

_lengthOrNothing(val) = length(val)
_lengthOrNothing(val::Nothing) = 0

# TODO make in-place memory version
function sampleFactor( cf::CalcFactor{<:Mixture}, N::Int=1)
  #
  # TODO consolidate #927, case if mechanics has a special sampler
  # TODO slight bit of waste in computation, but easiest way to ensure special tricks in s.mechanics::F are included
  ## example case is old FluxModelsPose2Pose2 requiring velocity
  # FIXME better consolidation of when to pass down .mechanics, also see #1099 and #1094 and #1069

  cf_ = CalcFactor( cf.factor.mechanics, cf.metadata, 0, _lengthOrNothing(cf._legacyMeas), cf._legacyMeas, cf._legacyParams)
  smpls = [getSample(cf_) for _=1:N]
    # smpls = Array{Float64,2}(undef,s.dims,N)
  #out memory should be right size first
  length(cf.factor.labels) != N ? resize!(cf.factor.labels, N) : nothing
  cf.factor.labels .= rand(cf.factor.diversity, N)
  for i in 1:N
    mixComponent = cf.factor.components[cf.factor.labels[i]]
    # measurements relate to the factor's manifold (either tangent vector or manifold point)
    setPointsMani!(smpls[i], rand(mixComponent,1))
  end

  # TODO only does first element of meas::Tuple at this stage, see #1099
  smpls
end

function DistributedFactorGraphs.isPrior(::Mixture{N, F, S, T}) where {N,F,S,T}
  return F <: AbstractPrior
end

"""
$(TYPEDEF)

Serialization type for `Mixture`.
"""
mutable struct PackedMixture <: PackedInferenceType
  N::Int
  # store the packed type for later unpacking
  F_::String
  S::Vector{String}
  components::Vector{String}
  diversity::String
end

function convert(::Type{PackedMixture}, obj::Mixture{N,F,S,T}) where {N,F,S,T}
  allcomp = String[]
  for val in obj.components
    # TODO, likely to be difficult for non-standard "Samplable" types -- e.g. Flux models in RoME
    push!(allcomp, convert(PackedSamplableBelief, val))
  end
  # pm = DFG.convertPackedType(obj.mechanics)
  pm = convert(DFG.convertPackedType(obj.mechanics), obj.mechanics)
  sT = string(typeof(pm))
  PackedMixture( N, sT, string.(collect(S)), allcomp, convert(PackedSamplableBelief, obj.diversity) )
end
function convert(::Type{Mixture}, obj::PackedMixture)
  N = obj.N
  F1 = getfield(Main, Symbol(obj.F_))
  S = (Symbol.(obj.S)...,)
  F2 = DFG.convertStructType(F1)
  components = convert.(SamplableBelief, obj.components)
  diversity = convert(SamplableBelief, obj.diversity)
  tupcomp = (components...,)
  ntup = NamedTuple{S,typeof(tupcomp)}(tupcomp)
  Mixture(F2, ntup, diversity)
end

  #


text:
using GPUArrays
using GPUArrays.TestSuite
using Base.Test

function run_blas(Typ)
    @testset "BLAS" begin
        T = Typ{Float32}
        @testset "matmul" begin
            against_base(*, T, (5, 5), (5, 5))
            against_base(*, T, (5, 5), (5,))
            against_base(A_mul_Bt, T, (5, 5), (5, 5))
            against_base(A_mul_Bt!, T, (10, 32), (10, 60), (32, 60))
            against_base(At_mul_B, T, (5, 5), (5, 5))
            against_base(At_mul_Bt, T, (10, 15), (1, 10))
            against_base(At_mul_B, T, (10, 15), (10,))
            against_base(A_mul_B!, T, (15,), (15, 10), (10,))
        end
        for T in (Complex64, Float32)
            @testset "scale! $T" begin
                against_base(scale!, Typ{T}, (13, 23), 77f0)
            end
        end
    end
end