R/RoleApi.r

# Looker API 4.0 (Beta) Reference
#
#  Welcome to the future! API 4.0 co-exists with APIs 3.1 and 3.0. (3.0 should no longer be used.) The \"beta\" tag means updates for API 4.0 may include breaking changes, but as always we will work to minimize them.  ### Authorization  The classic method of API authorization uses Looker **API3** credentials for authorization and access control. Looker admins can create API3 credentials on Looker's **Admin/Users** page.  API 4.0 adds additional ways to authenticate API requests, including OAuth and CORS requests.  For details, see [Looker API Authorization](https://looker.com/docs/r/api/authorization).   ### API Explorer  The API Explorer is a Looker-provided utility with many new and unique features for learning and using the Looker API and SDKs. It is a replacement for the 'api-docs' page currently provided on Looker instances.  For details, see the [API Explorer documentation](https://looker.com/docs/r/api/explorer).   ### Looker Language SDKs  The Looker API is a RESTful system that should be usable by any programming language capable of making HTTPS requests. SDKs for a variety of programming languages are also provided to streamline using the API. Looker has an OpenSource [sdk-codegen project](https://github.com/looker-open-source/sdk-codegen) that provides several language SDKs. Language SDKs generated by `sdk-codegen` have an Authentication manager that can automatically authenticate API requests when needed.  For details on available Looker SDKs, see [Looker API Client SDKs](https://looker.com/docs/r/api/client_sdks).   ### API Versioning  Future releases of Looker expand the latest API version release-by-release to securely expose more and more of the core power of the Looker platform to API client applications. API endpoints marked as \"beta\" may receive breaking changes without warning (but we will try to avoid doing that). Stable (non-beta) API endpoints should not receive breaking changes in future releases.  For details, see [Looker API Versioning](https://looker.com/docs/r/api/versioning).   ### In This Release  API 4.0 version was introduced so we can make adjustments to API functions, parameters, and response types to fix bugs and inconsistencies. These changes fall outside the bounds of non-breaking additive changes we can make to our stable API 3.1.  One benefit of these type adjustments in API 4.0 is dramatically better support for strongly typed languages like TypeScript, Kotlin, Swift, Go, C#, and more.  While API 3.1 is still the de-facto Looker API (\"current\", \"stable\", \"default\", etc), the bulk of our development activity has shifted to API 4.0, where all new features are added.  The API Explorer can be used to [interactively compare](https://looker.com/docs/r/api/explorer#comparing_api_versions) the differences between API 3.1 and 4.0.   ### API and SDK Support Policies  Looker API versions and language SDKs have varying support levels. Please read the API and SDK [support policies](https://looker.com/docs/r/api/support-policy) for more information.   
#
# OpenAPI spec version: 4.0.21.18
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git

