text:
# solver code for the Euler equation

function evalSCResidual(mesh::AbstractMesh, operator::AbstractSBP, u::AbstractVector, u0, alpha_x::FloatingPoint, alpha_y::FloatingPoint)
# evaluate the residual using summation by parts (not including boundary integrals)
# this only works for triangular meshes, where are elements are same
# mesh : mesh type
# operator: what operator to use (SBP, lagrange polynomial ...)
# u : solution vector (must be ndof by 1) to be populated
# u0 : solution vector at previous timestep
# alpha_x and alpha_y : advection velocities in x and y directions

# not clear how to do source term using SBP operators

# initialize
#println("entered evalResidual")
#println("u = \n", u)
#println("u0 =\n", u0)

ndof = getNumNodes(mesh)
numEl = getNumEl(mesh)

# count the number of nodes per element
nnodes = operator.numnodes  # BAD: should not directly access fields
                            # SBP needs to provide access this
ub = zeros(nnodes) # holds original solution at for an element
fluxes = zeros(nnodes, 2)  # jacobian term times advection velocity divided by jac

Q_xi = operator.Q[:,:,1]
Q_eta = operator.Q[:,:,2]
#println("Q_xi = \n", Q_xi)
#println("Q_eta = \n", Q_eta)

p#rintln("performing volume integrals")
for i=1:numEl  # loop over element
#  println("\nelement i = ", i)
  dofnums_i = getGlobalNodeNumbers(mesh, i)

  ub = u0[dofnums_i]  # get original solution values
#  println("ub = \n", ub)

  vert_coords = getElementVertCoords(mesh, [i])
#  println("vert_coords = ", vert_coords)
#  println("size(vert_coords) = ", size(vert_coords))
  vert_coords_extract = vert_coords[1:2, :, :]
#  println("vert_coords_extract = ", vert_coords_extract)
#  println("type of vert_coords_extract = ", typeof(vert_coords_extract))
#  println("size of vert_coords_extract = ", size(vert_coords_extract))

  dxi_dx = zeros(2, 2, nnodes, 1)
#  println("size(dxi_dx) = ", size(dxi_dx))
  jac = zeros(nnodes, 1)
  mappingjacobian!(operator, vert_coords_extract, dxi_dx, jac)

#  println("jac = ", jac)
  dxi_dxu = zeros(nnodes,2)

  for j=1:nnodes
#    println("\nj = ", j)
#    println("jac_j = \n", dxi_dx[:,:,j,1])

    dxi_dxu[j,1] += (dxi_dx[1,1,j,1]*alpha_x + dxi_dx[1,2,j,1]*alpha_y)*ub[j]
    dxi_dxu[j,2] += (dxi_dx[2,1,j,1]*alpha_x + dxi_dx[2,2,j,1]*alpha_y)*ub[j]
  end

#  println("dxi_dxu = ", dxi_dxu)
  # multiply by stiffness matrix here because it is the same for all points in the element

  res = zeros(nnodes,1)
#  res_x = zeros(nnodes, 1)
#  res_y = zeros(nnodes, 1)

  # copy dxi_dxu into column matricies to satisfy SBP
  dxi_dxu_x = zeros(nnodes,1)
#  println("type of dxi_dxu_x = ", dxi_dxu_x)
  dxi_dxu_x[:] = dxi_dxu[:,1]
  dxi_dxu_y = zeros(nnodes,1)
  dxi_dxu_y[:] = dxi_dxu[:,2]
#  println("dxi_dxu_x = ", dxi_dxu_x)
#  println("dxi_dxu_y = ", dxi_dxu_y)
  weakdifferentiate!(sbp, 1, dxi_dxu_x, res, trans=true)
  weakdifferentiate!(sbp, 2, dxi_dxu_y, res, trans=true)

#  println("dxi_dxu_x = \n", dxi_dxu_x)
#  println("dxi_dxu_y = \n", dxi_dxu_y)
#  println("res_x = \n", res_x)
#  println("res_y = \n", res_y)

#  res = res_x + res_y