#' @title Role operations
#' @description looker.Role
#'
#' @field path Stores url path of the request.
#' @field apiClient Handles the client-server communication.
#' @field userAgent Set the user agent of the request.
#'
#' @importFrom R6 R6Class
#'
#' @section Methods:
#' \describe{
#'
#' all_model_sets Get All Model Sets
#'
#'
#' all_permission_sets Get All Permission Sets
#'
#'
#' all_permissions Get All Permissions
#'
#'
#' all_roles Get All Roles
#'
#'
#' create_model_set Create Model Set
#'
#'
#' create_permission_set Create Permission Set
#'
#'
#' create_role Create Role
#'
#'
#' delete_model_set Delete Model Set
#'
#'
#' delete_permission_set Delete Permission Set
#'
#'
#' delete_role Delete Role
#'
#'
#' model_set Get Model Set
#'
#'
#' permission_set Get Permission Set
#'
#'
#' role Get Role
#'
#'
#' role_groups Get Role Groups
#'
#'
#' role_users Get Role Users
#'
#'
#' search_model_sets Search Model Sets
#'
#'
#' search_permission_sets Search Permission Sets
#'
#'
#' search_roles Search Roles
#'
#'
#' search_roles_with_user_count Search Roles with User Count
#'
#'
#' set_role_groups Update Role Groups
#'
#'
#' set_role_users Update Role Users
#'
#'
#' update_model_set Update Model Set
#'
#'
#' update_permission_set Update Permission Set
#'
#'
#' update_role Update Role
#'
#' }
#'
#' @export
RoleApi <- R6::R6Class(
  'RoleApi',
  public = list(
    userAgent = "R-SDK",
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    all_model_sets = function(fields, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`fields`)) {
        queryParams['fields'] <- fields
      }

      urlPath <- "/model_sets"
      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- ModelSet$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- ModelSet$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    all_permission_sets = function(fields, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`fields`)) {
        queryParams['fields'] <- fields
      }

      urlPath <- "/permission_sets"
      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- PermissionSet$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- PermissionSet$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    all_permissions = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      urlPath <- "/permissions"
      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- Permission$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- Permission$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    all_roles = function(fields, ids, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`fields`)) {
        queryParams['fields'] <- fields
      }

      if (!missing(`ids`)) {
        queryParams['ids'] <- ids
      }

      urlPath <- "/roles"
      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- Role$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- Role$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    create_model_set = function(body, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`body`)) {
        body <- `body`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/model_sets"
      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- ModelSet$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- ModelSet$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    create_permission_set = function(body, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`body`)) {
        body <- `body`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/permission_sets"
      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- PermissionSet$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- PermissionSet$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    create_role = function(body, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`body`)) {
        body <- `body`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/roles"
      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- Role$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- Role$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    delete_model_set = function(model_set_id, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      urlPath <- "/model_sets/{model_set_id}"
      if (!missing(`model_set_id`)) {
        urlPath <- gsub(paste0("\\{", "model_set_id", "\\}"), `model_set_id`, urlPath)
      }

      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "DELETE",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- Character$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- Character$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    delete_permission_set = function(permission_set_id, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      urlPath <- "/permission_sets/{permission_set_id}"
      if (!missing(`permission_set_id`)) {
        urlPath <- gsub(paste0("\\{", "permission_set_id", "\\}"), `permission_set_id`, urlPath)
      }

      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "DELETE",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- Character$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- Character$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    delete_role = function(role_id, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      urlPath <- "/roles/{role_id}"
      if (!missing(`role_id`)) {
        urlPath <- gsub(paste0("\\{", "role_id", "\\}"), `role_id`, urlPath)
      }

      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "DELETE",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- Character$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- Character$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    model_set = function(model_set_id, fields, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`fields`)) {
        queryParams['fields'] <- fields
      }

      urlPath <- "/model_sets/{model_set_id}"
      if (!missing(`model_set_id`)) {
        urlPath <- gsub(paste0("\\{", "model_set_id", "\\}"), `model_set_id`, urlPath)
      }

      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- ModelSet$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- ModelSet$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    permission_set = function(permission_set_id, fields, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`fields`)) {
        queryParams['fields'] <- fields
      }

      urlPath <- "/permission_sets/{permission_set_id}"
      if (!missing(`permission_set_id`)) {
        urlPath <- gsub(paste0("\\{", "permission_set_id", "\\}"), `permission_set_id`, urlPath)
      }

      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- PermissionSet$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- PermissionSet$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    role = function(role_id, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      urlPath <- "/roles/{role_id}"
      if (!missing(`role_id`)) {
        urlPath <- gsub(paste0("\\{", "role_id", "\\}"), `role_id`, urlPath)
      }

      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- Role$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- Role$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    role_groups = function(role_id, fields, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`fields`)) {
        queryParams['fields'] <- fields
      }

      urlPath <- "/roles/{role_id}/groups"
      if (!missing(`role_id`)) {
        urlPath <- gsub(paste0("\\{", "role_id", "\\}"), `role_id`, urlPath)
      }

      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- Group$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- Group$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    role_users = function(role_id, fields, direct_association_only, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`fields`)) {
        queryParams['fields'] <- fields
      }

      if (!missing(`direct_association_only`)) {
        queryParams['direct_association_only'] <- direct_association_only
      }

      urlPath <- "/roles/{role_id}/users"
      if (!missing(`role_id`)) {
        urlPath <- gsub(paste0("\\{", "role_id", "\\}"), `role_id`, urlPath)
      }

      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- User$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- User$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    search_model_sets = function(fields, limit, offset, sorts, id, name, all_access, built_in, filter_or, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`fields`)) {
        queryParams['fields'] <- fields
      }

      if (!missing(`limit`)) {
        queryParams['limit'] <- limit
      }

      if (!missing(`offset`)) {
        queryParams['offset'] <- offset
      }

      if (!missing(`sorts`)) {
        queryParams['sorts'] <- sorts
      }

      if (!missing(`id`)) {
        queryParams['id'] <- id
      }

      if (!missing(`name`)) {
        queryParams['name'] <- name
      }

      if (!missing(`all_access`)) {
        queryParams['all_access'] <- all_access
      }

      if (!missing(`built_in`)) {
        queryParams['built_in'] <- built_in
      }

      if (!missing(`filter_or`)) {
        queryParams['filter_or'] <- filter_or
      }

      urlPath <- "/model_sets/search"
      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- ModelSet$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- ModelSet$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    search_permission_sets = function(fields, limit, offset, sorts, id, name, all_access, built_in, filter_or, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`fields`)) {
        queryParams['fields'] <- fields
      }

      if (!missing(`limit`)) {
        queryParams['limit'] <- limit
      }

      if (!missing(`offset`)) {
        queryParams['offset'] <- offset
      }

      if (!missing(`sorts`)) {
        queryParams['sorts'] <- sorts
      }

      if (!missing(`id`)) {
        queryParams['id'] <- id
      }

      if (!missing(`name`)) {
        queryParams['name'] <- name
      }

      if (!missing(`all_access`)) {
        queryParams['all_access'] <- all_access
      }

      if (!missing(`built_in`)) {
        queryParams['built_in'] <- built_in
      }

      if (!missing(`filter_or`)) {
        queryParams['filter_or'] <- filter_or
      }

      urlPath <- "/permission_sets/search"
      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- PermissionSet$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- PermissionSet$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    search_roles = function(fields, limit, offset, sorts, id, name, built_in, filter_or, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`fields`)) {
        queryParams['fields'] <- fields
      }

      if (!missing(`limit`)) {
        queryParams['limit'] <- limit
      }

      if (!missing(`offset`)) {
        queryParams['offset'] <- offset
      }

      if (!missing(`sorts`)) {
        queryParams['sorts'] <- sorts
      }

      if (!missing(`id`)) {
        queryParams['id'] <- id
      }

      if (!missing(`name`)) {
        queryParams['name'] <- name
      }

      if (!missing(`built_in`)) {
        queryParams['built_in'] <- built_in
      }

      if (!missing(`filter_or`)) {
        queryParams['filter_or'] <- filter_or
      }

      urlPath <- "/roles/search"
      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- Role$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- Role$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    search_roles_with_user_count = function(fields, limit, offset, sorts, id, name, built_in, filter_or, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`fields`)) {
        queryParams['fields'] <- fields
      }

      if (!missing(`limit`)) {
        queryParams['limit'] <- limit
      }

      if (!missing(`offset`)) {
        queryParams['offset'] <- offset
      }

      if (!missing(`sorts`)) {
        queryParams['sorts'] <- sorts
      }

      if (!missing(`id`)) {
        queryParams['id'] <- id
      }

      if (!missing(`name`)) {
        queryParams['name'] <- name
      }

      if (!missing(`built_in`)) {
        queryParams['built_in'] <- built_in
      }

      if (!missing(`filter_or`)) {
        queryParams['filter_or'] <- filter_or
      }

      urlPath <- "/roles/search/with_user_count"
      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- RoleSearch$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- RoleSearch$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    set_role_groups = function(role_id, body, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`body`)) {
        body <- `body`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/roles/{role_id}/groups"
      if (!missing(`role_id`)) {
        urlPath <- gsub(paste0("\\{", "role_id", "\\}"), `role_id`, urlPath)
      }

      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "PUT",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- Group$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- Group$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    set_role_users = function(role_id, body, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`body`)) {
        body <- `body`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/roles/{role_id}/users"
      if (!missing(`role_id`)) {
        urlPath <- gsub(paste0("\\{", "role_id", "\\}"), `role_id`, urlPath)
      }

      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "PUT",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- User$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- User$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    update_model_set = function(model_set_id, body, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`body`)) {
        body <- `body`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/model_sets/{model_set_id}"
      if (!missing(`model_set_id`)) {
        urlPath <- gsub(paste0("\\{", "model_set_id", "\\}"), `model_set_id`, urlPath)
      }

      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "PATCH",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- ModelSet$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- ModelSet$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    update_permission_set = function(permission_set_id, body, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`body`)) {
        body <- `body`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/permission_sets/{permission_set_id}"
      if (!missing(`permission_set_id`)) {
        urlPath <- gsub(paste0("\\{", "permission_set_id", "\\}"), `permission_set_id`, urlPath)
      }

      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "PATCH",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- PermissionSet$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- PermissionSet$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    },
    update_role = function(role_id, body, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- character()

      if (!missing(`body`)) {
        body <- `body`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/roles/{role_id}"
      if (!missing(`role_id`)) {
        urlPath <- gsub(paste0("\\{", "role_id", "\\}"), `role_id`, urlPath)
      }

      resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "PATCH",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)
      
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
	data <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"),simplifyVector = FALSE)
	if (is.null(names(data))) {
	  returnObjects <- lapply(data, function(x) {
	    returnObject <- Role$new()
	    #returnObject$fromJSON(jsonlite::toJSON(x, auto_unbox = FALSE))
	    returnObject$fromJSONObject(x)
	    returnObject
	  })
	  Response$new(returnObjects, resp)
	} else {
	  returnObject <- Role$new()
	  #result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
	  result <- returnObject$fromJSONObject(data)
	  Response$new(returnObject, resp)
	}
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        Response$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        Response$new("API server error", resp)
      }

    }
  )
)
looker/lookr documentation built on Jan. 15, 2024, 2:49 a.m.