#  println("res = \n", res)
#  println("dofnums_i = ", dofnums_i)

  u[dofnums_i.'] += res
#  println("u = \n", u)
end  # end loop over elements

#println("after volume integral, u = \n", u)

end  # end function

function evalBndry(mesh::PumiMesh2, operator::AbstractSBP, u::AbstractVector, u0, alpha_x::FloatingPoint, alpha_y::FloatingPoint)
# evaluate boundary integrals for advection equation
# mesh : mesh type, must be PumiMesh (need adjacency information
# operator : SBP operator
# u : solution vector to be populated, has already has volume integrals done
# u0 : solution vector at previous timestep
# alpha_x and alpha_y : advection veocities in x and y directions

println("entered evalBndry")
#println("u = \n", u)
#println("u0 = \n", u0)

# get arguments needed for sbp boundaryintegrate!

bndry_edges = getBoundaryEdgeNums(mesh)
num_bndry_edges = length(bndry_edges)

bndry_faces = Array{Boundary}( num_bndry_edges)
bndry_sign = zeros(Int, num_bndry_edges)
bndry_orientation = zeros(Int, num_bndry_edges)
#println("getting boundary edge numbers")
for i=1:num_bndry_edges  # extract element and edge numbers
#  println("i = ", i)
  edgenum_i = bndry_edges[i]
  edge_i = mesh.edges[edgenum_i]

  # get mesh face associated with edge
  countAdjacent(mesh.m_ptr, edge_i, 2)
  face = getAdjacent(1)[1]  # get the single face (not an array)

  facenum_i = getFaceNumber2(face) + 1  # convert to 1 based indexing

  (down_edges, numedges) = getDownward(mesh.m_ptr, face, 1)
  edgenum_local = 0
  for j = 1:numedges  # find which local edge is edge_i
    if down_edges[j] == edge_i
      edgenum_local = j
    end
  end

#=
  # modify for orientation of parent element
  coords = getElementVertCoords(mesh, [facenum_i])
  println("coords = ", coords)
  println("before correction, edgenum = ", edgenum_local)
  if (coords[1,1] < coords[1,2]) && (coords[2,1] = coords[2,2] < 1e-12)  # first point is to left of second pointa
    println("correcting horizontally flipped element")
    if edgenum_local == 2  # reverse 2nd, 3rd edges
      edgenum_local = 3
      bndry_sign[i] = -1  # reverse sign of normal
    elseif edgenum_local == 3
      edgenum_local = 2
      bndry_sign[i] = -1  # reverse sign of normal
    end
  end

  if (coords[2,1] < coords[2,2]) && (coords[1,1] - coords [3,1] < 1e-12)
    println("correcting vertically flipped element")
    if edgenum_local == 1
      edgenum_local == 2  # reverse normal components here
      bndry_orientation[i] = -1  # reverse normal components
    elseif edgenum_local == 2
      edgenum_local = 1
      bndry_sign[i] = -1
    end
  end
=#
#  println("after correction, edgenum_local = ", edgenum_local)
  bndry_faces[i] = Boundary(facenum_i, edgenum_local)
end

#println("bndry_faces = \n", bndry_faces)

for i=1:num_bndry_edges
  bndry_i = bndry_faces[i]
#  println("i = ", i, " element ", bndry_i.element, "face ", bndry_i.face)
end

#println("size(bndry_faces) = ", size(bndry_faces))

# create new u formatted for SBP
# also get coordinates needed for  mapping jacobian
u_sbp = zeros(operator.numnodes, mesh.numEl)
x = zeros(2, operator.numnodes, mesh.numEl)

#println("u = ", u)
for i=1:mesh.numEl
  dofnums_i = getGlobalNodeNumbers(mesh, i)
  u_sbp[:,i] = u0[dofnums_i]

  x_i = getElementVertCoords(mesh, [i])
  x[:,:,i] = x_i[1:2,:]
end

dxi_dx = zeros(2,2,operator.numnodes, mesh.numEl)
jac = zeros(operator.numnodes, mesh.numEl)

#println("typeof dxi_dx = ", typeof(dxi_dx))

# populate dxi_dx and jac
mappingjacobian!(operator, x, dxi_dx, jac)

res = zeros(operator.numnodes, mesh.numEl)

# define the flux function
u_bc = sin(-1)  # boundary condition (for all sides)
#u_bc = 0.0

  cntr = 1  # count number of times flux function is called
  function flux1(u_sbp_, dxi_dx_, nrm)
    # u_sbp_ is the entry from u_sbp for this node
    # dxi_dx is the jacobian for this node
    # nrm is the normal vector

#    println("\nentered flux1")
#    println("cntr = ", cntr)
#    println("u_sbp_ = ", u_sbp_)
#    println("dxi_dx_ = \n", dxi_dx_)
#    println("u_sbp_ = ", u_sbp_)
#    println("u_bc = ", u_bc)
    u_xi = dxi_dx_[1,1]*alpha_x + dxi_dx_[1,2]*alpha_y
    u_eta = dxi_dx_[2,1]*alpha_x + dxi_dx_[2,2]*alpha_y

#    println("nrm = ", nrm)
#=
    # modify normal vector
    cnt_i = fld((cntr-1),2)
    cnt_i += 1

    println("cnt_i = ", cnt_i)
    if bndry_sign[cnt_i] == -1  # modify sign
      println("negating sign of normal")
      nrm = -1*nrm
    end

    if bndry_orientation[cnt_i] == -1  # reverse componentsa
      println("reversing normal components")
      tmp = nrm[1]
      nrm[1] = nrm[2]
      nrm[2] = tmp
    end
=#
#    println("nrm_mod = ", nrm)
#    println("u_xi = ", u_xi)
#    println("u_eta = ", u_eta)

    mag_x = u_xi*nrm[1]  # x flow magnitude
    mag_y = u_eta*nrm[2]  # y flow magnitude

    mag = mag_x + mag_y

#    println("mag_x = ", mag_x, " mag_y = ", mag_y)

    # because mag is scalar,not vector, can combine these if statements
    if mag < 0  # inflow condition, added factor of nrm[2]
#      println("xi inflow condition")
      flx_xi = u_xi*u_bc
    else
#      println("xi outflow condition")
      flx_xi = u_xi*u_sbp_
    end

    if mag < 0  # inflow condition, added factor of nrm[1]
#      println("eta inflow condition")
      flx_eta = u_eta*u_bc
    else
#      println("eta outflow condition")
      flx_eta = u_eta*u_sbp_
    end

#    println("flx_xi = ", flx_xi, " flx_eta = ", flx_eta)
    net_flux = flx_xi*nrm[1] + flx_eta*nrm[2]
#    println("net_flux = ", net_flux)

    cntr += 1
    return net_flux

  end

#  println("\nu_sbp = \n", u_sbp)
  boundaryintegrate!(operator, bndry_faces, u_sbp, dxi_dx, flux1, res)
#  println("finished performing boundaryintegrate!()\n")

#  println("before applying boundary integral, u = \n", u)
#  println("\nu_sbp = \n", u_sbp)

  bndry_contrib = zeros(mesh.numDof)
#println("assembling boundary terms")
for i=1:mesh.numEl
  dofnums_i = getGlobalNodeNumbers(mesh, i)
#  println("dofnums_i = ", dofnums_i)
  vals_i = res[:,i]

  u[dofnums_i.'] -= vals_i
  bndry_contrib[dofnums_i.'] -= vals_i

end

#  println("res = \n", res)
#  println("bndry_contrib = \n", bndry_contrib)
#  println("after boundary integral, u = \n", u)

end # end of outer function

function getMass(operator, mesh)
  # assemble mesh
  numnodes = mesh.numNodes  # number of dofs
  numdof = numnodes*mesh.numDofPerNode
  mass_matrix = zeros(numdof, numdof)

  for i=1:mesh.numEl
    dofnums_i = getGlobalNodeNumbers(mesh, i)
    nnodes = size(dofnums_i)[2]  # number of nodes
    for j=1:nnodes
      for k=1:mesh.numDofPerNode
        dofnum_k = dofnums_i[k,j]
        mass_matrix[dofnum_k, dofnum_k] += sbp.w[j]
      end
    end
  end

  return mass_matrix
end


text:
# module ...
using CSV, DataFrames, Markdown
using Mux
import Mux.WebSockets
using JSON
using HttpCommon
using Logging, LoggingExtras

using ScottishTaxBenefitModel
using .FRSHouseholdGetter
using .Utils
using .ModelHousehold
using .FRSHouseholdGetter: initialise, get_household, get_num_households

const DEFAULT_PORT=8002

include("../src/HouseholdMappingFRS_HBAI.jl")

"""
LOCAL version treating '-1' as missing.
main version in `Utils.jl`.
load a file into a dataframe and force all the identifiers into
lower case
"""
function l_load_to_frame(filename::AbstractString)::DataFrame
    println( "loading $filename")
    df = CSV.File(filename, delim = '\t',missingstrings=["-1",""]) |> DataFrame #
    lcnames = Symbol.(lowercase.(string.(names(df))))
    rename!(df, lcnames)
    df
end

"""
Local so we can treat "-1" as a missing string and add a datayear
"""
function l_loadfrs(which::AbstractString, year::Integer)::DataFrame
    filename = "$(FRS_DIR)/$(year)/tab/$(which).tab"
    df = l_load_to_frame(filename)
    n = size(df)[1]
    df.data_year = fill( year, n )
    return df
end

function addqstrdict(app, req  :: Dict )
    req[:parsed_querystring] = qstrtodict(req[:query])
    return app(req)
 end

struct RawData
    frsx  :: DataFrame
    hbai_res :: DataFrame
    accounts :: DataFrame
    benunit :: DataFrame
    extchild :: DataFrame
    maint :: DataFrame
    penprov :: DataFrame
    care :: DataFrame
    mortcont :: DataFrame
    pension :: DataFrame
    adult :: DataFrame
    child :: DataFrame
    govpay :: DataFrame
    mortgage :: DataFrame
    assets :: DataFrame
    childcare :: DataFrame
    househol :: DataFrame
    oddjob :: DataFrame
    rentcont :: DataFrame
    benefits :: DataFrame
    endowmnt :: DataFrame
    job :: DataFrame
    owner :: DataFrame
    renter :: DataFrame

end

function load_raw()::RawData
    year = 2015
    y = year - 2000
    ystr = "$(y)$(y+1)"
    frsx = l_loadfrs( "frs$ystr", year )
    hbai_res = l_load_to_frame("$(HBAI_DIR)/tab/"*HBAIS[year])
    print("on year $year ")
    accounts = l_loadfrs("accounts", year)
    benunit = l_loadfrs("benunit", year)
    extchild = l_loadfrs("extchild", year)
    maint = l_loadfrs("maint", year)
    penprov = l_loadfrs("penprov", year)
    care = l_loadfrs("care", year)
    mortcont = l_loadfrs("mortcont", year)
    pension = l_loadfrs("pension", year)
    adult = l_loadfrs("adult", year)
    child = l_loadfrs("child", year)
    govpay = l_loadfrs("govpay", year)
    mortgage = l_loadfrs("mortgage", year)
    assets = l_loadfrs("assets", year)
    chldcare = l_loadfrs("chldcare", year)
    househol = l_loadfrs("househol", year)
    oddjob = l_loadfrs("oddjob", year)
    rentcont = l_loadfrs("rentcont", year)
    benefits = l_loadfrs("benefits", year)
    endowmnt = l_loadfrs("endowmnt", year)
    job = l_loadfrs("job", year)
    owner = l_loadfrs("owner", year)
    renter = l_loadfrs("renter", year)

    for year in 2019:2018
        #=
        global frsx
        global hbai_res
        global accounts
        global benunit
        global extchild
        global maint
        global penprov
        global care
        global mortcont
        global pension
        global adult
        global child
        global govpay
        global mortgage
        global assets
        global childcare
        global househol
        global oddjob
        global rentcont
        global benefits
        global endowmnt
        global job
        global owner
        global renter
        =#
        y = year - 2000
        ystr = "$(y)$(y+1)"
        frsx = vcat( frsx, l_loadfrs( "frs$ystr", year ), cols=:union )
        n = size(frsx)
        hbai_res = vcat( hbai_res, l_load_to_frame("$(HBAI_DIR)/tab/"*HBAIS[year]),  cols=:union )
        print("on year $year frsx size=$n")
        accounts = vcat( accounts, l_loadfrs("accounts", year),  cols=:union )
        benunit = vcat( benunit, l_loadfrs("benunit", year),  cols=:union )
        extchild = vcat( extchild, l_loadfrs("extchild", year),  cols=:union )
        maint = vcat( maint, l_loadfrs("maint", year),  cols=:union )
        penprov = vcat( penprov, l_loadfrs("penprov", year),  cols=:union )
        care = vcat( care, l_loadfrs("care", year),  cols=:union )
        mortcont = vcat( mortcont, l_loadfrs("mortcont", year),  cols=:union )
        pension = vcat( pension, l_loadfrs("pension", year),  cols=:union )
        adult = vcat( adult, l_loadfrs("adult", year),  cols=:union )
        child = vcat( child, l_loadfrs("child", year),  cols=:union )
        govpay = vcat( govpay, l_loadfrs("govpay", year),  cols=:union )
        mortgage = vcat( mortgage, l_loadfrs("mortgage", year),  cols=:union )
        assets = vcat( assets, l_loadfrs("assets", year),  cols=:union )
        chldcare = vcat( chldcare, l_loadfrs("chldcare", year),  cols=:union )
        househol = vcat( househol, l_loadfrs("househol", year),  cols=:union )
        oddjob = vcat( oddjob, l_loadfrs("oddjob", year),  cols=:union )
        rentcont = vcat( rentcont, l_loadfrs("rentcont", year),  cols=:union )
        benefits = vcat( benefits, l_loadfrs("benefits", year),  cols=:union )
        endowmnt = vcat( endowmnt, l_loadfrs("endowmnt", year),  cols=:union )
        job = vcat( job, l_loadfrs("job", year),  cols=:union )
        owner = vcat( owner, l_loadfrs("owner", year),  cols=:union )
        renter = vcat( renter, l_loadfrs("renter", year),  cols=:union )
    end
    model_households = CSV.File( "data/model_households_scotland.tab") |> DataFrame
    model_people = CSV.File( "data/model_people_scotland.tab") |> DataFrame

    return RawData(
            frsx ,
            hbai_res,
            accounts,
            benunit,
            extchild,
            maint,
            penprov,
            care,
            mortcont,
            pension,
            adult,
            child,
            govpay,
            mortgage,
            assets,
            chldcare,
            househol,
            oddjob,
            rentcont,
            benefits,
            endowmnt,
            job,
            owner,
            renter
    )
end

const rd = load_raw()

function init_data(; reset :: Bool = false )
    nhh = get_num_households()
    num_people = -1
    if( nhh == 0 ) || reset
       @time nhh, num_people,nhh2 = initialise(
             household_name = "model_households_scotland",
             people_name    = "model_people_scotland" )
    end
    (nhh,num_people)
 end

function print_one( r :: DataFrameRow ) :: String
    nms = names( r )
    s = "|:-----------|-------------:|\n"
    for n in nms
        sym = Symbol(n)
        v = r[sym]
        if ! ismissing( v )
            s *= "|**$n**|$v|\n"
        end
    end
    s *= "\n\n"
    return s
end

function get_one( label :: String, frame :: DataFrame, sernum :: BigInt, data_year :: Int ) :: String
    s = ""
    items = frame[(frame.sernum .== sernum).&(frame.data_year .== data_year),:]
    n = size(items)[1]
    if n == 0
        s *= "###No $(label)s\n"
        return s
    elseif n == 1
        s *= "##$label\n"
        s *= print_one(items[1,:])
    else
        i = 1
        for item in eachrow(items)
            s *= "##$label ($i)\n"
            s *= print_one(item)
            i += 1
        end
    end
    return s
end

function get_data( hno, bits )
    mhh = FRSHouseholdGetter.get_household( hno )
    s = to_string( mhh )
    if :househol in bits
        s *= get_one( "Househol", rd.househol, mhh.hid, mhh.data_year)
        s *= get_one( "Renter", rd.renter, mhh.hid, mhh.data_year)
        s *= get_one( "Mortcont", rd.mortcont, mhh.hid, mhh.data_year)
        s *= get_one( "Owner", rd.owner, mhh.hid, mhh.data_year)
        s *= get_one( "RentCont", rd.rentcont, mhh.hid, mhh.data_year)
    end
    if :adult in bits
        s *= get_one( "Adult", rd.adult, mhh.hid, mhh.data_year)

        s *= get_one( "Job", rd.job, mhh.hid, mhh.data_year)
        s *= get_one( "Benefits", rd.benefits, mhh.hid, mhh.data_year)
        s *= get_one( "OddJob", rd.oddjob, mhh.hid, mhh.data_year)
        s *= get_one( "Accounts", rd.accounts, mhh.hid, mhh.data_year)
        s *= get_one( "Pension", rd.pension, mhh.hid, mhh.data_year)
        s *= get_one( "Penprov", rd.penprov, mhh.hid, mhh.data_year)
        s *= get_one( "Assets", rd.assets, mhh.hid, mhh.data_year)
        s *= get_one( "Endowment", rd.endowmnt, mhh.hid, mhh.data_year)
        s *= get_one( "GovPay", rd.govpay, mhh.hid, mhh.data_year)
        s *= get_one( "Maint", rd.maint, mhh.hid, mhh.data_year)
        s *= get_one( "Care", rd.care, mhh.hid, mhh.data_year)
    end
    if :child in bits
        s *= get_one( "Child", rd.child, mhh.hid, mhh.data_year)
        s *= get_one( "ExtChild", rd.extchild, mhh.hid, mhh.data_year)
        s *= get_one( "Childcare", rd.chldcare, mhh.hid, mhh.data_year)
    end
    if :hbai in bits
        s *= get_one( "HBAI", rd.hbai_res, mhh.hid, mhh.data_year)
    end
    if :frsx in bits
        s *= get_one( "FRS-Flatfile", rd.frsx, mhh.hid, mhh.data_year)
    end

    return s
end

# Headers -- set Access-Control-Allow-Origin for either dev or prod
# this is from https://github.com/JuliaDiffEq/DiffEqOnlineServer
#
function add_headers( md :: AbstractString ) :: Dict
    headers  = HttpCommon.headers()
    headers["Content-Type"] = "text/markdown; charset=utf-8"
    headers["Access-Control-Allow-Origin"] = "*"
    return Dict(
       :headers => headers,
       :body=> md
    )
end

function get_hh( hdstr :: AbstractString ) :: Dict
    @debug "get hh hdstr=$hdstr"
    hno = parse( Int, hdstr )
    @debug "get hh parsed hid=$hno"
    bits = [:househol]
    s = get_data( hno, bits )
    println( "got s $s")
    return add_headers( s )
end

function x_get_hh( req  :: Dict ) :: Dict
    println( "get_hh entered")
    querydict = req[:parsed_querystring]
    println("get_hh; req=$req")
    println( "querydict=$(querydict)")
    hno = querydict["hno"]
    bits = [:househol] # todo
    s = get_hhld( hno, bits )
    println( "got s $s")
    return add_headers( s )
end

init_data()
println("data initialised")
logger = FileLogger("/var/tmp/retriever.log")
global_logger(logger)
LogLevel( Logging.Info )

@app retriever = (
   Mux.defaults,
   page( respond("
STB Data Retrieval
")),
   # addqstrdict,
   # page("/get_hh:hid", req -> get_hh( ) )
   page( "/hhld/:hid", req -> get_hh( req[:params][:hid] )),
   Mux.notfound()
)
println("app created")

port = DEFAULT_PORT
if length(ARGS) > 0
   port = parse(Int, ARGS[1])
end

serve( retriever, port )
println( "server started on port $port ")

while true # FIXME better way?
   println( "main loop; server running on port $port" )
   sleep( 60 )
end

ext: jl

max_stars_repo_name: grahamstark/ScottishTaxBenefitModel

max_issues_repo_name: grahamstark/ScottishTaxBenefitModel

max_forks_repo_name: grahamstark/ScottishTaxBenefitModel


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

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

"""

create a ClusterRole
Param: body::IoK8sApiRbacV1beta1ClusterRole (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiRbacV1beta1ClusterRole
"""
function createRbacAuthorizationV1beta1ClusterRole(_api::RbacAuthorizationV1beta1Api, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "POST", IoK8sApiRbacV1beta1ClusterRole, "/apis/rbac.authorization.k8s.io/v1beta1/clusterroles", ["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 ClusterRoleBinding
Param: body::IoK8sApiRbacV1beta1ClusterRoleBinding (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiRbacV1beta1ClusterRoleBinding
"""
function createRbacAuthorizationV1beta1ClusterRoleBinding(_api::RbacAuthorizationV1beta1Api, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "POST", IoK8sApiRbacV1beta1ClusterRoleBinding, "/apis/rbac.authorization.k8s.io/v1beta1/clusterrolebindings", ["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 Role
Param: namespace::String (required)
Param: body::IoK8sApiRbacV1beta1Role (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiRbacV1beta1Role
"""
function createRbacAuthorizationV1beta1NamespacedRole(_api::RbacAuthorizationV1beta1Api, namespace::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "POST", IoK8sApiRbacV1beta1Role, "/apis/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/roles", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "namespace", namespace)  # 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

"""

create a RoleBinding
Param: namespace::String (required)
Param: body::IoK8sApiRbacV1beta1RoleBinding (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiRbacV1beta1RoleBinding
"""
function createRbacAuthorizationV1beta1NamespacedRoleBinding(_api::RbacAuthorizationV1beta1Api, namespace::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "POST", IoK8sApiRbacV1beta1RoleBinding, "/apis/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/rolebindings", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "namespace", namespace)  # 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

"""

delete a ClusterRole
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 deleteRbacAuthorizationV1beta1ClusterRole(_api::RbacAuthorizationV1beta1Api, name::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/rbac.authorization.k8s.io/v1beta1/clusterroles/{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 ClusterRoleBinding
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 deleteRbacAuthorizationV1beta1ClusterRoleBinding(_api::RbacAuthorizationV1beta1Api, name::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/rbac.authorization.k8s.io/v1beta1/clusterrolebindings/{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 ClusterRole
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 deleteRbacAuthorizationV1beta1CollectionClusterRole(_api::RbacAuthorizationV1beta1Api; 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/rbac.authorization.k8s.io/v1beta1/clusterroles", ["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 ClusterRoleBinding
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 deleteRbacAuthorizationV1beta1CollectionClusterRoleBinding(_api::RbacAuthorizationV1beta1Api; 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/rbac.authorization.k8s.io/v1beta1/clusterrolebindings", ["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 Role
Param: namespace::String (required)
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 deleteRbacAuthorizationV1beta1CollectionNamespacedRole(_api::RbacAuthorizationV1beta1Api, namespace::String; 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/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/roles", ["BearerToken"])
    Swagger.set_param(_ctx.path, "namespace", namespace)  # type String
    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 RoleBinding
Param: namespace::String (required)
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 deleteRbacAuthorizationV1beta1CollectionNamespacedRoleBinding(_api::RbacAuthorizationV1beta1Api, namespace::String; 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/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/rolebindings", ["BearerToken"])
    Swagger.set_param(_ctx.path, "namespace", namespace)  # type String
    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 Role
Param: name::String (required)
Param: namespace::String (required)
Param: pretty::String
Param: body::IoK8sApimachineryPkgApisMetaV1DeleteOptions
Param: dryRun::String
Param: gracePeriodSeconds::Int32
Param: orphanDependents::Bool
Param: propagationPolicy::String
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteRbacAuthorizationV1beta1NamespacedRole(_api::RbacAuthorizationV1beta1Api, name::String, namespace::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/roles/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.path, "namespace", namespace)  # 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 RoleBinding
Param: name::String (required)
Param: namespace::String (required)
Param: pretty::String
Param: body::IoK8sApimachineryPkgApisMetaV1DeleteOptions
Param: dryRun::String
Param: gracePeriodSeconds::Int32
Param: orphanDependents::Bool
Param: propagationPolicy::String
Return: IoK8sApimachineryPkgApisMetaV1Status
"""
function deleteRbacAuthorizationV1beta1NamespacedRoleBinding(_api::RbacAuthorizationV1beta1Api, name::String, namespace::String; pretty=nothing, body=nothing, dryRun=nothing, gracePeriodSeconds=nothing, orphanDependents=nothing, propagationPolicy=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", IoK8sApimachineryPkgApisMetaV1Status, "/apis/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/rolebindings/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.path, "namespace", namespace)  # 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 getRbacAuthorizationV1beta1APIResources(_api::RbacAuthorizationV1beta1Api; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApimachineryPkgApisMetaV1APIResourceList, "/apis/rbac.authorization.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 ClusterRole
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: IoK8sApiRbacV1beta1ClusterRoleList
"""
function listRbacAuthorizationV1beta1ClusterRole(_api::RbacAuthorizationV1beta1Api; pretty=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiRbacV1beta1ClusterRoleList, "/apis/rbac.authorization.k8s.io/v1beta1/clusterroles", ["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 ClusterRoleBinding
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: IoK8sApiRbacV1beta1ClusterRoleBindingList
"""
function listRbacAuthorizationV1beta1ClusterRoleBinding(_api::RbacAuthorizationV1beta1Api; pretty=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiRbacV1beta1ClusterRoleBindingList, "/apis/rbac.authorization.k8s.io/v1beta1/clusterrolebindings", ["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 Role
Param: namespace::String (required)
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: IoK8sApiRbacV1beta1RoleList
"""
function listRbacAuthorizationV1beta1NamespacedRole(_api::RbacAuthorizationV1beta1Api, namespace::String; pretty=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiRbacV1beta1RoleList, "/apis/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/roles", ["BearerToken"])
    Swagger.set_param(_ctx.path, "namespace", namespace)  # type String
    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 RoleBinding
Param: namespace::String (required)
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: IoK8sApiRbacV1beta1RoleBindingList
"""
function listRbacAuthorizationV1beta1NamespacedRoleBinding(_api::RbacAuthorizationV1beta1Api, namespace::String; pretty=nothing, __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiRbacV1beta1RoleBindingList, "/apis/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/rolebindings", ["BearerToken"])
    Swagger.set_param(_ctx.path, "namespace", namespace)  # type String
    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 RoleBinding
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: IoK8sApiRbacV1beta1RoleBindingList
"""
function listRbacAuthorizationV1beta1RoleBindingForAllNamespaces(_api::RbacAuthorizationV1beta1Api; __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiRbacV1beta1RoleBindingList, "/apis/rbac.authorization.k8s.io/v1beta1/rolebindings", ["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

"""

list or watch objects of kind Role
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: IoK8sApiRbacV1beta1RoleList
"""
function listRbacAuthorizationV1beta1RoleForAllNamespaces(_api::RbacAuthorizationV1beta1Api; __continue__=nothing, fieldSelector=nothing, labelSelector=nothing, limit=nothing, pretty=nothing, resourceVersion=nothing, timeoutSeconds=nothing, watch=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiRbacV1beta1RoleList, "/apis/rbac.authorization.k8s.io/v1beta1/roles", ["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

"""

partially update the specified ClusterRole
Param: name::String (required)
Param: body::IoK8sApimachineryPkgApisMetaV1Patch (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Param: force::Bool
Return: IoK8sApiRbacV1beta1ClusterRole
"""
function patchRbacAuthorizationV1beta1ClusterRole(_api::RbacAuthorizationV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PATCH", IoK8sApiRbacV1beta1ClusterRole, "/apis/rbac.authorization.k8s.io/v1beta1/clusterroles/{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 ClusterRoleBinding
Param: name::String (required)
Param: body::IoK8sApimachineryPkgApisMetaV1Patch (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Param: force::Bool
Return: IoK8sApiRbacV1beta1ClusterRoleBinding
"""
function patchRbacAuthorizationV1beta1ClusterRoleBinding(_api::RbacAuthorizationV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PATCH", IoK8sApiRbacV1beta1ClusterRoleBinding, "/apis/rbac.authorization.k8s.io/v1beta1/clusterrolebindings/{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 Role
Param: name::String (required)
Param: namespace::String (required)
Param: body::IoK8sApimachineryPkgApisMetaV1Patch (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Param: force::Bool
Return: IoK8sApiRbacV1beta1Role
"""
function patchRbacAuthorizationV1beta1NamespacedRole(_api::RbacAuthorizationV1beta1Api, name::String, namespace::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PATCH", IoK8sApiRbacV1beta1Role, "/apis/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/roles/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.path, "namespace", namespace)  # 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 RoleBinding
Param: name::String (required)
Param: namespace::String (required)
Param: body::IoK8sApimachineryPkgApisMetaV1Patch (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Param: force::Bool
Return: IoK8sApiRbacV1beta1RoleBinding
"""
function patchRbacAuthorizationV1beta1NamespacedRoleBinding(_api::RbacAuthorizationV1beta1Api, name::String, namespace::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, force=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PATCH", IoK8sApiRbacV1beta1RoleBinding, "/apis/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/rolebindings/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.path, "namespace", namespace)  # 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 ClusterRole
Param: name::String (required)
Param: pretty::String
Return: IoK8sApiRbacV1beta1ClusterRole
"""
function readRbacAuthorizationV1beta1ClusterRole(_api::RbacAuthorizationV1beta1Api, name::String; pretty=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiRbacV1beta1ClusterRole, "/apis/rbac.authorization.k8s.io/v1beta1/clusterroles/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # 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

"""

read the specified ClusterRoleBinding
Param: name::String (required)
Param: pretty::String
Return: IoK8sApiRbacV1beta1ClusterRoleBinding
"""
function readRbacAuthorizationV1beta1ClusterRoleBinding(_api::RbacAuthorizationV1beta1Api, name::String; pretty=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiRbacV1beta1ClusterRoleBinding, "/apis/rbac.authorization.k8s.io/v1beta1/clusterrolebindings/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # 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

"""

read the specified Role
Param: name::String (required)
Param: namespace::String (required)
Param: pretty::String
Return: IoK8sApiRbacV1beta1Role
"""
function readRbacAuthorizationV1beta1NamespacedRole(_api::RbacAuthorizationV1beta1Api, name::String, namespace::String; pretty=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiRbacV1beta1Role, "/apis/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/roles/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.path, "namespace", namespace)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # 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

"""

read the specified RoleBinding
Param: name::String (required)
Param: namespace::String (required)
Param: pretty::String
Return: IoK8sApiRbacV1beta1RoleBinding
"""
function readRbacAuthorizationV1beta1NamespacedRoleBinding(_api::RbacAuthorizationV1beta1Api, name::String, namespace::String; pretty=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", IoK8sApiRbacV1beta1RoleBinding, "/apis/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/rolebindings/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.path, "namespace", namespace)  # type String
    Swagger.set_param(_ctx.query, "pretty", pretty)  # 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 ClusterRole
Param: name::String (required)
Param: body::IoK8sApiRbacV1beta1ClusterRole (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiRbacV1beta1ClusterRole
"""
function replaceRbacAuthorizationV1beta1ClusterRole(_api::RbacAuthorizationV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", IoK8sApiRbacV1beta1ClusterRole, "/apis/rbac.authorization.k8s.io/v1beta1/clusterroles/{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 ClusterRoleBinding
Param: name::String (required)
Param: body::IoK8sApiRbacV1beta1ClusterRoleBinding (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiRbacV1beta1ClusterRoleBinding
"""
function replaceRbacAuthorizationV1beta1ClusterRoleBinding(_api::RbacAuthorizationV1beta1Api, name::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", IoK8sApiRbacV1beta1ClusterRoleBinding, "/apis/rbac.authorization.k8s.io/v1beta1/clusterrolebindings/{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 Role
Param: name::String (required)
Param: namespace::String (required)
Param: body::IoK8sApiRbacV1beta1Role (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiRbacV1beta1Role
"""
function replaceRbacAuthorizationV1beta1NamespacedRole(_api::RbacAuthorizationV1beta1Api, name::String, namespace::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", IoK8sApiRbacV1beta1Role, "/apis/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/roles/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.path, "namespace", namespace)  # 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 RoleBinding
Param: name::String (required)
Param: namespace::String (required)
Param: body::IoK8sApiRbacV1beta1RoleBinding (required)
Param: pretty::String
Param: dryRun::String
Param: fieldManager::String
Return: IoK8sApiRbacV1beta1RoleBinding
"""
function replaceRbacAuthorizationV1beta1NamespacedRoleBinding(_api::RbacAuthorizationV1beta1Api, name::String, namespace::String, body; pretty=nothing, dryRun=nothing, fieldManager=nothing, _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", IoK8sApiRbacV1beta1RoleBinding, "/apis/rbac.authorization.k8s.io/v1beta1/namespaces/{namespace}/rolebindings/{name}", ["BearerToken"], body)
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.path, "namespace", namespace)  # 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 ClusterRole. 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 watchRbacAuthorizationV1beta1ClusterRole(_api::RbacAuthorizationV1beta1Api, 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/rbac.authorization.k8s.io/v1beta1/watch/clusterroles/{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 changes to an object of kind ClusterRoleBinding. 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 watchRbacAuthorizationV1beta1ClusterRoleBinding(_api::RbacAuthorizationV1beta1Api, 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/rbac.authorization.k8s.io/v1beta1/watch/clusterrolebindings/{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 ClusterRoleBinding. 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 watchRbacAuthorizationV1beta1ClusterRoleBindingList(_api::RbacAuthorizationV1beta1Api; __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/rbac.authorization.k8s.io/v1beta1/watch/clusterrolebindings", ["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 individual changes to a list of ClusterRole. 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 watchRbacAuthorizationV1beta1ClusterRoleList(_api::RbacAuthorizationV1beta1Api; __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/rbac.authorization.k8s.io/v1beta1/watch/clusterroles", ["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 Role. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.
Param: name::String (required)
Param: namespace::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 watchRbacAuthorizationV1beta1NamespacedRole(_api::RbacAuthorizationV1beta1Api, name::String, namespace::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/rbac.authorization.k8s.io/v1beta1/watch/namespaces/{namespace}/roles/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.path, "namespace", namespace)  # 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 changes to an object of kind RoleBinding. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.
Param: name::String (required)
Param: namespace::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 watchRbacAuthorizationV1beta1NamespacedRoleBinding(_api::RbacAuthorizationV1beta1Api, name::String, namespace::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/rbac.authorization.k8s.io/v1beta1/watch/namespaces/{namespace}/rolebindings/{name}", ["BearerToken"])
    Swagger.set_param(_ctx.path, "name", name)  # type String
    Swagger.set_param(_ctx.path, "namespace", namespace)  # 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 RoleBinding. deprecated: use the 'watch' parameter with a list operation instead.
Param: namespace::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 watchRbacAuthorizationV1beta1NamespacedRoleBindingList(_api::RbacAuthorizationV1beta1Api, namespace::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/rbac.authorization.k8s.io/v1beta1/watch/namespaces/{namespace}/rolebindings", ["BearerToken"])
    Swagger.set_param(_ctx.path, "namespace", namespace)  # 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 Role. deprecated: use the 'watch' parameter with a list operation instead.
Param: namespace::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 watchRbacAuthorizationV1beta1NamespacedRoleList(_api::RbacAuthorizationV1beta1Api, namespace::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/rbac.authorization.k8s.io/v1beta1/watch/namespaces/{namespace}/roles", ["BearerToken"])
    Swagger.set_param(_ctx.path, "namespace", namespace)  # 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 RoleBinding. 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 watchRbacAuthorizationV1beta1RoleBindingListForAllNamespaces(_api::RbacAuthorizationV1beta1Api; __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/rbac.authorization.k8s.io/v1beta1/watch/rolebindings", ["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 individual changes to a list of Role. 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 watchRbacAuthorizationV1beta1RoleListForAllNamespaces(_api::RbacAuthorizationV1beta1Api; __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/rbac.authorization.k8s.io/v1beta1/watch/roles", ["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 createRbacAuthorizationV1beta1ClusterRole, createRbacAuthorizationV1beta1ClusterRoleBinding, createRbacAuthorizationV1beta1NamespacedRole, createRbacAuthorizationV1beta1NamespacedRoleBinding, deleteRbacAuthorizationV1beta1ClusterRole, deleteRbacAuthorizationV1beta1ClusterRoleBinding, deleteRbacAuthorizationV1beta1CollectionClusterRole, deleteRbacAuthorizationV1beta1CollectionClusterRoleBinding, deleteRbacAuthorizationV1beta1CollectionNamespacedRole, deleteRbacAuthorizationV1beta1CollectionNamespacedRoleBinding, deleteRbacAuthorizationV1beta1NamespacedRole, deleteRbacAuthorizationV1beta1NamespacedRoleBinding, getRbacAuthorizationV1beta1APIResources, listRbacAuthorizationV1beta1ClusterRole, listRbacAuthorizationV1beta1ClusterRoleBinding, listRbacAuthorizationV1beta1NamespacedRole, listRbacAuthorizationV1beta1NamespacedRoleBinding, listRbacAuthorizationV1beta1RoleBindingForAllNamespaces, listRbacAuthorizationV1beta1RoleForAllNamespaces, patchRbacAuthorizationV1beta1ClusterRole, patchRbacAuthorizationV1beta1ClusterRoleBinding, patchRbacAuthorizationV1beta1NamespacedRole, patchRbacAuthorizationV1beta1NamespacedRoleBinding, readRbacAuthorizationV1beta1ClusterRole, readRbacAuthorizationV1beta1ClusterRoleBinding, readRbacAuthorizationV1beta1NamespacedRole, readRbacAuthorizationV1beta1NamespacedRoleBinding, replaceRbacAuthorizationV1beta1ClusterRole, replaceRbacAuthorizationV1beta1ClusterRoleBinding, replaceRbacAuthorizationV1beta1NamespacedRole, replaceRbacAuthorizationV1beta1NamespacedRoleBinding, watchRbacAuthorizationV1beta1ClusterRole, watchRbacAuthorizationV1beta1ClusterRoleBinding, watchRbacAuthorizationV1beta1ClusterRoleBindingList, watchRbacAuthorizationV1beta1ClusterRoleList, watchRbacAuthorizationV1beta1NamespacedRole, watchRbacAuthorizationV1beta1NamespacedRoleBinding, watchRbacAuthorizationV1beta1NamespacedRoleBindingList, watchRbacAuthorizationV1beta1NamespacedRoleList, watchRbacAuthorizationV1beta1RoleBindingListForAllNamespaces, watchRbacAuthorizationV1beta1RoleListForAllNamespaces


text:
#=
functions to help with the construction and management of factor, node, and model structure
=#

macro factor(ftype, nodes...)
    ex = quote
        fi = get_structure($(nodes...))
        symdict = get_name_mapping($ftype, $(nodes...))
        $ftype{length(fi.indices)}($(nodes...), fi, symdict)
    end
    esc(ex)
end

"""
Calculate the value of a factor. Relies on value methods taking factor
types as arguments.
"""
@generated function value{N}(f::Factor{N})
    vars = fieldnames(f)
    val_expr = value(f)
    quote
        v = 0
        @nloops $N i d -> 1:f.inds.maxvals[d] begin
            v += @wrapvars $vars $val_expr project f (@ntuple $N i)
        end
        v
    end
end

###################################################
# Functions to deal with factor structure
###################################################
"""
Given a list of nodes, return a FactorInds type variable that calculates
the unique indices in the nodes, their ranges, and the map from node symbols
to integer indices.

TODO: Example showing how inner and outer indices get parsed and what the
inds_in_* mappings are.
"""
get_structure(nodes...) = get_structure(Symbol[], nodes...)

function get_structure(forced_inners::Vector{Symbol}, nodes...)
    # first, get all indices that are not inner for any node
    # these will be the nodes that need explicit summing
    outers = union([n.outerinds for n in nodes]...)
    inners = union(forced_inners, [n.innerinds for n in nodes]...)
    allinds = setdiff(outers, intersect(outers, inners))

    # now, map these indices to consecutive integers
    idx_to_int = [idx => idxnum for (idxnum, idx) in enumerate(allinds)]

    #=
    initialize some Dicts that will be useful for working with factors:
    - idxdict: map index symbol to the size of each node along this
        dimension
    - node_to_int_inds: map node symbol to the integer codes within the
        factor of its fully outer indices
    - ints_within_node: map node symbol to the subset of *all* its indices
        corresponding to the fully outer indices
    =#
    idxdict = Dict{Symbol, Vector{Int}}([(idx => []) for idx in allinds])
    inds_in_factor = Dict{Symbol, Vector{Int}}([(n.name => []) for n in nodes])
    inds_in_node = Dict{Symbol, Vector{Int}}([(n.name => []) for n in nodes])

    # now loop over nodes, building these dicts
    for n in nodes
        for (d, idx) in enumerate(n.outerinds)
            # if this outer index is to be summed over...
            if idx in allinds
                push!(idxdict[idx], size(n)[d])
                push!(inds_in_factor[n.name], idx_to_int[idx])
                push!(inds_in_node[n.name], indexin([idx], n.outerinds)[1])
            end
        end
    end

    # lastly, check that the index ranges are the same for every node in
    # which an index appears; build a vector of index ranges
    maxvals = Integer[]
    for idx in allinds
        lengths = idxdict[idx]
        if !all(x -> x == lengths[1], lengths)
            error("Index length mismatch in index $idx.")
        else
            push!(maxvals, lengths[1])
        end
    end

    FactorInds(allinds, maxvals, inds_in_factor, inds_in_node)
end

function get_name_mapping{F <: Factor}(ftype::Type{F}, nodes...)
    nodenames = [n.name for n in nodes]
    Dict(zip(nodenames, fieldnames(ftype)))
end

"""
Given a factor, a symbol naming a variable in that factor, and a tuple of
index ranges for the factor as a whole, return the elements of node
corresponding to the global range of indices.
"""
function project(name::Symbol, f, rangetuple)
    node = node_from_name(f, name)
    if length(project_inds(name, f, rangetuple)) > 0
        out = node[project_inds(name, f, rangetuple)...]
    else
        alltuple = [Colon() for _ in 1:ndims(node)]
        out = node[alltuple...]
    end
    out
end

function project_inds(name::Symbol, f, rangetuple)
    node = node_from_name(f, name)
    factor_inds = f.inds.inds_in_factor[node.name]
    node_inds = f.inds.inds_in_node[node.name]
    ninds = length(node.outerinds)

    outtuple = repmat(Any[Colon()], ninds)
    if !isempty(node_inds)
        for (ni, fi) in zip(node_inds, factor_inds)
            outtuple[ni] = rangetuple[fi]
        end
    end
    outtuple
end

###################################################
# helper functions on nodes
###################################################
node_from_name(f::Factor, name::Symbol) = getfield(f, name)
node_from_name(f::ExprNode, name::Symbol) = f.nodedict[name]

nodeextract(key, node) = node.nodedict[key]

size(n::Node) = size(n.data)
size(n::ExprNode) = tuple(n.dims...)
ndims(n::Node) = length(size(n))

getindex(n::Node, inds...) = n.data[inds...]

function getindex(n::ExprNode, inds...)
    nd = Dict([(s => project(s, n, inds)) for (s, _) in n.nodedict])
    ExprDist{Val{n.name}}(nd)
end
setindex!(n::Node, val, inds...) = setindex!(n.data, val, inds...)

function get_par_sizes(d::Distribution)
    [size(p) for p in unconstrain(d)]
end

function unroll_pars(n::RandomNode)
    vcat(map(unroll_pars, n.data)...)
end

function unroll_pars(d::Distribution)
    vcat([flatten(par) for par in unconstrain(d)]...)
end

function reroll_pars(d::Distribution, par_sizes, x)
    D = typeof(d).name.primary
    ctr = 0
    pars = []
    for (i, dims) in enumerate(par_sizes)
        sz = prod(dims)
        p = sz == 1 ? x[ctr + 1] : reshape(x[ctr + 1: ctr + sz], dims)
        push!(pars, p)
        ctr += sz
    end
    D(constrain(pars, d)...)
end


text:
using BNPRegressionGGA2021
using Distributions
using Gadfly
using LaTeXStrings

begin
    ygrid = LinRange(0, 6, 50) |> collect;
    dy1 = LogNormal(0.3, 0.7);
    dy2 = MixtureModel(LogNormal, [(0.0, 1.0), (0.3, 1.2)], [0.6, 0.4]);
    fy1 = pdf.(dy1, ygrid);
    fy2 = pdf.(dy2, ygrid);
    Sy1 = 1.0 .- cdf.(dy1, ygrid);
    Sy2 = 1.0 .- cdf.(dy2, ygrid);
    hy1 = pdf.(dy1, ygrid) ./ Sy1;
    hy2 = pdf.(dy2, ygrid) ./ Sy2;
    hry = hy2 ./ hy1;
end

# Densities
plot_fy = plot(
    layer(x = ygrid, y = fy2, Geom.line, color=["xᵢ₅ = 1"]),
    layer(x = ygrid, y = fy1, Geom.line, color=["xᵢ₅ = 0"]),
    Guide.xlabel("zᵢ"),
    Guide.ylabel("density function"),
)

# Hazard curves
plot_hy = plot(
    layer(x = ygrid, y = hy2, Geom.line, color=["xᵢ₅ = 1"]),
    layer(x = ygrid, y = hy1, Geom.line, color=["xᵢ₅ = 0"]),
    Guide.xlabel("zᵢ"),
    Guide.ylabel("hazard function"),
)

x, y = 0.55*rand(4), 0.55*rand(4)

# Survival curves
# plot_sy = plot(
#     layer(x = ygrid, y = Sy2, Geom.line, Geom.point, shape=[String(L"$x_{i5} = 1$")]),
#     layer(x = ygrid, y = Sy1, Geom.line, Geom.point, shape=[String(L"$x_{i5} = 0$")]),
#     # Theme(point_shapes = [Shape.square, Shape.xcross], default_color = "grey")
#     # layer(x = ygrid, y = Sy1, Geom.line, Geom.point, shape=[L"$x_{i5} = 0$"]),
#     # Guide.xlabel(String(L"$z_i$")),
#     # Guide.ylabel("survival function"),
#     # style(key_position = :top)
# )

plot_sy = plot(
    layer(x = ygrid, y = Sy2, Geom.line, linestyle=[String(L"$x_{i5} = 1$")]),
    layer(x = ygrid, y = Sy1, Geom.line, linestyle=[String(L"$x_{i5} = 0$")]),
    Scale.linestyle_discrete(levels = String.([L"$x_{i5} = 1$", L"$x_{i5} = 0$"])),
    Theme(default_color = "grey", line_style = [:dot, :dash])
    # layer(x = ygrid, y = Sy1, Geom.line, Geom.point, shape=[L"$x_{i5} = 0$"]),
    # Guide.xlabel(String(L"$z_i$")),
    # Guide.ylabel("survival function"),
    # style(key_position = :top)
)

# Hazard ratio
plot_hr = plot(
    x = ygrid,
    y = hry,
    Geom.line,
    Guide.ylabel("hazard ratio"),
    Guide.xlabel(String(L"$z_i$")),
)

draw(SVG("figures/crossing-survival-curves.svg", 2.5inch, 3inch), plot_sy)
draw(SVG("figures/non-proportional-hazards.svg", 2.5inch, 3inch), plot_hr)


text:
taskLoggingOn = true

function turn_on_logging()
    global taskLoggingOn = true
end

function turn_off_logging()
    global taskLoggingOn = false
end


text:
@testset "Utility functions" begin
    midi = load(testmidi())
    @test time_signature(midi) == "4/4"
    @test qpm(midi) ≈ 130.00013
    @test bpm(midi) ≈ 130.00013

    first_tempo_event = tempochanges(midi)[1]
    @test first_tempo_event[1] == 0
    @test first_tempo_event[2] ≈ 130.00013
end


text:
function charge(sequence, pKvalues = pKtable["solomon"], pH = 7.0)
    aa = BioSequences.composition(sequence)

    charge = 0.0

    charge += (1 / (1 + 10^(1 * (pH - pKvalues[1]))))
    charge += (-1 / (1 + 10^(-1 * (pH - pKvalues[2]))))

    charge += aa[AA_C] * (-1 / (1 + 10^(-1 * (pH - pKvalues[3]))))
    charge += aa[AA_D] * (-1 / (1 + 10^(-1 * (pH - pKvalues[4]))))
    charge += aa[AA_E] * (-1 / (1 + 10^(-1 * (pH - pKvalues[5]))))
    charge += aa[AA_Y] * (-1 / (1 + 10^(-1 * (pH - pKvalues[9]))))
    charge += aa[AA_H] * (1 / (1 + 10^(1 * (pH - pKvalues[6]))))
    charge += aa[AA_K] * (1 / (1 + 10^(1 * (pH - pKvalues[7]))))
    charge += aa[AA_R] * (1 / (1 + 10^(1 * (pH - pKvalues[8]))))

    return charge
end

"""
    pI(sequence, [pKvalues; gamma])

Estimate isoelectric point of `sequence`. `pKvalues` can be a vector containing pK values or a string specifying one of the pK-value sources in `pKtable`. See the docstring for `pKtable` for details. Default is "IPC protein".
"""
pI(sequence::LongAminoAcidSeq, pKvalues::AbstractString; gamma = 0.001) = pI(sequence, pKtable[pKvalues]; gamma = gamma)
function pI(sequence::LongAminoAcidSeq, pKvalues = pKtable["IPC protein"]; gamma = 0.001)
    pH = 7.0

    if charge(sequence, pKvalues, pH) < 0
        pHs = 0:gamma:7
        charges = charge.(Ref(sequence), Ref(pKvalues), pHs)
        pH = pHs[findmin(abs.(charges))[2]]
        return pH
    end

    if charge(sequence, pKvalues, pH) > 0
        pHs = 7:gamma:14
        charges = charge.(Ref(sequence), Ref(pKvalues), pHs)
        pH = pHs[findmin(abs.(charges))[2]]
        return pH
    end

    return pH
end


text:
using PolygonalFem

include("test_costnormU.jl")


text:
function seed_cleanup!(S::SeisData, BUF::SeisIOBuf)
  trunc_x!(S)
  fill!(getfield(BUF, :hdr_old), zero(UInt8))
  setfield!(BUF, :r1_old, zero(Int16))
  setfield!(BUF, :r2_old, zero(Int16))
  return nothing
end

function parsemseed!(S::SeisData, io::IO, nx_new::Int64, nx_add::Int64, strict::Bool, v::Integer)
  while !eof(io)
    parserec!(S, BUF, io, nx_new, nx_add, strict, v)
  end
  seed_cleanup!(S, BUF)
  return nothing
end

function read_mseed_file!(S::SeisData, fname::String,  nx_new::Int64, nx_add::Int64, memmap::Bool, strict::Bool, v::Integer)
  io  = memmap ? IOBuffer(Mmap.mmap(fname)) : open(fname, "r")
  fastskip(io, 6)
  c = fastread(io)
  if c in (0x44, 0x52, 0x4d, 0x51)
    seekstart(io)
    parsemseed!(S, io, nx_new, nx_add, strict, v)
    close(io)
  else
    close(io)
    error("Invalid file type!")
  end
  return nothing
end


text:
using Flux, Images
using StatsBase: sample, shuffle

const PATH = joinpath(@__DIR__, "train")
const FILES = joinpath.(PATH, readdir(PATH))
if isempty(readdir(PATH))
  error("Empty train folder - perhaps you need to download and extract the kaggle dataset.")
end

# Get all of the files with "dog" in the name
const DOGS = filter(x -> occursin("dog", x), FILES)

# Get all of the files with "cat" in the name
const CATS = filter(x -> occursin("cat", x), FILES)

# Takes in the number of requested images per batch ("n") and image size
# Returns a 4D array with images and an array of labels
function load_batch(n = 10, nsize = (224,224); path = PATH)
  if ((batchsize % 2) != 0)
      print("Batch size must be an even number")
  end
  # Sample N dog images and N cat images, shuffle, and then combine them into a batch
  imgs_paths = shuffle(vcat(sample(DOGS, Int(n/2)), sample(CATS, Int(n/2))))

  # Generate the image label based on the file name
  labels = map(x -> occursin("dog.",x) ? 1 : 0, imgs_paths)
  # Here, dog is set to 1 and cat to 0

  # Convert the text based names to 0 or 1 (one hot encoding)
  labels = Flux.onehotbatch(labels, [0,1])

  # Load all of the images
  imgs = Images.load.(imgs_paths)

  # Re-size the images based on imagesize from above (most models use 224 x 224)
  imgs = map(img -> Images.imresize(img, nsize...), imgs)

  # Change the dimensions of each image, switch to gray scale. Channel view switches to...
  # a 3 channel 3rd dimension and then (3,2,1) makes those into seperate arrays.
  # So we end up with [:, :, 1] being the Red values, [:, :, 2] being the Green values, etc
  imgs = map(img -> permutedims(channelview(img), (3,2,1)), imgs)
  # Result is two 3D arrays representing each image

  # Concatenate the two images into a single 4D array and add another extra dim at the end
  # which shows how many images there are per set, in this case, it's 2
  imgs = cat(imgs..., dims = 4)
  # This is requires since the model's input is a 4D array

  # Convert the images to float form and return them along with the labels
  # The default is float64 but float32 is commonly used which is why we use it
  Float32.(imgs), labels
end

max_stars_repo_name: Ossifragus/model-zoo

max_issues_repo_name: Ossifragus/model-zoo

max_forks_repo_name: Ossifragus/model-zoo


text:
# %% Modules

include("DASTDP.jl")
include("NeuronModel.jl")

using .DASTDP
using .NeuronModel
using Statistics

# %% Constants

const T = 2000
const n1 = 1
const syn = 45
const n2 = post[n1,syn]
const interval = 20

# %% reward functions

function reward(n1f::Array{Int64},n2f::Array{Int64},rew::Array{Int64},fired::Array{Int64},time::Int64) # Module DA_STDP
    if n1 in fired
        append!(n1f,time)
    end
    if n2 in fired
        append!(n2f,time)
        if (time-last(n1f)<interval) && (last(n2f)>last(n1f))
            append!(rew,time+1000+rand(1:2000))
        end
    end
    return n1f,n2f,rew
end

# %% Network Structure

mutable struct NeuralNet
    v::Array{Float64}
    u::Array{Float64}
    s::Array{Float64,2}
    sd::Array{Float64,2}
    STDP::Array{Float64,2}
    firings::Array{Int64,2}
    DA::Float64
    rew::Array{Int64}
    n1f::Array{Int64}
    n2f::Array{Int64}
    I::Array{Float64}
    shist::Array{Float64,2}

    function NeuralNet()
        v = -65.0*ones(N)
        u = 0.2*v
        s = vcat(1.0 .* ones(Ne,M),-1.0 .* ones(Ni,M))
        s[n1,syn] = 0.0
        sd = 0.0 .* zeros(N,M)
        STDP = 0.0 .* zeros(N,1001+D)
        firings = [-D*1.0 0.0]
        DA = 0.0
        rew = []
        n1f = [-100]
        n2f = []
        I = Float64[]
        shist = zeros(1000*T, 2)
        new(v,u,s,sd,STDP,firings,DA,rew,n1f,n2f,I,shist)
    end
end
# %% Main loop

net = NeuralNet()

@time @inbounds for sec in 0:T-1
    @inbounds for msec in 1:2000
        net.I = 13*(rand(N).-0.5)
        time = 1000*sec+msec
        fired = findall(x->x>=thresh,net.v)
        net.v,net.u = izhikevicmodel_fire(net.v,net.u,fired)
        net.STDP = STDP_fire(net.STDP,fired,msec)
        net.sd = LTP(net.STDP,net.sd,fired,msec)
        net.firings = vcat(net.firings,hcat(msec.*ones(length(fired)),fired))
        net.I,net.sd = LTD(net.STDP,net.sd,net.s,net.firings,net.I,msec)
        net.v,net.u = izhikevicmodel_step(net.v,net.u,net.I)
        net.STDP,net.DA = DA_STDP_step(net.STDP,net.DA,msec)
        if msec%10==0
            net.s,net.sd = synweight_step(net.sd,net.s,net.DA,msec)
        end
        if sec<1000
            net.n1f,net.n2f,net.rew = reward(net.n1f,net.n2f,net.rew,fired,time)
        end
        net.DA = DA_inc(net.rew,net.DA,time)
        net.shist[time,:] = [net.s[n1,syn],net.sd[n1,syn]]
    end
    net.STDP,net.firings = time_reset(net.STDP,net.firings)
    if sec%100==0
        print("\rsec = $sec")
    end
end

# %% Plot learning of the targeted synapse
using Plots
gr()
x1 = 0.001.*collect(1:length(net.shist[:,1]))
y1 = net.shist[:,1]
x2 = x1
y2 = net.shist[:,2]
fig = plot()
plot!(x1,y1,color="blue",label="synapse weight", legend = true)
plot!(x2,y2,color="green",label="eligibilty trace", legend = true)
xlabel!("Time (sec)")

max_stars_repo_name: SuReLI/RL-STDP

max_issues_repo_name: SuReLI/RL-STDP

max_forks_repo_name: SuReLI/RL-STDP


text:
# This file was generated, do not modify it. # hide
using Gnuplot
@gsp " " :-  # reset session
@gsp "unset key" "set multi layout 2,2 title 'Multiplot title'" :-
@gsp :- 1 x y Z "w linespoints pt 4 ps 2" :-
@gsp :- 2 x y Z "w points pt 3 ps 3" :-
@gsp :- 3 x y Z "w l palette" "set view 55, 65" :-
@gsp :- 4 x y Z "w pm3d" "set view 55, 65" "set key off" :-
@gsp :- x y Z "w l lc 'white'"
save(term="pngcairo size 1200,800", output="plt3d_ex2.png")