R/projects.R

Defines functions uo_get_role_assignments_per_user_list uo_get_project_usage_get uo_put_service_users_token uo_delete_service_users_delete uo_patch_service_users_update uo_get_service_users_get uo_post_service_users_create uo_get_service_users_list uo_delete_request_schedules_delete uo_patch_request_schedules_update uo_get_request_schedules_get uo_post_request_schedules_create uo_get_request_schedules_list uo_delete_roles_delete uo_patch_roles_update uo_get_roles_get uo_post_roles_create uo_get_roles_list uo_delete_role_assignments_delete uo_get_role_assignments_get uo_post_role_assignments_create uo_get_projects_resource_usage uo_delete_batch_pipeline_requests_delete uo_get_batch_pipeline_requests_get uo_post_batch_pipeline_requests_batch_delete uo_post_batch_pipeline_requests_batch_get uo_post_batch_pipeline_requests_create uo_get_batch_pipeline_requests_list uo_post_pipeline_requests_create uo_get_pipeline_object_environment_variables_list uo_delete_pipeline_objects_delete uo_patch_pipeline_objects_update uo_get_pipeline_objects_get uo_get_pipeline_object_attachments_destination_get uo_post_pipeline_objects_create uo_get_pipeline_objects_list uo_get_pipeline_audit_events_list uo_delete_pipeline_object_attachments_delete uo_get_pipeline_object_attachments_get uo_post_pipeline_object_attachments_create uo_get_pipeline_object_attachments_list uo_delete_pipelines_delete uo_patch_pipelines_update uo_get_pipelines_get uo_post_pipelines_create uo_get_pipelines_list uo_get_metrics_get uo_post_projects_log_list uo_delete_project_environment_variables_delete uo_patch_project_environment_variables_update uo_get_project_environment_variables_get uo_post_project_environment_variables_create uo_get_project_environment_variables_list uo_get_revisions_file_download uo_get_revisions_get uo_post_revisions_file_upload uo_get_revisions_list uo_delete_batch_deployment_requests_delete uo_get_batch_deployment_requests_get uo_post_batch_deployment_requests_batch_delete uo_post_batch_deployment_requests_batch_get uo_post_batch_deployment_requests_create uo_get_batch_deployment_requests_list uo_post_deployment_requests_create uo_delete_version_environment_variables_delete uo_patch_version_environment_variables_update uo_get_version_environment_variables_get uo_post_version_environment_variables_create uo_get_version_environment_variables_list uo_post_version_environment_variables_copy uo_get_builds_get uo_get_builds_list uo_delete_versions_delete uo_patch_versions_update uo_get_versions_get uo_post_versions_create uo_get_versions_list uo_delete_deployment_environment_variables_delete uo_patch_deployment_environment_variables_update uo_get_deployment_environment_variables_get uo_post_deployment_environment_variables_create uo_get_deployment_environment_variables_list uo_post_deployment_environment_variables_copy uo_get_deployment_audit_events_list uo_delete_deployments_delete uo_patch_deployments_update uo_get_deployments_get uo_post_deployments_create uo_get_deployments_list uo_delete_blobs_delete uo_get_blobs_get uo_post_blobs_create uo_get_blobs_list uo_get_project_audit_events_list uo_delete_projects_delete uo_patch_projects_update uo_get_projects_get uo_get_projects

# (autogenerated content from swagger API)

#' List projects
#'
#'
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return list of projects
#' @export
uo_get_projects <- function(UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects")
    tk <- check_ubiobstoken(UBIOPS_TOKEN)
    h  <- create_headers(tk)
    res <- httr::GET(url=endpoint,h)
    httr::stop_for_status(res)
    httr::content(res)
}


#' Get details of a project
#'
#'
#'  ### Description
#'  Get the details of a single project. The user making the request must have appropriate permissions.
#'
#'  ### Response Structure
#'  Details of a project
#'  - `id`: Unique identifier for the project (UUID)
#'
#'  - `name`: Name of the project
#'
#'  - `creation_date`: Time the project was created
#'
#'  - `organization_name`: Name of the organization in which the project is created
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "e988ddc0-3ef1-42d2-ab30-9f810a5e7063",
#'    "name": "project-1",
#'    "creation_date": "2018-10-26",
#'    "organization_name": "organization-1"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_projects_get <- function(project_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Update a project name
#'
#'
#'  ### Description
#'  Update the name of a single project. The user making the request must have appropriate permissions.
#'
#'  ### Optional Parameters
#'  - `name`: New project name
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "project-name-example"
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of a project
#'  - `id`: Unique identifier for the project (UUID)
#'
#'  - `name`: Name of the project
#'
#'  - `creation_date`: Time the project was created
#'
#'  - `organization_name`: Name of the organization in which the project is created
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "e988ddc0-3ef1-42d2-ab30-9f810a5e7063",
#'    "name": "project-1",
#'    "creation_date": "2018-10-26",
#'    "organization_name": "organization-1"
#'  }
#'  ```
#'
#' @param project_name old name
#' @param name new name
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_patch_projects_update <- function(project_name, name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-c("name"=name)
    res <- httr::PATCH(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
} ### TODO, THIS DOESN'T WORK YET.


#' Delete a project
#'
#'
#'  ### Description
#'  Delete a project. The user making the request must have appropriate permissions.
#'  **When project is deleted, all the deployments and pipelines defined in it are also deleted.**
#'
#' @param project_name name of your project
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_projects_delete <- function(project_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List audit events in a project
#'
#'
#'  ### Description
#'  List all audit events in a project including all objects
#'
#'  ### Optional Parameters
#'  The following parameters should be given as query parameters:
#'  - `action`: Type of action. It can be one of: create, update, delete, info.
#'  - `limit`: The maximum number of audit events given back, default is 50
#'  - `offset`: The number which forms the starting point of the audit events given back. If offset equals 2, then the first 2 events will be omitted from the list.
#'
#'  ### Response Structure
#'  A list of details of the audit events in the project
#'  - `id`: Unique identifier for the audit event (UUID)
#'  - `date`: The date when the action was performed
#'  - `action`: Type of action. It can be one of: create, update, delete, info. *info* action denotes that the action does not fall into create, update or delete categories.
#'  - `user`: Email of the user who performed the action
#'  - `event`: Description of the event
#'  - `object_type`: Type of the object on which the action was performed
#'  - `object_name`: Name of the object on which the action was performed. If the object is deleted at the time of listing audit events, this field is empty.
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "54c1ea23-5773-4821-8fd7-1b577cc301bc",
#'      "date": "2020-05-23T11:53:02.873+00:00",
#'      "action": "create",
#'      "user": "user@example.com",
#'      "event": "Created project test-project",
#'      "object_type": "project",
#'      "object_name": "test-project"
#'    },
#'    {
#'      "id": "764e254c-7402-4445-ac79-009d08b21caa",
#'      "date": "2020-05-23T11:57:20.072+00:00",
#'      "action": "create",
#'      "user": "user@example.com",
#'      "event": "Created deployment deployment-1",
#'      "object_type": "deployment",
#'      "object_name": "deployment-1"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param action descriptionhere
#' @param limit descriptionhere
#' @param offset descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_project_audit_events_list <- function(
    project_name,
    action=NULL,
    limit=NULL,
    offset=NULL, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/audit")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
   ## you need to url encode these actions.
    res <- httr::GET(url=endpoint,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
} # TODO this one I don't have permissions for.

#' List blobs
#'
#'
#'  ### Description
#'  List all blobs in a project
#'
#'  ### Optional Parameters
#'  These parameters should be given as GET parameters.
#'  - `range`: Number of blobs to be returned. It may be a positive or a negative value. If it is positive, blobs uploaded starting from the creation_date towards the present time are returned. Otherwise, blobs uploaded towards the past are returned. The default value is -50.
#'  - `creation_date`: Get the blobs uploaded starting from this date. If it is not provided, the uploaded blobs are returned according to the *range* parameter. It should be provided in year-month-day hour:minute:second format.
#'
#'  ### Response Structure
#'  A list of details of the blobs in the project
#'   - `id`: Unique identifier for the blob (UUID)
#'   - `creation_date`: Time the blob was created
#'   - `filename`: Original filename of the blob
#'   - `size`: Size of the uploaded blob in bytes
#'   - `ttl`: Time to live of the blob in seconds
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "ecb39626-2a14-4224-a57a-592a51567e17",
#'      "creation_date": "2020-05-13T14:39:50.149+00:00",
#'      "filename": "original-filename.jpg",
#'      "size": 562,
#'      "ttl": 12338
#'    },
#'    {
#'      "id": "f629a052-a827-44d9-97cf-3902504edc79",
#'      "creation_date": "2020-05-18T08:35:18.796+00:00",
#'      "filename": "original-filename2.jpg",
#'      "size": 3439,
#'      "ttl": 259200
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param range descriptionhere
#' @param creation_date descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_blobs_list <- function(project_name, range, creation_date, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/blobs")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    res <- httr::GET(url=endpoint,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
} ## TODO URL encode the argumetns

#' Upload a blob
#'
#'
#'  ### Description
#'  Upload a blob to a project. The returned blob_id may be passed in a deployment or pipeline request as input.
#'
#'  The uploaded blob file can be retrieved by passing the blob_id as well.
#'
#'  ### Optional Parameters
#'  These parameters should be given in the header.
#'  - `blob-ttl`: The Blob-TTL parameter designates the time to live of the blob in seconds. The default value is 259200 seconds (or 72 hours), the minimum value is 900 seconds and the maximum value is 259200 seconds.
#'
#'  ### Response Structure
#'  The details of the uploaded blob
#'  - `id`: Unique identifier for the blob (UUID)
#'  - `creation_date`: Time the blob was created
#'  - `filename`: Original filename of the blob
#'  - `size`: Size of the uploaded blob in bytes
#'  - `ttl`: Time to live of the blob in seconds
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "b58fb853-9311-4583-9688-abed61830abc",
#'    "creation_date": "2020-05-18T11:26:57.904+00:00",
#'    "filename": "original-filename.jpg",
#'    "size": 3439,
#'    "ttl": 259200
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param file descriptionhere
#' @param blob_ttl descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_blobs_create <- function(project_name, file, blob_ttl, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/blobs")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get a blob
#'
#'
#'  ### Description
#'  Download a blob file in a project
#'
#'  ### Response Structure
#'  - `file`: Blob file
#'
#' @param project_name name of your project
#' @param blob_id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_blobs_get <- function(project_name, blob_id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/blobs/{blob_id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete a blob
#'
#'
#'  ### Description
#'  Delete a blob from a project
#'
#' @param project_name name of your project
#' @param blob_id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_blobs_delete <- function(project_name, blob_id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/blobs/{blob_id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List deployments in project
#'
#'
#'  ### Description
#'  Deployments can be filtered according to the labels they have by giving labels as a query parameter. Deployments that have at least one of the labels on which is filtered, are returned.
#'
#'  ### Optional Parameters
#'  - `labels`: Filter on labels of the deployment. Should be given in the format 'label:label_value'. Separate multiple label-pairs with a comma (,). This parameter should be given as query parameter.
#'
#'  ### Response Structure
#'  A list of details of the deployments in the project
#'  - `id`: Unique identifier for the deployment (UUID)
#'  - `name`: Name of the deployment
#'  - `project`: Project name in which the deployment is defined
#'  - `input_type`: Type of the input of the deployment
#'  - `output_type`: Type of the output of the deployment
#'  - `input_fields`: The list of deployment input fields containing name and data_type. It is empty in case of plain input type deployments.
#'  - `output_fields`: The list of deployment output fields containing name and data_type. It is empty in case of plain output type deployments.
#'  - `description`: Description of the deployment
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'  - `creation_date`: The date when the deployment was created
#'  - `last_updated`: The date when the deployment was last updated
#'  - `number_of_versions`: Number of versions that this deployment has
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "903ccd12-81d1-46e1-9ac9-b9d70af118de",
#'      "name": "deployment-1",
#'      "project": "project-1",
#'      "description": "Temperature deployment",
#'      "input_type": "structured",
#'      "output_type": "structured",
#'      "input_fields": [
#'        {
#'          "name": "input-field-1",
#'          "data_type": "int"
#'        },
#'        {
#'          "name": "input-field-2",
#'          "data_type": "double"
#'        }
#'      ],
#'      "output_fields": [
#'        {
#'          "name": "output-field",
#'          "data_type": "double"
#'        }
#'      ],
#'      "labels": {
#'        "type": "deployment"
#'      },
#'      "creation_date": "2020-05-12T16:23:15.456812Z",
#'      "last_updated": "2020-06-22T18:04:76.123754Z",
#'      "number_of_versions": 1
#'    },
#'    {
#'      "id": "5f4e942f-d5b8-4d62-99b2-870c15a82127",
#'      "name": "deployment-2",
#'      "project": "project-1",
#'      "description": "Deployment two",
#'      "input_type": "structured",
#'      "output_type": "plain",
#'      "input_fields": [
#'        {
#'          "name": "input-field",
#'          "data_type": "int"
#'        }
#'      ],
#'      "output_fields": [],
#'      "labels": {
#'        "type": "deployment"
#'      },
#'      "creation_date": "2020-03-24T09:43:51.791253Z",
#'      "last_updated": "2020-05-19T11:52:21.163270Z",
#'      "number_of_versions": 2
#'    },
#'    {
#'      "id": "bd3fae9d-aeec-4cf3-8ef0-5f9224d41904",
#'      "name": "deployment-3",
#'      "description": "",
#'      "project": "project-1",
#'      "input_type": "plain",
#'      "output_type": "plain",
#'      "input_fields": [],
#'      "output_fields": [],
#'      "creation_date": "2020-06-18T08:32:14.876451Z",
#'      "last_updated": "2020-06-19T10:52:23.124784Z",
#'      "number_of_versions": 1
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param labels descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_deployments_list <- function(project_name, labels=NULL, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
   # labels as query parameters too.
    res <- httr::GET(url=endpoint,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Create a deployment
#'
#'
#'  ### Description
#'  Create a deployment by defining the input/output type and input/output fields. In case of **plain** type of input or output, input and output fields should not be given or passed as an empty list.
#'
#'  Possible data types for the input and output fields are:
#'  - **int**: integer
#'  - **string**: string
#'  - **double**: double precision floating point
#'  - **bool**: boolean value (False/True)
#'  - **timestamp**: timestamp
#'  - **array_int**: an array of integers
#'  - **array_double**: an array of double precision floating points
#'  - **array_string**: an array of strings
#'  - **blob**: a blob field. This type of field can be used to pass blobs to the deployment. In deployment and pipeline requests, the uuid of a previously uploaded blob must be provided for this field.
#'
#'  ### Required Parameters
#'  - `name`: Name of the deployment. It is unique within a project.
#'  - `input_type`: Type of the input of the deployment. It can be either structured or plain.
#'  - `output_type`: Type of the output of the deployment. It can be either structured or plain.
#'  - `input_fields`: The list of required deployment input fields. It must contain the fields: name and data_type. The name of an input field is unique for a deployment.
#'  - `output_fields`: The list of required deployment output fields. It must contain the fields: name and data_type. The name of an output field is unique for a deployment.
#'
#'  ### Optional Parameters
#'  - `description`: Description of the deployment
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'
#'  #### Request Examples
#'  A deployment with structured input and output type
#'  ```
#'  {
#'    "name": "deployment-1",
#'    "input_type": "structured",
#'    "output_type": "structured",
#'    "input_fields": [
#'      {
#'        "name": "input-field-1",
#'        "data_type": "int"
#'      },
#'      {
#'        "name": "input-field-2",
#'        "data_type": "double"
#'      }
#'    ],
#'    "output_fields": [
#'      {
#'        "name": "output-field",
#'        "data_type": "double"
#'      }
#'    ]
#'  }
#'  ```
#'
#'  A deployment with plain input type
#'  ```
#'  {
#'    "name": "deployment-1",
#'    "description": "Deployment one"
#'    "input_type": "plain",
#'    "output_type": "structured",
#'    "output_fields": [
#'      {
#'        "name": "output-field",
#'        "data_type": "double"
#'      }
#'    ]
#'  }
#'  ```
#'
#'  A deployment with plain input and output type
#'  ```
#'  {
#'    "name": "deployment-1",
#'    "input_type": "plain",
#'    "output_type": "plain"
#'    "labels": {
#'      "type": "deployment"
#'    }
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the created deployment
#'  - `id`: Unique identifier for the deployment (UUID)
#'  - `name`: Name of the deployment
#'  - `project`: Project name in which the deployment is created
#'  - `input_type`: Type of the input of the deployment
#'  - `output_type`: Type of the output of the deployment
#'  - `input_fields`: The list of deployment input fields containing name and data_type
#'  - `output_fields`: The list of deployment output fields containing name and data_type
#'  - `description`: Description of the deployment
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'  - `creation_date`: The date when the deployment was created
#'  - `last_updated`: The date when the deployment was last updated
#'  - `number_of_versions`: Number of versions that this deployment has
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "903ccd12-81d1-46e1-9ac9-b9d70af118de",
#'    "name": "deployment-1",
#'    "project": "project-1",
#'    "description": "",
#'    "input_type": "structured",
#'    "output_type": "structured",
#'    "input_fields": [
#'      {
#'        "name": "input-field-1",
#'        "data_type": "int"
#'      },
#'      {
#'        "name": "input-field-2",
#'        "data_type": "double"
#'      }
#'    ],
#'    "output_fields": [
#'      {
#'        "name": "output-field",
#'        "data_type": "double"
#'      }
#'    ],
#'    "labels": {
#'      "type": "deployment"
#'    },
#'    "creation_date": "2020-06-18T08:32:14.876451Z",
#'    "last_updated": "2020-06-18T08:32:14.876451Z",
#'    "number_of_versions": 0
#'  }
#'  ```
#'
#' @param project_name projectname
#' @param name A name for this deployment
#' @param description Free text description, can be emtpy.
#' @param input_type,output_type either structured or plain
#' @param input_fields,output_fields supply a dataframe with two columns: name and data_type where datatype is one of int, string, double, bool, timestamp, array_int, array_double, array_string or blob
#' @param labels Supply a list with named values. For instance list("boundaries"="flat")
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return result of deployment
#' @export
uo_post_deployments_create <- function(project_name, name, description, input_type, output_type, input_fields, output_fields, labels, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-list(
        name=name,
        input_type=input_type,
        output_type=output_type,
        input_fields=valid_fields(input_fields),
        output_fields=valid_fields(output_fields)
    )
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get details of deployment
#'
#'
#'  ### Description
#'  Retrieve details of a single deployment in a project
#'
#'  ### Response Structure
#'  Details of a deployment
#'  - `id`: Unique identifier for the deployment (UUID)
#'  - `name`: Name of the deployment
#'  - `project`: Project name in which the deployment is defined
#'  - `input_type`: Type of the input of the deployment
#'  - `output_type`: Type of the output of the deployment
#'  - `input_fields`: The list of deployment input fields containing name and data_type
#'  - `output_fields`: The list of deployment output fields containing name and data_type
#'  - `description`: Description of the deployment
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'  - `creation_date`: The date when the deployment was created
#'  - `last_updated`: The date when the deployment was last updated
#'  - `number_of_versions`: Number of versions that this deployment has
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "903ccd12-81d1-46e1-9ac9-b9d70af118de",
#'    "name": "deployment-1",
#'    "project": "project-1",
#'    "description": "",
#'    "input_type": "structured",
#'    "output_type": "structured",
#'    "input_fields": [
#'      {
#'        "name": "input-field-1",
#'        "data_type": "int"
#'      },
#'      {
#'        "name": "input-field-2",
#'        "data_type": "double"
#'      }
#'    ],
#'    "output_fields": [
#'      {
#'        "name": "output-field",
#'        "data_type": "double"
#'      }
#'    ],
#'    "labels": {
#'      "type": "deployment"
#'    },
#'    "creation_date": "2020-06-18T08:32:14.876451Z",
#'    "last_updated": "2020-06-19T10:52:23.124784Z",
#'    "number_of_versions": 2
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_deployments_get <- function(project_name, deployment_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Update a deployment
#'
#'
#'  ### Description
#'  Update a deployment. It is only possible to update the name, description and labels fields. When updating labels, the labels will replace the existing value for labels.
#'
#'  ### Optional Parameters
#'  - `name`: New name for the deployment
#'  - `description`: New description for the deployment
#'  - `labels`: New dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label. The new labels will replace the existing value for labels.
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "new-deployment-name"
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the updated deployment
#'  - `id`: Unique identifier for the deployment (UUID)
#'  - `name`: Name of the deployment
#'  - `project`: Project name in which the deployment is defined
#'  - `input_type`: Type of the input of the deployment
#'  - `output_type`: Type of the output of the deployment
#'  - `input_fields`: The list of deployment input fields containing name and data_type
#'  - `output_fields`: The list of deployment output fields containing name and data_type
#'  - `description`: Description of the deployment
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'  - `creation_date`: The date when the deployment was created
#'  - `last_updated`: The date when the deployment was last updated
#'  - `number_of_versions`: Number of versions that this deployment has
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "903ccd12-81d1-46e1-9ac9-b9d70af118de",
#'    "name": "new-deployment-name",
#'    "project": "project-1",
#'    "description": "New deployment description",
#'    "input_type": "structured",
#'    "output_type": "structured",
#'    "input_fields": [
#'      {
#'        "name": "input-field-1",
#'        "data_type": "int"
#'      },
#'      {
#'        "name": "input-field-2",
#'        "data_type": "double"
#'      }
#'    ],
#'    "output_fields": [
#'      {
#'        "name": "output-field",
#'        "data_type": "double"
#'      }
#'    ],
#'    "labels": {
#'      "type": "deployment"
#'    },
#'    "creation_date": "2020-06-18T08:32:14.876451Z",
#'    "last_updated": "2020-06-19T10:52:23.124784Z",
#'    "number_of_versions": 2
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param name New name for the deployment
#' @param description New description for the deployment
#' @param labels new labels
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_patch_deployments_update <- function(project_name, deployment_name, name=NULL, description=NULL, labels=NULL, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-list(
        name=name, description=description, labels=labels,
    )

    res <- httr::PATCH(url=endpoint,body=remove_nulls_from_list(body),encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete a deployment
#'
#'
#'  ### Description
#'  Delete a deployment. If any of the versions of the deployment are referenced in a pipeline, the deployment cannot be deleted.
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_deployments_delete <- function(project_name, deployment_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    res <- httr::DELETE(url=endpoint,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List audit events for a deployment
#'
#'
#'  ### Description
#'  List all audit events for a deployment including versions
#'
#'  ### Optional Parameters
#'  The following parameters should be given as query parameters:
#'  - `action`: Type of action. It can be one of: create, update, delete, info.
#'  - `limit`: The maximum number of audit events given back, default is 50
#'  - `offset`: The number which forms the starting point of the audit events given back. If offset equals 2, then the first 2 events will be omitted from the list.
#'
#'  ### Response Structure
#'  A list of details of the audit events for a deployment
#'  - `id`: Unique identifier for the audit event (UUID)
#'  - `date`: The date when the action was performed
#'  - `action`: Type of action. It can be one of: create, update, delete, info. *info* action denotes that the action does not fall into create, update or delete categories.
#'  - `user`: Email of the user who performed the action
#'  - `event`: Description of the event
#'  - `object_type`: Type of the object on which the action was performed
#'  - `object_name`: Name of the object on which the action was performed. If the object is deleted at the time of listing audit events, this field is empty.
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "25750859-e082-44df-bde9-cd85ca3f869c",
#'      "date": "2020-10-23T12:03:55.675+00:00",
#'      "action": "delete",
#'      "user": "user@example.com",
#'      "event": "Deleted environment variable ENV_VAR for deployment deployment-1",
#'      "object_type": "deployment",
#'      "object_name": "deployment-1"
#'    },
#'    {
#'      "id": "ce81814d-b00c-4094-a483-814afdb80875",
#'      "date": "2020-10-23T12:04:28.645+00:00",
#'      "action": "create",
#'      "user": "user@example.com",
#'      "event": "Created version v1 for deployment deployment-1",
#'      "object_type": "deployment",
#'      "object_name": "audit-deployment"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param action set a possible action
#' @param limit set a possible limit
#' @param offset set a possible offset
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return a list of results
#' @export
uo_get_deployment_audit_events_list <- function(project_name, deployment_name, action=NULL, limit=NULL, offset=NULL, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/audit")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    # query encode
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Copy deployment environment variable
#'
#'
#'  ### Description
#'  Copy existing environment variables from a source object to the deployment. Variables of the deployment with the same name as ones from the source object will be overwritten with the new value. Only the copied variables are returned.
#'
#'  ### Required Parameters
#'  - `source_deployment`: The name of the deployment from which the variables will be copied
#'
#'  ### Optional Parameters
#'  - `source_version`: The version of the object from which the variables will be copied
#'
#'  #### Request Examples
#'  Copy the environment variables from a deployment
#'  ```
#'  {
#'    "source_deployment": "example-deployment"
#'  }
#'  ```
#'
#'  Copy the environment variables from a version
#'  ```
#'  {
#'    "source_deployment": "example-deployment",
#'    "source_version": "v1"
#'  }
#'  ```
#'
#'  ### Response Structure
#'  A list of the copied variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'  - `inheritance_type`: Type of parent object that this variable is inherited from. Will be null for copied environment variables.
#'  - `inheritance_name`: Name of the parent object that this variable is inherited from. Will be null for copied environment variables.
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
#'      "name": "deployment_specific_variable",
#'      "value": "some_value",
#'      "secret": false,
#'      "inheritance_type": null,
#'      "inheritance_name": null
#'    },
#'    {
#'      "id": "4c15a27e-25ea-4be0-86c7-f4790389d061",
#'      "name": "database_schema",
#'      "value": "public",
#'      "secret": false,
#'      "inheritance_type": null,
#'      "inheritance_name": null
#'    },
#'    {
#'      "id": "06c2c8be-507e-4fae-981d-54e94f22dab0",
#'      "name": "database_password",
#'      "value": null,
#'      "secret": true,
#'      "inheritance_type": null,
#'      "inheritance_name": null
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param source_deployment descriptionhere
#' @param source_version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_deployment_environment_variables_copy <- function(project_name, deployment_name, source_deployment, source_version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/copy-environment-variables")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List deployment environment variables
#'
#'
#'  ### Description
#'  List the environment variables defined for the deployment. Includes environment variables defined at project level.
#'
#'  ### Response Structure
#'  A list of variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'  - `inheritance_type`: Type of parent object that this variable is inherited from - can be `project` or null if the variable was defined for the deployment directly
#'  - `inheritance_name`: Name of the parent object that this variable is inherited from - will be null if the variable was defined for the deployment directly
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "4c15a27e-25ea-4be0-86c7-f4790389d061",
#'      "name": "database_schema",
#'      "value": "public",
#'      "secret": false,
#'      "inheritance_type": null,
#'      "inheritance_name": null
#'    },
#'    {
#'      "id": "06c2c8be-507e-4fae-981d-54e94f22dab0",
#'      "name": "database_password",
#'      "value": null,
#'      "secret": true,
#'      "inheritance_type": "project",
#'      "inheritance_name": "project_name"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_deployment_environment_variables_list <- function(project_name, deployment_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/environment-variables")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    res <- httr::GET(url=endpoint,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Create deployment environment variable
#'
#'
#'  ### Description
#'  Create an environment variable for the deployment. This variable will be inherited by all versions of this deployment. Variables inherited from the project can be shadowed by creating a variable with the same name.
#'
#'  ### Required Parameters
#'  - `name`: The name of the variable. The variable will have this name when accessed from your deployment code. The variable name should contain only letters and underscores, and not start or end with an underscore.
#'  - `value`: The value of the variable as a string. It may be an empty string ("").
#'  - `secret`: If this variable contains sensitive information, set this to true to hide it from other users.
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "deployment_variable_a",
#'    "value": "some_value",
#'    "secret": false
#'  }
#'  ```
#'
#'  ### Response Structure
#'  A list of variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'
#'  #### Response Examples
#'  ```
#'  {
#'  "id": "7c28a2be-507e-4fae-981d-54e94f22dab0",
#'  "name": "deployment_variable_a",
#'  "value": "some_value",
#'  "secret": false
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param name descriptionhere
#' @param value descriptionhere
#' @param secret descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_deployment_environment_variables_create <- function(project_name, deployment_name, name, value, secret, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/environment-variables")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    ## TODO encode name, value and secret into list.
    body<-data.frame(
        name, value, secret
    )
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get deployment environment variable
#'
#'
#'  ### Description
#'  Retrieve details of a deployment environment variable. This cannot be used to retrieve details of inherited variables.
#'
#'  ### Response Structure
#'  A list of variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "4c15a27e-25ea-4be0-86c7-f4790389d061",
#'      "name": "database_schema",
#'      "value": "public",
#'      "secret": false
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_deployment_environment_variables_get <- function(project_name, deployment_name, id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/environment-variables/{id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Update deployment environment variable
#'
#'
#'  ### Description
#'  Update an environment variable for the deployment. This cannot be used to update inherited variables; to change an inherited variable for a specific deployment you can create a variable with the same name for the deployment.
#'
#'  ### Required Parameters
#'  - `name`: The name of the variable. The variable will have this name when accessed from your deployment code. The variable name should contain only letters and underscores, and not start or end with an underscore.
#'  - `value`: The value of the variable as a string. It may be an empty string ("").
#'  - `secret`: If this variable contains sensitive information, set this to true to hide it from other users. Can be updated from false to true, but not from true to false (i.e. secrets will stay secrets).
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "deployment_variable_a",
#'    "value": "some new value",
#'    "secret": false
#'  }
#'  ```
#'
#'  ### Response Structure
#'  A list of variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "7c28a2be-507e-4fae-981d-54e94f22dab0",
#'    "name": "deployment_variable_a",
#'    "value": "some new value",
#'    "secret": false
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param id descriptionhere
#' @param name descriptionhere
#' @param value descriptionhere
#' @param secret descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_patch_deployment_environment_variables_update <- function(project_name, deployment_name, id, name, value, secret, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/environment-variables/{id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::PATCH(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete deployment environment variable
#'
#'
#'  ### Description
#'  Delete an environment variable of the deployment
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_deployment_environment_variables_delete <- function(project_name, deployment_name, id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/environment-variables/{id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List versions
#'
#'
#'  ### Description
#'  Versions can be filtered according to the labels they have by giving labels as a query parameter. Versions that have at least one of the labels on which is filtered, are returned.
#'
#'  ### Optional Parameters
#'  - `labels`: Filter on labels of the version. Should be given in the format 'label:label_value'. Separate multiple label-pairs with a comma (,). This parameter should be given as query parameter.
#'
#'  ### Response Structure
#'  A list of details of the versions
#'  - `id`: Unique identifier for the deployment (UUID)
#'  - `deployment`: Deployment name to which the version is associated
#'  - `version`: Version name
#'  - `description`: Description of the version
#'  - `language`: Language in which the version is provided
#'  - `status`: The status of the version
#'  - `active_revision`: UUID of the active revision of the version. If no deployment files have been uploaded yet, it is None.
#'  - `latest_build`: UUID of the latest build of the version. If no build has been triggered yet, it is None.
#'  - `memory_allocation`: Reserved memory usage for the version in MB
#'  - `maximum_instances`: Upper bound of number of versions running
#'  - `minimum_instances`: Lower bound of number of versions running
#'  - `maximum_idle_time`: Maximum time in seconds a version stays idle before it is stopped
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'  - `creation_date`: The date when the version was created
#'  - `last_updated`: The date when the version was last updated
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "4ae7d14b-4803-4e16-b96d-3b18caa4b605",
#'      "deployment": "deployment-1",
#'      "version": "version-1",
#'      "description": "",
#'      "language": "python3.8",
#'      "status": "available",
#'      "active_revision": "da27ef7c-aa3f-4963-a815-6ebf1865638e",
#'      "latest_build": "0f4a94c6-ec4c-4d1e-81d7-8f3e40471f75",
#'      "memory_allocation": 512,
#'      "maximum_instances": 4,
#'      "minimum_instances": 1,
#'      "maximum_idle_time": 10,
#'      "labels": {
#'        "type": "version"
#'      },
#'      "creation_date": "2020-06-18T08:32:14.876451Z",
#'      "last_updated": "2020-06-19T10:52:23.124784Z"
#'    },
#'    {
#'      "id": "24f6b80a-08c3-4d52-ac1a-2ea7e70f16a6",
#'      "deployment": "deployment-1",
#'      "version": "version-2",
#'      "description": "",
#'      "language": "r4.0",
#'      "status": "available",
#'      "active_revision": "a74662be-c938-4104-872a-8be1b85f64ff",
#'      "latest_build": "4534e479-ea2e-4161-876a-1d382191a031",
#'      "memory_allocation": 256,
#'      "maximum_instances": 5,
#'      "minimum_instances": 0,
#'      "maximum_idle_time": 10,
#'      "labels": {
#'        "type": "version"
#'      },
#'      "creation_date": "2020-05-12T16:23:15.456812Z",
#'      "last_updated": "2020-06-22T18:04:76.123754Z"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param labels descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_versions_list <- function(project_name, deployment_name, labels, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Create versions
#'
#'
#'  ### Description
#'  Create a version for a deployment
#'
#'  ### Required Parameters
#'  - `version`: Name of the version of the deployment
#'
#'  ### Optional Parameters
#'  - `language`: Language in which the version is provided. It can be python3.5, python3.6, python3.7, python3.8 or r4.0. The default value is python3.7.
#'  - `memory_allocation`: Reserved memory for the version in MB. This value determines the memory allocated to the version: it should to be enough to encompass the deployment file and all requirements that need to be installed. The default value is 2048. The minimum and maximum values are 256 and 32768 respectively.
#'  - `maximum_instances`: Upper bound of number of versions running. The default value is 5, the maximum value is 20. *Indicator of resource capacity:* if many deployment requests need to be handled in a short time, this number can be set higher to avoid long waiting times.
#'  - `minimum_instances`: Lower bound of number of versions running. The default value is 0. Set this value greater than 0 to always have a always running version.
#'  - `maximum_idle_time`: Maximum time in seconds a version stays idle before it is stopped. The default value is 300, the minimum value is 10 and the maximum value is 3600. A high value means that the version stays available longer. Sending requests to a running version means that it will be already initialized and thus take a shorter timer.
#'
#'  - `description`: Description for the version
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'
#'  If the time that a request takes does not matter, keep the default values.
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "version": "version-1",
#'    "language": "python3.8"
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "version": "version-1",
#'    "language": "r4.0",
#'    "memory_allocation": 512
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "version": "version-1",
#'    "maximum_instances": 4,
#'    "minimum_instances": 1
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the created version
#'  - `id`: Unique identifier for the deployment (UUID)
#'  - `deployment`: Deployment name to which the version is associated
#'  - `version`: Version name
#'  - `description`: Description of the version
#'  - `language`: Language in which the version is provided
#'  - `status`: The status of the version
#'  - `active_revision`: Active revision of the version. It is initialised as None since there are no deployment files uploaded for the version yet.
#'  - `latest_build`: Latest build of the version. It is initialised as None since no build is triggered for the version yet.
#'  - `memory_allocation`: Reserved memory for the version in MB
#'  - `maximum_instances`: Upper bound of number of versions running
#'  - `minimum_instances`: Lower bound of number of versions running
#'  - `maximum_idle_time`: Maximum time in seconds a version stays idle before it is stopped
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'  - `creation_date`: The date when the version was created
#'  - `last_updated`: The date when the version was last updated
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "4ae7d14b-4803-4e16-b96d-3b18caa4b605",
#'    "deployment": "deployment-1",
#'    "version": "version-1",
#'    "description": "",
#'    "language": "python3.8",
#'    "status": "unavailable",
#'    "active_revision": null,
#'    "latest_build": null,
#'    "memory_allocation": 512,
#'    "maximum_instances": 5,
#'    "minimum_instances": 0,
#'    "maximum_idle_time": 10,
#'    "labels": {
#'      "type": "version"
#'    },
#'    "creation_date": "2020-05-12T16:23:15.456812Z",
#'    "last_updated": "2020-05-12T16:23:15.456812Z"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param language descriptionhere
#' @param memory_allocation descriptionhere
#' @param maximum_instances descriptionhere
#' @param minimum_instances descriptionhere
#' @param maximum_idle_time descriptionhere
#' @param description descriptionhere
#' @param labels descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_versions_create <- function(project_name, deployment_name, version, language, memory_allocation, maximum_instances, minimum_instances, maximum_idle_time, description, labels, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get version
#'
#'
#'  ### Description
#'  Retrieve details of a version of a deployment in a project
#'
#'  ### Response Structure
#'  Details of a version
#'  - `id`: Unique identifier for the version (UUID)
#'  - `deployment`: Deployment name to which the version is associated
#'  - `version`: Version name
#'  - `description`: Description of the version
#'  - `language`: Language in which the version is provided
#'  - `status`: The status of the version
#'  - `active_revision`: UUID of the active revision of the version. If no deployment files have been uploaded yet, it is None.
#'  - `latest_build`: UUID of the latest build of the version. If no build has been triggered yet, it is None.
#'  - `memory_allocation`: Reserved memory for the version in MB
#'  - `maximum_instances`: Upper bound of number of deployment pods running in parallel
#'  - `minimum_instances`: Lower bound of number of deployment pods running in parallel
#'  - `maximum_idle_time`: Maximum time in seconds a version stays idle before it is stopped
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'  - `creation_date`: The date when the version was created
#'  - `last_updated`: The date when the version was last updated
#'  - `last_file_upload`: The date when a deployment file was last uploaded for the version
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "4ae7d14b-4803-4e16-b96d-3b18caa4b605",
#'    "deployment": "deployment-1",
#'    "version": "version-1",
#'    "description": "",
#'    "language": "python3.7",
#'    "status": "available",
#'    "active_revision": "a74662be-c938-4104-872a-8be1b85f64ff",
#'    "latest_build": "9f7fd6ec-53b7-41c6-949e-09efc2ee2d31",
#'    "memory_allocation": 512,
#'    "maximum_instances": 4,
#'    "minimum_instances": 1,
#'    "maximum_idle_time": 10,
#'    "labels": {
#'      "type": "version"
#'    },
#'    "creation_date": "2020-05-12T16:23:15.456812Z",
#'    "last_updated": "2020-06-22T18:04:76.123754Z",
#'    "last_file_uploaded": "2020-06-21T09:03:01.875391Z"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_versions_get <- function(project_name, deployment_name, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Update version
#'
#'
#'  ### Description
#'  Update a version of a deployment in a project. All necessary fields are validated again. When updating labels, the labels will replace the existing value for labels.
#'
#'  ### Optional Parameters
#'  - `version`: New name for the version
#'  - `memory_allocation`: New reserved memory for the version in MB
#'  - `maximum_instances`: New upper bound of number of versions running
#'  - `minimum_instances`: New lower bound of number of versions running
#'  - `maximum_idle_time`: New maximum time in seconds a version stays idle before it is stopped
#'  - `description`: New description for the version
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label. The new labels will replace the existing value for labels.
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "version": "new-version"
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "memory_allocation": 512,
#'    "maximum_instances": 4,
#'    "minimum_instances": 1
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the updated version
#'  - `id`: Unique identifier for the deployment (UUID)
#'  - `deployment`: Deployment name to which the version is associated
#'  - `version`: Version name
#'  - `description`: Description of the version
#'  - `language`: Language in which the version is provided
#'  - `status`: The status of the version
#'  - `active_revision`: UUID of the active revision of the version. If no deployment files have been uploaded yet, it is None.
#'  - `latest_build`: UUID of the latest build of the version. If no build has been triggered yet, it is None.
#'  - `memory_allocation`: Reserved memory for the version in MB
#'  - `maximum_instances`: Upper bound of number of versions running
#'  - `minimum_instances`: Lower bound of number of versions running
#'  - `maximum_idle_time`: Maximum time in seconds a version stays idle before it is stopped
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'  - `creation_date`: The date when the version was created
#'  - `last_updated`: The date when the version was last updated
#'  - `last_file_upload`: The date when a deployment file was last uploaded for the version
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "4ae7d14b-4803-4e16-b96d-3b18caa4b605",
#'    "deployment": "deployment-1",
#'    "version": "version-1",
#'    "description": "",
#'    "language": "python3.8",
#'    "status": "available",
#'    "active_revision": "a74662be-c938-4104-872a-8be1b85f64ff",
#'    "latest_build": "0d07337e-96d6-4ce6-8c63-c2f07edd2ce4",
#'    "memory_allocation": 512,
#'    "maximum_instances": 4,
#'    "minimum_instances": 1,
#'    "maximum_idle_time": 10,
#'    "labels": {
#'      "type": "version"
#'    },
#'    "creation_date": "2020-05-12T16:23:15.456812Z",
#'    "last_updated": "2020-06-23T18:04:76.123754Z",
#'    "last_file_uploaded": "2020-06-21T09:03:01.875391Z"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param memory_allocation descriptionhere
#' @param maximum_instances descriptionhere
#' @param minimum_instances descriptionhere
#' @param maximum_idle_time descriptionhere
#' @param description descriptionhere
#' @param labels descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_patch_versions_update <- function(project_name, deployment_name, version, memory_allocation, maximum_instances, minimum_instances, maximum_idle_time, description, labels, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::PATCH(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete version
#'
#'
#'  ### Description
#'  Delete a deployment version. If the version is referenced from a pipeline, it cannot be deleted, it must be removed from the pipeline first.
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_versions_delete <- function(project_name, deployment_name, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List builds
#'
#'
#'  ### Description
#'  List all builds associated with a version. A build is triggered when a new deployment file is uploaded.
#'
#'  ### Response Structure
#'  A list of details of the builds
#'  - `id`: Unique identifier for the build (UUID)
#'  - `revision`: UUID of the revision to which the build is linked
#'  - `creation_date`: The date when the build was created
#'  - `status`: Status of the build. Can be 'queued', 'building', 'deploying', 'validating', 'success' or 'failed'.
#'  - `error_message`: Error message which explains why the build has failed. It is empty if the build is successful.
#'  - `trigger`: Action that triggered the build
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "49d857fd-39ca-48db-9547-0d5d1a91b62d",
#'      "revision": "7ead8a18-c1d2-4751-80d2-d8e0e0e2fed6",
#'      "creation_date": "2020-12-23T16:15:11.200+00:00",
#'      "status": "failed",
#'      "error_message": "Could not find the deployment file",
#'      "trigger": "Deployment file upload"
#'    },
#'    {
#'      "id": "baf88570-d884-4bc6-9308-01068b051f5f",
#'      "revision": "a009d7c9-67e4-4d3c-89fd-d3c8b07c7242",
#'      "creation_date": "2020-12-23T16:35:13.088+00:00",
#'      "status": "queued",
#'      "error_message": "",
#'      "trigger": "Deployment file upload"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_builds_list <- function(project_name, deployment_name, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/builds")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get build
#'
#'
#'  ### Description
#'  Retrieve details of a single build of a version
#'
#'  ### Response Structure
#'  A dictionary containing details of the build
#'  - `id`: Unique identifier for the build (UUID)
#'  - `revision`: UUID of the revision to which the build is linked
#'  - `creation_date`: The date when the build was created
#'  - `status`: Status of the build. Can be 'queued', 'building', 'deploying', 'validating', 'success' or 'failed'.
#'  - `error_message`: Error message which explains why the build has failed. It is empty if the build is successful.
#'  - `trigger`: Action that triggered the build
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "49d857fd-39ca-48db-9547-0d5d1a91b62d",
#'    "revision": "7ead8a18-c1d2-4751-80d2-d8e0e0e2fed6",
#'    "creation_date": "2020-12-23T16:15:11.200+00:00",
#'    "status": "building",
#'    "error_message": "",
#'    "trigger": "Deployment file upload"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param build_id descriptionhere
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_builds_get <- function(project_name, build_id, deployment_name, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/builds/{build_id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Copy version environment variable
#'
#'
#'  ### Description
#'  Copy existing environment variables from a source object to the version. Variables of the version with the same name as ones from the source object will be overwritten with the new value. Only the copied variables are returned.
#'
#'  ### Required Parameters
#'  - `source_deployment`: The name of the deployment from which the variables will be copied
#'
#'  ### Optional Parameters
#'  - `source_version`: The version of the object from which the variables will be copied
#'
#'  #### Request Examples
#'  Copy the environment variables from a deployment
#'  ```
#'  {
#'    "source_deployment": "example-deployment"
#'  }
#'  ```
#'
#'  Copy the environment variables from a version
#'  ```
#'  {
#'    "source_deployment": "example-deployment",
#'    "source_version": "v1"
#'  }
#'  ```
#'
#'  ### Response Structure
#'  A list of the copied variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'  - `inheritance_type`: Type of parent object that this variable is inherited from. Will be null for copied environment variables.
#'  - `inheritance_name`: Name of the parent object that this variable is inherited from. Will be null for copied environment variables.
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
#'      "name": "version_specific_variable",
#'      "value": "some_value",
#'      "secret": false,
#'      "inheritance_type": null,
#'      "inheritance_name": null
#'    },
#'    {
#'      "id": "4c15a27e-25ea-4be0-86c7-f4790389d061",
#'      "name": "database_schema",
#'      "value": "public",
#'      "secret": false,
#'      "inheritance_type": null,
#'      "inheritance_name": null
#'    },
#'    {
#'      "id": "06c2c8be-507e-4fae-981d-54e94f22dab0",
#'      "name": "database_password",
#'      "value": null,
#'      "secret": true,
#'      "inheritance_type": null,
#'      "inheritance_name": null
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param source_deployment descriptionhere
#' @param source_version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_version_environment_variables_copy <- function(project_name, deployment_name, version, source_deployment, source_version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/copy-environment-variables")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List version environment variables
#'
#'
#'  ### Description
#'  List the environment variables defined for the version. Includes environment variables defined at project level and deployment level.
#'
#'  ### Response Structure
#'  A list of variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'  - `inheritance_type`: Type of parent object that this variable is inherited from - can be `project`, `deployment`, or null if the variable was defined for the version directly
#'  - `inheritance_name`: Name of the parent object that this variable is inherited from - will be null if the variable was defined for the version directly
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
#'      "name": "version_specific_variable",
#'      "value": "some_value",
#'      "secret": false,
#'      "inheritance_type": null,
#'      "inheritance_name": null
#'    },
#'    {
#'      "id": "4c15a27e-25ea-4be0-86c7-f4790389d061",
#'      "name": "database_schema",
#'      "value": "public",
#'      "secret": false,
#'      "inheritance_type": "deployment",
#'      "inheritance_name": "deployment_name"
#'    },
#'    {
#'      "id": "06c2c8be-507e-4fae-981d-54e94f22dab0",
#'      "name": "database_password",
#'      "value": null,
#'      "secret": true,
#'      "inheritance_type": "project",
#'      "inheritance_name": "project_name"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_version_environment_variables_list <- function(project_name, deployment_name, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/environment-variables")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Create version environment variable
#'
#'
#'  ### Description
#'  Create an environment variable for the version. Variables inherited from the project or deployment can be shadowed by creating a variable with the same name.
#'
#'  ### Required Parameters
#'  - `name`: The name of the variable. The variable will have this name when accessed from your deployment code. The variable name should contain only letters and underscores, and not start or end with an underscore.
#'  - `value`: The value of the variable as a string. It may be an empty string ("").
#'  - `secret`: If this variable contains sensitive information, set this to true to hide it from other users.
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "version_variable",
#'    "value": "another one",
#'    "secret": false
#'  }
#'  ```
#'
#'  ### Response Structure
#'  A list of variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "54e94fbe-507e-4fae-981d-227c28a2dab0",
#'    "name": "version_variable",
#'    "value": "another one",
#'    "secret": false
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param name descriptionhere
#' @param value descriptionhere
#' @param secret descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_version_environment_variables_create <- function(project_name, deployment_name, version, name, value, secret, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/environment-variables")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get version environment variable
#'
#'
#'  ### Description
#'  Retrieve details of a version environment variable. This cannot be used to retrieve details of inherited variables.
#'
#'  ### Response Structure
#'  A list of variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "4c15a27e-25ea-4be0-86c7-f4790389d061",
#'      "name": "database_schema",
#'      "value": "public",
#'      "secret": false
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param id descriptionhere
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_version_environment_variables_get <- function(project_name, deployment_name, id, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/environment-variables/{id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Update version environment variable
#'
#'
#'  ### Description
#'  Update an environment variable for the version. This cannot be used to update inherited variables; to change an inherited variable for a specific version you can create a variable with the same name for the version.
#'
#'  ### Required Parameters
#'  - `name`: The name of the variable. The variable will have this name when accessed from your deployment code. The variable name should contain only letters and underscores, and not start or end with an underscore.
#'  - `value`: The value of the variable as a string. It may be an empty string ("").
#'  - `secret`: If this variable contains sensitive information, set this to true to hide it from other users. Can be updated from false to true, but not from true to false (i.e. secrets will stay secrets).
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "version_variable",
#'    "value": "yet another one",
#'    "secret": false
#'  }
#'  ```
#'
#'  ### Response Structure
#'  A list of variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "54e94fbe-507e-4fae-981d-227c28a2dab0",
#'    "name": "version_variable",
#'    "value": "yet another one",
#'    "secret": false
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param id descriptionhere
#' @param version descriptionhere
#' @param name descriptionhere
#' @param value descriptionhere
#' @param secret descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_patch_version_environment_variables_update <- function(project_name, deployment_name, id, version, name, value, secret, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/environment-variables/{id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::PATCH(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete version environment variable
#'
#'
#'  ### Description
#'  Delete an environment variable of a version
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param id descriptionhere
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_version_environment_variables_delete <- function(project_name, deployment_name, id, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/environment-variables/{id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Create deployment requests
#'
#'
#'  ### Description
#'  Request a prediction from a deployment. Deployment requests are made for a specific version of a deployment. It is only possible to make a request if a deployment file is uploaded for that version and the deployment build has succeeded (meaning that the version is in available state).
#'  In case of a **blob** field, the uuid of a previously uploaded blob must be provided.
#'
#'  ### Required Parameters
#'  A dictionary which contains the input fields of the deployment as keys
#'
#'  ### Optional Parameters
#'  These parameters should be given as GET parameters
#'  - `timeout`: Timeout for the deployment request in seconds. The maximum allowed value is 3600 and the default value is 300.
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "input-field-1": 5.0,
#'    "input-field-2": "N",
#'    "input-field-3": [0.25, 0.25, 2.1, 16.3]
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "input-field-1": 5.0,
#'    "blob-input-field": "f52ff875-4980-4d71-9798-a469ef8cece2"
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the created deployment request
#'  - `request_id`: Unique identifier for the deployment request
#'  - `success`: A boolean value that indicates whether the deployment request was successful
#'  - `result`: Deployment request result value. NULL if the request failed.
#'  - `error_message`: An error message explaining why the request has failed. NULL if the request was successful.
#'
#'  #### Response Examples
#'  A failed deployment request
#'  ```
#'  {
#'    "request_id": "edcf07b5-ae15-46e6-ba29-daeed53eaa61",
#'    "success": false,
#'    "result": None,
#'    "error_message": "Asset ID not supported"
#'  }
#'  ```
#'
#'  A successful deployment request
#'  ```
#'  {
#'    "request_id": "b98a6d68-3173-409a-9e6e-a56804045a9c",
#'    "success": true,
#'    "result": {
#'      "output-field-1": "2.1369",
#'      "output-field-2": "5.5832",
#'    },
#'    "error_message": None
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param deployment_input_field_1 descriptionhere
#' @param deployment_input_field_2 descriptionhere
#' @param timeout descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_deployment_requests_create <- function(project_name, deployment_name, version, deployment_input_field_1, deployment_input_field_2, timeout, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/request")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List batch deployment requests
#'
#'
#'  ### Description
#'  List all requests for a version
#'
#'  ### Optional Parameters
#'  The following parameters should be given as Query parameters:
#'  - `status`: Status of the request. Can be 'pending', 'processing', 'failed' or 'completed'
#'  - `success`: A boolean value that indicates whether the deployment request was successful
#'  - `limit`: The maximum number of requests given back, default is 50
#'  - `offset`: The number which forms the starting point of the requests given back. If offset equals 2, then the first 2 requests will be omitted from the list.
#'  - `sort`: Direction of sorting, can be 'asc' or 'desc'. The default sorting is done in descending order.
#'
#'  ### Response Structure
#'  A list of dictionaries containing the details of the deployment requests with the following fields:
#'   - `id`: Unique identifier for the deployment request
#'   - `status`: Status of the request. Always 'pending' when initialised, later it can be 'processing', 'failed' or 'completed'.
#'   - `success`: A boolean value that indicates whether the deployment request was successful
#'   - `time_created`: Server time that the request was made (current time)
#'   - `time_started`: Server time that the processing of the request was started
#'   - `time_completed`: Server time that the processing of the request was completed
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "69eca481-8576-49e8-8e20-ea56f2005bcb",
#'      "status": "pending",
#'      "success": false,
#'      "time_created": "2020-03-28T20:00:26.613+00:00",
#'      "time_started": "2020-03-28T20:00:41.276+00:00",
#'      "time_completed": "2020-03-28T20:00:42.241+00:00"
#'    },
#'    {
#'      "id": "2521378e-263e-4e2e-85e9-a96254b36536",
#'      "status": "completed",
#'      "success": true,
#'      "time_created": "2020-03-28T20:00:26.613+00:00",
#'      "time_started": "2020-03-28T20:00:41.276+00:00",
#'      "time_completed": "2020-03-28T20:00:42.241+00:00"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param status descriptionhere
#' @param success descriptionhere
#' @param limit descriptionhere
#' @param offset descriptionhere
#' @param sort descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_batch_deployment_requests_list <- function(project_name, deployment_name, version, status, success, limit, offset, sort, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/request-batch")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Create batch deployment requests
#'
#'
#'  ### Description
#'  Request multiple predictions from a deployment. The request follows an asynchronous method, as the requests are queued in our back-end and can be collected at a later time using the deployment request collect methods. It is only possible to make a request if a deployment file is uploaded for that version and the deployment build has succeeded (meaning that the version is in available state).
#'  In case of a **blob** field, the uuid of a previously uploaded blob must be provided.
#'
#'  If one of the requests is faulty, all requests are denied. The maximum number of requests per bulk call is 250.
#'
#'  ### Required Parameters
#'  In case of structured input deployment: A list of dictionaries, where each dictionary contains the input fields of the deployment as keys. It is also possible to send a single dictionary as input.
#'  In case of plain input deployment: A list of strings. It is also possible to send a single string as input.
#'
#'  #### Request Examples
#'  ```
#'  [
#'    {
#'      "input-field-1": 5.0,
#'      "input-field-2": "N",
#'      "input-field-3": [0.25, 0.25, 2.1, 16.3]
#'    },
#'    {
#'      "input-field-1": 3.0,
#'      "input-field-2": "S",
#'      "input-field-3": [4.23, 3.27, 2.41, 12.4]
#'    }
#'  ]
#'  ```
#'
#'  ### Response Structure
#'  A list of dictionaries containing the details of the created deployment requests with the following fields:
#'   - `id`: Unique identifier for the deployment request, which can be used to collect the result
#'   - `status`: Status of the request. Always 'pending' when initialised, later it can be 'processing', 'failed' or 'completed'.
#'   - `time_created`: Server time that the request was made (current time)
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "69eca481-8576-49e8-8e20-ea56f2005bcb",
#'      "status": "pending",
#'      "time_created": "2020-03-28T20:00:26.613+00:00"
#'    },
#'    {
#'      "id": "2521378e-263e-4e2e-85e9-a96254b36536",
#'      "status": "pending",
#'      "time_created": "2020-03-28T20:00:26.613+00:00"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_batch_deployment_requests_create <- function(project_name, deployment_name, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/request-batch")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Retrieve multiple batch deployment request results
#'
#'
#'  ### Description
#'  Retrieve multiple batch deployment requests. If one of the given batch deployment requests does not exist, an error message is given and no request is returned. A maximum of 250 deployment requests can be retrieved with this method. The deployment requests are NOT returned in the order they are given in.
#'
#'  ### Required Parameters
#'  A list of ids for the batch requests
#'
#'  #### Request Examples
#'  ```
#'  ["2f909aeb-5c7e-4974-970d-cd0a6a073aca", "85711124-54db-4794-b83d-24492247c6e1"]
#'  ```
#'
#'  ### Response Structure
#'  A list of dictionaries containing the details of the retrieved deployment requests with the following fields:
#'   - `id`: Unique identifier for the deployment request
#'   - `status`: Status of the request. Always 'pending' when initialised, later it can be 'processing', 'failed' or 'completed'.
#'   - `success`: A boolean value that indicates whether the deployment request was successful
#'   - `time_created`: Server time that the request was made (current time)
#'   - `time_started`: Server time that the processing of the request was started
#'   - `time_completed`: Server time that the processing of the request was completed
#'   - `request_data`: A dictionary containing the data that was sent when the request was created
#'   - `result`: Deployment request result value. NULL if the request is 'pending', 'processing' or 'failed'.
#'   - `error_message`: An error message explaining why the request has failed. NULL if the request was successful.
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "2f909aeb-5c7e-4974-970d-cd0a6a073aca",
#'      "status": "pending",
#'      "success": false,
#'      "time_created": "2020-03-29T08:09:10.729+00:00",
#'      "time_started": "2020-03-28T20:00:41.276+00:00",
#'      "time_completed": "2020-03-28T20:00:42.241+00:00"
#'      "request_data": {
#'        "input": 82.2
#'      },
#'      "result": null,
#'      "error_message": null
#'    },
#'    {
#'      "id": "85711124-54db-4794-b83d-24492247c6e1",
#'      "status": "pending",
#'      "success": false,
#'      "time_created": "2020-06-25T09:37:17.765+00:00",
#'      "time_started": "2020-03-28T20:00:41.276+00:00",
#'      "time_completed": "2020-03-28T20:00:42.241+00:00"
#'      "request_data": {
#'        "input": 52.4
#'      },
#'      "result": null,
#'      "error_message": null
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_batch_deployment_requests_batch_get <- function(project_name, deployment_name, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/request-batch-collect")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete multiple batch deployment requests
#'
#'
#'  ### Description
#'  Delete multiple batch deployment requests. If one of the given batch deployment requests does not exist, an error message is given and no request is deleted. A maximum of 250 deployment requests can be deleted with this method.
#'
#'  ### Required Parameters
#'  A list of ids for the batch requests
#'
#'  #### Request Examples
#'  ```
#'  ["2f909aeb-5c7e-4974-970d-cd0a6a073aca", "85711124-54db-4794-b83d-24492247c6e1"]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_batch_deployment_requests_batch_delete <- function(project_name, deployment_name, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/request-batch-delete")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get batch deployment request
#'
#'
#'  ### Description
#'  Get a batch request for a deployment. With this method, the result of a batch request may be retrieved.
#'
#'  ### Response Structure
#'  A dictionary containing the details of the deployment request with the following fields:
#'   - `id`: Unique identifier for the deployment request
#'   - `status`: Status of the request. Always 'pending' when initialised, later it can be 'processing', 'failed' or 'completed'.
#'   - `success`: A boolean value that indicates whether the deployment request was successful
#'   - `time_created`: Server time that the request was made (current time)
#'   - `time_started`: Server time that the processing of the request was started
#'   - `time_completed`: Server time that the processing of the request was completed
#'   - `request_data`: A dictionary containing the data that was sent when the request was created
#'   - `result`: Deployment request result value. NULL if the request is 'pending', 'processing' or 'failed'.
#'   - `error_message`: An error message explaining why the request has failed. NULL if the request was successful.
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "2f909aeb-5c7e-4974-970d-cd0a6a073aca",
#'    "status": "pending",
#'    "success": false,
#'    "time_created": "2020-03-29T08:09:10.729+00:00",
#'    "time_started": "2020-03-28T20:00:41.276+00:00",
#'    "time_completed": "2020-03-28T20:00:42.241+00:00"
#'    "request_data": {
#'      "input": 82.3
#'    },
#'    "result": null,
#'    "error_message": null
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param request_id descriptionhere
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_batch_deployment_requests_get <- function(project_name, deployment_name, request_id, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/request-batch/{request_id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete batch deployment requests
#'
#'
#'  ### Description
#'  Delete a batch deployment request
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param request_id descriptionhere
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_batch_deployment_requests_delete <- function(project_name, deployment_name, request_id, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/request-batch/{request_id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List revisions
#'
#'
#'  ### Description
#'  List all revisions associated with a version. A new revision is created every time a new deployment file is uploaded for a version.
#'
#'  ### Response Structure
#'  A list of details of the revisions
#'  - `id`: Unique identifier for the revision (UUID)
#'  - `version`: Version to which the revision is linked
#'  - `creation_date`: The date when the revision was created
#'  - `created_by`: The email of the user that uploaded the deployment file. In case the revision is created by a service, the field will have a "UbiOps" value.
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "7ead8a18-c1d2-4751-80d2-d8e0e0e2fed6",
#'      "version": "v1",
#'      "creation_date": "2020-12-23T16:15:11.181+00:00",
#'      "created_by": "UbiOps"
#'    },
#'    {
#'      "id": "a009d7c9-67e4-4d3c-89fd-d3c8b07c7242",
#'      "version": "v1",
#'      "creation_date": "2020-12-23T16:35:13.069+00:00",
#'      "created_by": "test@example.com"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_revisions_list <- function(project_name, deployment_name, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/revisions")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Upload deployment file
#'
#'
#'  ### Description
#'  Upload a deployment file for a version. Uploading a deployment file will create a new revision and trigger a build.
#'  This file should contain the deployment that will be run. It should be provided as a zip and a template can be found on https://github.com/UbiOps/deployment-template. The file is saved under a directory in the storage specified in the settings.
#'
#'  ### Required Parameters
#'  - `file`: Deployment file
#'
#'  ### Response Structure
#'  - `success`: Boolean indicating whether the deployment file upload succeeded or not
#'  - `revision`: UUID of the created revision for the file upload
#'  - `build`: UUID of the build created for the file upload
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param version descriptionhere
#' @param file descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_revisions_file_upload <- function(project_name, deployment_name, version, file, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/revisions")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get revision
#'
#'
#'  ### Description
#'  Retrieve details of a single revision of a version
#'
#'  ### Response Structure
#'  A dictionary containing details of the build
#'  - `id`: Unique identifier for the revision (UUID)
#'  - `version`: Version to which the revision is linked
#'  - `creation_date`: The date when the revision was created
#'  - `created_by`: The email of the user that uploaded the deployment file. In case the revision is created by a service, the field will have a "UbiOps" value.
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "a009d7c9-67e4-4d3c-89fd-d3c8b07c7242",
#'    "version": "v1",
#'    "creation_date": "2020-12-23T16:35:13.069+00:00",
#'    "created_by": "test@example.com"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param revision_id descriptionhere
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_revisions_get <- function(project_name, deployment_name, revision_id, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/revisions/{revision_id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Download deployment file
#'
#'
#'  ### Description
#'  Download the deployment file of a revision of a version
#'
#'  ### Response Structure
#'   - `file`: Deployment file of the version
#'
#' @param project_name name of your project
#' @param deployment_name name of your deployment
#' @param revision_id descriptionhere
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_revisions_file_download <- function(project_name, deployment_name, revision_id, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/deployments/{deployment_name}/versions/{version}/revisions/{revision_id}/download")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List project environment variables
#'
#'
#'  ### Description
#'  List the environment variables defined for the project. These are the variables that are inherited by all deployments in this project.
#'
#'  ### Response Structure
#'  A list of variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "4c15a27e-25ea-4be0-86c7-f4790389d061",
#'      "name": "database_schema",
#'      "value": "public",
#'      "secret": false
#'    },
#'    {
#'      "id": "06c2c8be-507e-4fae-981d-54e94f22dab0",
#'      "name": "database_password",
#'      "value": null,
#'      "secret": true
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_project_environment_variables_list <- function(project_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/environment-variables")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Create project environment variable
#'
#'
#'  ### Description
#'  Create an environment variable for the project. This variable will be inherited by all deployments in this project.
#'
#'  ### Required Parameters
#'  - `name`: The name of the variable. The variable will have this name when accessed from your deployment code. The variable name should contain only letters and underscores, and not start or end with an underscore.
#'  - `value`: The value of the variable as a string. It may be an empty string ("").
#'  - `secret`: If this variable contains sensitive information, set this to true to hide it from other users.
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "database_schema",
#'    "value": "public",
#'    "secret": false
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "name": "database_password",
#'    "value": "password",
#'    "secret": true
#'  }
#'  ```
#'
#'  ### Response Structure
#'  A list of variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "4c15a27e-25ea-4be0-86c7-f4790389d061",
#'    "name": "database_schema",
#'    "value": "public",
#'    "secret": false
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "id": "06c2c8be-507e-4fae-981d-54e94f22dab0",
#'    "name": "database_password",
#'    "value": null,
#'    "secret": true
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param name descriptionhere
#' @param value descriptionhere
#' @param secret descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_project_environment_variables_create <- function(project_name, name, value, secret, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/environment-variables")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get project environment variable
#'
#'
#'  ### Description
#'  Retrieve details of a project environment variable.
#'
#'  ### Response Structure
#'  A list of variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "4c15a27e-25ea-4be0-86c7-f4790389d061",
#'      "name": "database_schema",
#'      "value": "public",
#'      "secret": false
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_project_environment_variables_get <- function(project_name, id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/environment-variables/{id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Update project environment variable
#'
#'
#'  ### Description
#'  Update an environment variable for the projects
#'
#'  ### Required Parameters
#'  - `name`: The name of the variable. The variable will have this name when accessed from your deployment code. The variable name should contain only letters and underscores, and not start or end with an underscore.
#'  - `value`: The value of the variable as a string. It may be an empty string.
#'  - `secret`: If this variable contains sensitive information, set this to true to hide it from other users. Can be updated from false to true, but not from true to false (i.e. secrets will stay secrets).
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "database_schema",
#'    "value": "new+schema",
#'    "secret": false
#'  }
#'  ```
#'
#'  ### Response Structure
#'  A list of variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "4c15a27e-25ea-4be0-86c7-f4790389d061",
#'    "name": "database_schema",
#'    "value": "new_schema",
#'    "secret": false
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param id descriptionhere
#' @param name descriptionhere
#' @param value descriptionhere
#' @param secret descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_patch_project_environment_variables_update <- function(project_name, id, name, value, secret, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/environment-variables/{id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::PATCH(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete project environment variable
#'
#'
#'  ### Description
#'  Delete an environment variable of the project
#'
#' @param project_name name of your project
#' @param id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_project_environment_variables_delete <- function(project_name, id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/environment-variables/{id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List logs for a project
#'
#'
#'  ### Description
#'  Retrieve the logs of all objects in a project, including deployments, pipelines and requests. Using filters you can filter the logs on the objects and information of your choice.
#'
#'  ### Required Parameters
#'  - `filters`: A dictionary containing information to filter logs on. It may contain zero or more of the following fields:
#'
#'      - `deployment_name`: name of a deployment
#'
#'      - `version`: a version name. If this field is present in the request, deployment_name must also be given. The versions are only meaningful in combination with the deployments they are defined for.
#'
#'      - `build_id`: the UUID of a build. It does not have to be given in combination with the version and deployment name.
#'
#'      - `pipeline_name`: name of a pipeline
#'
#'      - `pipeline_object_name`: name of a pipeline object. If this field is present in the request, pipeline_name must also be given. The pipeline objects are only meaningful in combination with the pipelines they are defined in.
#'
#'      - `request_id`: the UUID of a deployment request
#'
#'      - `pipeline_request_id`: the UUID of a pipeline request
#'
#'      - `system`: whether the log was generated by the system or user code (true / false)
#'
#'
#'  Any combination of filters may be given in the request. For example, if only a deployment_name is provided, all logs for that deployment are returned. These logs can contain information from all the pipelines that deployment is referenced in. If the filters dictionary is empty, all logs for all objects in the project are returned.
#'
#'  ### Optional Parameters
#'  - `date`: Starting date for the logs. If it is not provided and the `id` parameter is not set, the most recent logs are returned. It should be provided in ISO 8601 format. The results are inclusive of the given date.
#'
#'  - `id`: identifier for log lines. If specified, it will act as a starting point for the interval in which to query the logs. This can be useful when making multiple queries to obtain consecutive logs
#'
#'      It will include the log having the log id equal to the id value in the response, regardless of whether the date_range is positive or negative.
#'  - `limit`: Limit for the logs response. If specified, it will limit the total number of logs returned from the query to the specified number. Defaults to 50, the maximum is 500.
#'
#'  - `date_range`: The date range parameter sets the interval of time in which to query the logs, specified in seconds. It may be a positive or a negative value.
#'
#'      If it is positive, logs starting from the specified date / log id (both inclusive) plus date range seconds towards the present time are returned.
#'
#'      Otherwise, logs starting from the specified date / log id (both inclusive) minus date range seconds towards the past are returned.
#'
#'      The default value is -21600 (6 hours). The maximum value is -/+ 86400 seconds (24 hours).
#'
#'  If no date or id is specified, the API will use the current time as a starting point and try to fetch the logs starting from now minus date range seconds into the past.
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "filters": {
#'      "deployment_name": "deployment-1",
#'      "version": "v1"
#'    },
#'    "date": "2020-01-01T00:00:00.000000Z"
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "filters": {
#'      "pipeline_name": "pipeline-1"
#'    },
#'    "id": "41d7a7c5cd025e3501a00000",
#'    "date_range": -100
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "filters": {
#'      "pipeline_name": "pipeline-1",
#'      "deployment_name": "deployment-1",
#'      "version": "v1"
#'    },
#'    "date": "2020-01-01T00:00:00.000000Z",
#'    "date_range": -86400,
#'    "limit": 5
#'  }
#'  ```
#'
#'  ### Response Structure
#'  A list of log details
#'  - `id`: Unique UUID of the log line
#'
#'  - `log`: Log line text
#'
#'  - `date`: Time the log line was created
#'
#'  The following fields will be returned on response if they are set for the log line:
#'  - `deployment_name`:  The deployment which the log is related to
#'
#'  - `version`:  The version which the log is related to
#'
#'  - `build_id`: The UUID of the build
#'
#'  - `pipeline_name`:  The pipeline which the log is related to
#'
#'  - `pipeline_object_name`: The pipeline object which the log is related to
#'
#'  - `request_id`:  The deployment request the log is related to
#'
#'  - `pipeline_request_id`:  The pipeline request the log is related to
#'
#'  - `system`:  Whether the log was generated by the system (true / false)
#'
#'  #### Response Examples
#'  Logs for a specific deployment and version
#'  ```
#'  [
#'    {
#'      "id": "5dcad12ba76a2c6e4331f180",
#'      "deployment_name": "deployment-1",
#'      "version": "v1",
#'      "date": "2020-01-01T00:00:00.000000Z",
#'      "log": "[Info] Prediction result 0.14981"
#'    },
#'    {
#'      "id": "5dcad12ba76a2c6e4331f181",
#'      "deployment_name": "deployment-1",
#'      "version": "v1",
#'      "pipeline_name": "pipeline-2",
#'      "pipeline_object_name": "deployment-1-v1-object",
#'      "pipeline_trace_id": "8bb6ed79-8606-4acf-acd2-90507130523c",
#'      "date": "2020-01-01T00:00:01.000000Z",
#'      "log": "[Error] Deployment call result (failed)"
#'    }
#'  ]
#'  ```
#'
#'  Logs for a specific pipeline
#'  ```
#'  [
#'    {
#'      "id": "5dcad12ba76a2c6e4331f192",
#'      "deployment_name": "deployment-2",
#'      "version": "v2",
#'      "pipeline_name": "pipeline-1",
#'      "pipeline_object_name": "deployment-2-v2-object",
#'      "pipeline_trace_id": "4f75b10d-6012-47ab-ae68-cc9e69f35841",
#'      "date": "2020-01-01T00:00:00.000000Z",
#'      "log": "[Info] Deployment call result (success): 0.2316"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param filters descriptionhere
#' @param date_range descriptionhere
#' @param date descriptionhere
#' @param id descriptionhere
#' @param limit descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_projects_log_list <- function(project_name, filters, date_range, date, id, limit, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/logs")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get metrics
#'
#'
#'  ### Description
#'  Get metrics for the project or a specified object. The following metrics are available:
#'
#'  Metrics on pipeline level:
#'   - `requests`: Number of requests made to the object
#'   - `failed_requests`: Number of failed requests made to the object
#'   - `input_volume`: Volume of incoming data in bytes
#'   - `object_requests`: Number of requests made to objects in the pipeline
#'
#'  Metrics on version level:
#'   - `requests`: Number of requests made to the object
#'   - `failed_requests`: Number of failed requests made to the object
#'   - `input_volume`: Volume of incoming data in bytes
#'   - `output_volume`: Volume of outgoing data in bytes
#'   - `outputs`: Number of outgoing data items
#'   - `compute`: Time in seconds for a request to complete
#'   - `instances`: Number of active deployment instances
#'   - `gb_seconds`: Usage of GB seconds, calculated by multiplying the deployment memory sizes in GB by the number of seconds the deployments are running
#'   - `active_time`: Time in seconds that the deployment is active
#'
#'  ### Required Parameters
#'  - `start_time`: Starting time for the metric values to be returned. It should be provided in datetime isoformat.
#'  - `end_time`: Ending time for the metric values to be returned. It should be provided in datetime isoformat.
#'  - `object_type`: The type of the object for which the metrics are requested. It can be either `version` or `pipeline`.
#'
#'  ### Optional Parameters
#'  - `interval`: Interval for the metric value. It can be minute, hour, day or month. The metric values will be aggregated according to this interval. The default value is hour.
#'  - `object_id`: Uuid of the specific object for which the metrics are requested. When it is not provided, the metrics are aggregated for the given `object_type`.
#'
#'  ### Response Structure
#'  - `start_time`: Timestamp denoting the start of the period over which the metric was measured
#'  - `end_time`: Timestamp denoting the end of the period over which the metric was measured
#'  - `value`: Aggregated metric value for the given interval
#'
#'  #### Response Examples
#'  With interval as minute, start_time as 2019-11-13 12:00:00 and end_time as 2019-11-13 12:03:00
#'  ```
#'  [
#'    {
#'      "start_time": "2019-11-13T12:00:00+00:00",
#'      "end_time": "2019-11-13T12:01:00+00:00",
#'      "value": 100
#'    },
#'    {
#'      "start_time": "2019-11-13T12:01:00+00:00",
#'      "end_time": "2019-11-13T12:02:00+00:00",
#'      "value": 134
#'    },
#'    {
#'      "start_time": "2019-11-13T12:02:00+00:00",
#'      "end_time": "2019-11-13T12:03:00+00:00",
#'      "value": 112
#'    }
#'  ]
#'
#'  ```
#'
#'  With interval as hour, start_time as 2019-11-13 12:00:00 and end_time as 2019-11-13 14:00:00
#'  ```
#'  [
#'    {
#'     "start_time": "2019-11-13T12:00:00+00:00",
#'     "end_time": "2019-11-13T13:00:00+00:00",
#'     "value": 92
#'    },
#'    {
#'      "start_time": "2019-11-13T13:00:00+00:00",
#'      "end_time": "2019-11-13T14:00:00+00:00",
#'      "value": 120
#'    },
#'    {
#'      "start_time": "2019-11-13T14:00:00+00:00",
#'      "end_time": "2019-11-13T15:00:00+00:00",
#'      "value": 0
#'    }
#'  ]
#'  ```
#'
#'  With interval as day, start_time as 2019-11-13 12:00:00 and end_time as 2019-11-14 12:00:00
#'  ```
#'  [
#'    {
#'     "start_time": "2019-11-13T00:00:00+00:00",
#'     "end_time": "2019-11-14T00:00:00+00:00",
#'     "value": 528
#'    },
#'    {
#'      "start_time": "2019-11-14T00:00:00+00:00",
#'      "end_time": "2019-11-15T00:00:00+00:00",
#'      "value": 342
#'    }
#'  ]
#'  ```
#'
#'  With interval as month, start_time as 2019-11-13 12:00:00 and end_time as 2019-12-13 12:00:00
#'  ```
#'  [
#'    {
#'     "start_time": "2019-11-01T00:00:00+00:00",
#'     "end_time": "2019-12-01T00:00:00+00:00",
#'     "value": 1983
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param metric descriptionhere
#' @param interval descriptionhere
#' @param start_time descriptionhere
#' @param end_time descriptionhere
#' @param object_type descriptionhere
#' @param object_id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_metrics_get <- function(project_name, metric, interval, start_time, end_time, object_type, object_id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/metrics/{metric}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List pipelines
#'
#'
#'  ### Description
#'  Pipelines can be filtered according to the labels they have by giving labels as a query parameter. Pipelines that have at least one of the labels on which is filtered, are returned.
#'
#'  ### Optional Parameters
#'  - `labels`: Filter on labels of the pipeline. Should be given in the format 'label:label_value'. Separate multiple label-pairs with a comma (,). This parameter should be given as query parameter.
#'
#'  ### Response Structure
#'  A list of details of the pipelines in the project
#'  - `id`: Unique identifier for the pipeline (UUID)
#'  - `name`: Name of the pipeline
#'  - `project`: Project name in which the pipeline is defined
#'  - `description`: Description of the pipeline
#'  - `input_type`: Type of the pipeline
#'  - `input_fields`: A list of pipeline fields with name and data_type
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'  - `creation_date`: The date when the pipeline was created
#'  - `last_updated`: The date when the pipeline was last updated
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "6b0cea21-2657-4fa3-a331-de646e3cfdc4",
#'      "name": "pipeline-1",
#'      "project": "project-1",
#'      "description": "my description",
#'      "input_type": "structured",
#'      "input_fields": [
#'        {
#'          "name": "field-1",
#'          "data_type": "int"
#'        },
#'        {
#'          "name": "field-2",
#'          "data_type": "double"
#'        }
#'      ],
#'      "labels": {
#'        "tag": "production"
#'      },
#'      "creation_date": "2020-05-12T16:23:15.456812Z",
#'      "last_updated": "2020-06-22T18:04:76.123754Z"
#'    },
#'    {
#'      "id": "b6f60ebf-48ef-4084-9fbb-9ac0f934093e",
#'      "name": "pipeline-2",
#'      "project": "project-1",
#'      "description": "my description",
#'      "input_type": "plain",
#'      "input_fields": [],
#'      "labels": {
#'        "tag": "production"
#'      },
#'      "creation_date": "2020-03-24T09:43:51.791253Z",
#'      "last_updated": "2020-05-19T11:52:21.163270Z"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param labels descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_pipelines_list <- function(project_name, labels, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Create pipelines
#'
#'
#'  ### Description
#'  Create a pipeline in a project.
#'
#'  The input_fields represent the fields that the input data for pipeline requests should contain. When an object is attached to the pipeline, it means that the input data will be forwarded to these objects.
#'
#'  ### Required Parameters
#'  - `name`: Name of the pipeline. It is unique within a project.
#'  - `input_type`: Type of the pipeline. It can be either structured or plain.
#'  - `input_fields`: A list of fields with name and data_type. In case of plain pipelines, the input_fields should be omitted or given as an empty list. For structured pipelines, it is possible to leave this field empty.
#'
#'  ### Optional Parameters
#'  - `description`: Description of the pipeline
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'
#'  #### Request Examples
#'  A structured pipeline
#'  ```
#'  {
#'    "name": "pipeline-1",
#'    "input_type": "structured",
#'    "input_fields": [
#'      {
#'        "name": "field-1",
#'        "data_type": "int"
#'      },
#'      {
#'        "name": "field-2",
#'        "data_type": "double"
#'      }
#'    ]
#'  }
#'  ```
#'
#'  A plain pipeline
#'  ```
#'  {
#'    "name": "pipeline-2",
#'    "input_type": "plain",
#'    "description": "my description"
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the created pipeline
#'  - `id`: Unique identifier for the pipeline (UUID)
#'  - `name`: Name of the pipeline
#'  - `description`: Description of the pipeline
#'  - `project`: Project name in which the pipeline is created
#'  - `input_type`: Type of the pipeline
#'  - `input_fields`: A list of pipeline fields with name and data_type
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'  - `creation_date`: The date when the pipeline was created
#'  - `last_updated`: The date when the pipeline was last updated
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "6b0cea21-2657-4fa3-a331-de646e3cfdc4",
#'    "name": "pipeline-1",
#'    "project": "project-1",
#'    "description": "my description",
#'    "input_type": "structured",
#'    "input_fields": [
#'      {
#'        "name": "field-1",
#'        "data_type": "int"
#'      },
#'      {
#'        "name": "field-2",
#'        "data_type": "double"
#'      }
#'    ],
#'    "labels": {
#'      "tag": "production"
#'    },
#'    "creation_date": "2020-03-24T09:43:51.791253Z",
#'    "last_updated": "2020-03-24T09:43:51.791253Z"
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "id": "b6f60ebf-48ef-4084-9fbb-9ac0f934093e",
#'    "name": "pipeline-2",
#'    "project": "project-1",
#'    "description": "my description",
#'    "input_type": "plain",
#'    "input_fields": [],
#'    "labels": {
#'      "tag": "production"
#'    },
#'    "creation_date": "2020-05-12T16:23:15.456812Z",
#'    "last_updated": "2020-05-12T16:23:15.456812Z"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param name descriptionhere
#' @param description descriptionhere
#' @param input_type descriptionhere
#' @param input_fields descriptionhere
#' @param labels descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_pipelines_create <- function(project_name, name, description, input_type, input_fields, labels, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get pipeline
#'
#'
#'  ### Description
#'  Get the details of a single pipeline
#'
#'  ### Response Structure
#'  Details of the pipeline
#'  - `id`: Unique identifier for the pipeline (UUID)
#'  - `name`: Name of the pipeline
#'  - `description` Description of the pipeline
#'  - `project`: Project name in which the pipeline is defined
#'  - `input_type`: Type of the pipeline
#'  - `input_fields`: A list of pipeline fields with name and data_type
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'  - `creation_date`: The date when the pipeline was created
#'  - `last_updated`: The date when the pipeline was last updated
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "b6f60ebf-48ef-4084-9fbb-9ac0f934093e",
#'    "name": "pipeline-2",
#'    "project": "project-1",
#'    "description": "my description",
#'    "input_type": "plain",
#'    "input_fields": [],
#'    "labels": {
#'      "tag": "production"
#'    },
#'    "creation_date": "2020-03-24T09:43:51.791253Z",
#'    "last_updated": "2020-05-19T11:52:21.163270Z"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_pipelines_get <- function(project_name, pipeline_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Update pipeline
#'
#'
#'
#'  ### Description
#'  Update a pipeline. All necessary fields are validated again. When updating labels, the labels will replace the existing value for labels.
#'
#'  ### Optional Parameters
#'  - `name`: New name for the pipeline
#'  - `description`: New description for the pipeline
#'  - `labels`: New dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label. The new labels will replace the existing value for labels.
#'  - `input_type`: New type for the pipeline. It is possible to change the type from plain to structured and vice versa.
#'  - `input_fields`: New input fields for the pipeline.
#'
#'  If the type of pipeline is updated to plain, the input fields are deleted. In this case, input_fields should either be omitted or provided as en empty list.
#'  If the type of pipeline is updated to structured, the old fields are deleted, if there existed any. The new fields are created, if any is provided. If one or more old fields need to be kept, they must be provided again.
#'
#'  **To delete the input fields of a pipeline**, provide an empty list for input_fields field.
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "new-pipeline-name"
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "description": "New pipeline description",
#'    "labels": {
#'      "tag": "production"
#'    }
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "input_type": "plain"
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "input_type": "structured",
#'    "input_fields": [
#'      {
#'        "name": "new-field-1",
#'        "data_type": "array_double"
#'      },
#'      {
#'        "name": "new-field-2",
#'        "data_type": "array_string"
#'      }
#'    ]
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "input_type": "structured",
#'    "input_fields": []
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the updated pipeline
#'  - `id`: Unique identifier for the pipeline (UUID)
#'  - `name`: Name of the pipeline
#'  - `project`: Project name in which the pipeline is defined
#'  - `description`: Description for the pipeline
#'  - `input_type`: Type of the pipeline
#'  - `input_fields`: A list of pipeline fields with name and data_type
#'  - `labels`: Dictionary containing key/value pairs where key indicates the label and value is the corresponding value of that label
#'  - `creation_date`: The date when the pipeline was created
#'  - `last_updated`: The date when the pipeline was last updated
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "b6f60ebf-48ef-4084-9fbb-9ac0f934093e",
#'    "name": "new-pipeline-name",
#'    "project": "project-1",
#'    "description": "my description",
#'    "input_type": "structured",
#'    "input_fields": [
#'      {
#'        "name": "new-field-1",
#'        "data_type": "array_double"
#'      },
#'      {
#'        "name": "new-field-2",
#'        "data_type": "array_string"
#'      }
#'    ],
#'    "labels": {
#'      "tag": "production"
#'    },
#'    "creation_date": "2020-03-24T09:43:51.791253Z",
#'    "last_updated": "2020-05-19T11:52:21.163270Z"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param name descriptionhere
#' @param description descriptionhere
#' @param input_type descriptionhere
#' @param input_fields descriptionhere
#' @param labels descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_patch_pipelines_update <- function(project_name, pipeline_name, name, description, input_type, input_fields, labels, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::PATCH(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete pipeline
#'
#'
#'  ### Description
#'  Delete a pipeline. This will also delete all objects and attachments in the pipeline.
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_pipelines_delete <- function(project_name, pipeline_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List object attachments
#'
#'
#'  ### Description
#'  List all attachments in a pipeline
#'
#'  ### Response Structure
#'  A list of details of the attachments in the pipeline
#'  - `destination_name`: Name of the destination pipeline object
#'  - `sources`: A list of dictionaries containing the source object(s) and mapping of the fields. One attachment can have multiple source objects.
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "destination_name": "deployment-2-v2",
#'      "sources": [
#'        {
#'          "source_name": "pipeline_start",
#'          "mapping": [
#'            {
#'              "source_field_name": "pipeline-input-field-1",
#'              "destination_field_name": "deployment-input-field-1"
#'            },
#'            {
#'              "source_field_name": "pipeline-input-field-2",
#'              "destination_field_name": "deployment-input-field-2"
#'            }
#'          ]
#'        }
#'      ]
#'    },
#'    {
#'      "destination_name": "deployment-3-v1",
#'      "sources": [
#'        {
#'          "source_name": "deployment-2-v2",
#'          "mapping": [
#'            {
#'              "source_field_name": "deployment-output-field-1",
#'              "destination_field_name": "deployment-3-input-field-1"
#'            },
#'            {
#'              "source_field_name": "deployment-output-field-2",
#'              "destination_field_name": "deployment-3-input-field-2"
#'            },
#'            {
#'              "source_field_name": "deployment-output-field-3",
#'              "destination_field_name": "deployment-3-input-field-3"
#'            }
#'          ]
#'        }
#'      ]
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_pipeline_object_attachments_list <- function(project_name, pipeline_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/attachments")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Create object attachments
#'
#'
#'  ### Description
#'  Create an attachment between pipeline objects. An attachment can only be made between objects that have already been added to the pipeline.
#'  The objects where the attachment starts is called the source objects. The object that is linked is called the destination object. When attaching source objects to a destination object, one must also define which source object output fields map to which destination object input fields.
#'  All the input fields in the destination object must be provided in the mapping. In contrast, not all output fields of all source objects need to be used in the mapping. It is also possible that one source output field links to multiple destination input fields.
#'
#'  The *pipeline_start* object can only be a source object.
#'
#'  In case of plain type of objects, the mapping `source_field_name` and `destination_field_name` must be omitted or given as null.
#'
#'  ### Required Parameters
#'  - `destination_name`: Name of the destination pipeline object
#'  - `sources`: A list of dictionaries containing the link between a source object (source_name) and mapping of the source output field (source_field_name) and destination object input field (destination_field_name).
#'  Each item in the sources list must contain source_field_name and destination_field_name keys. The source and destination fields should match in data type, e.g. integer source fields can only be mapped to integer type destination fields.
#'
#'  #### Request Examples
#'  An attachment between two versions
#'  ```
#'  {
#'    "destination_name": "deployment-2-v1",
#'    "sources": [
#'      {
#'        "source_name": "deployment-1-v1",
#'        "mapping": [
#'          {
#'            "source_field_name": "deployment-output-field-1",
#'            "destination_field_name": "deployment-2-input-field-1"
#'          },
#'          {
#'            "source_field_name": "deployment-output-field-2",
#'            "destination_field_name": "deployment-2-input-field-2"
#'          },
#'          {
#'            "source_field_name": "deployment-output-field-3",
#'            "destination_field_name": "deployment-2-input-field-3"
#'          }
#'        ]
#'      },
#'    ]
#'  }
#'  ```
#'  An attachment between two plain input/output type versions
#'  ```
#'  {
#'    "destination_name": "plain-deployment-v4",
#'    "sources": [
#'      {
#'        "source_name": "plain-deployment-v3",
#'        "mapping": []
#'      }
#'    ]
#'  }
#'  ```
#'
#'  An attachment between a pipeline_start object and version
#'  ```
#'  {
#'    "destination_name": "deployment-2-v2",
#'    "sources": [
#'      {
#'        "source_name": "pipeline_start",
#'        "mapping": [
#'          {
#'            "source_field_name": "pipeline-input-field-1",
#'            "destination_field_name": "deployment-input-field-1"
#'          },
#'          {
#'            "source_field_name": "pipeline-input-field-2",
#'            "destination_field_name": "deployment-input-field-2"
#'          }
#'        ]
#'      }
#'    ]
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the created attachment
#'  - `destination_name`: Name of the destination pipeline object
#'  - `sources`: A list of dictionaries containing the link between a source object (source_name) and mapping of the source output field (source_field_name) and destination object input field (destination_field_name)
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "destination_name": "deployment-2-v2",
#'    "sources": [
#'      {
#'        "source_name": "pipeline_start",
#'        "mapping": [
#'          {
#'            "source_field_name": "pipeline-input-field-1",
#'            "destination_field_name": "deployment-input-field-1"
#'          },
#'          {
#'            "source_field_name": "pipeline-input-field-2",
#'            "destination_field_name": "deployment-input-field-2"
#'          }
#'        ]
#'      }
#'    ]
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param destination_name descriptionhere
#' @param sources descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_pipeline_object_attachments_create <- function(project_name, pipeline_name, destination_name, sources, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/attachments")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get an attachment in a pipeline
#'
#'
#'  ### Description
#'  Get the details of a single attachment in a pipeline
#'
#'  ### Response Structure
#'  Details of the attachment
#'  - `destination_name`: Name of the destination pipeline object
#'  - `sources`: A list of dictionaries containing the link between a source object (source_name) and mapping of the source output field (source_field_name) and destination object input field (destination_field_name)
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "destination_name": "deployment-3-v1",
#'    "sources": [
#'      {
#'        "source_name": "deployment-2-v2",
#'        "mapping": [
#'          {
#'            "source_field_name": "deployment-2-output-field-1",
#'            "destination_field_name": "deployment-3-input-field-1"
#'          },
#'          {
#'            "source_field_name": "deployment-2-output-field-2",
#'            "destination_field_name": "deployment-3-input-field-2"
#'          }
#'        ]
#'      }
#'    ]
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param attachment_id descriptionhere
#' @param pipeline_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_pipeline_object_attachments_get <- function(project_name, attachment_id, pipeline_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/attachments/{attachment_id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete attachment in a pipeline
#'
#'
#'  ### Description
#'  Delete an attachment in a pipeline. The referenced and original objects of the attachment still exist in the pipeline, only the link between them is deleted.
#'
#' @param project_name name of your project
#' @param attachment_id descriptionhere
#' @param pipeline_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_pipeline_object_attachments_delete <- function(project_name, attachment_id, pipeline_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/attachments/{attachment_id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List audit events for a pipeline
#'
#'
#'  ### Description
#'  List all audit events for a pipeline including objects and attachments
#'
#'  ### Optional Parameters
#'  The following parameters should be given as query parameters:
#'  - `action`: Type of action. It can be one of: create, update, delete, info.
#'  - `limit`: The maximum number of audit events given back, default is 50
#'  - `offset`: The number which forms the starting point of the audit events given back. If offset equals 2, then the first 2 events will be omitted from the list.
#'
#'  ### Response Structure
#'  A list of details of the audit events for a pipeline
#'  - `id`: Unique identifier for the audit event (UUID)
#'  - `date`: The date when the action was performed
#'  - `action`: Type of action. It can be one of: create, update, delete, info. *info* action denotes that the action does not fall into create, update or delete categories.
#'  - `user`: Email of the user who performed the action
#'  - `event`: Description of the event
#'  - `object_type`: Type of the object on which the action was performed
#'  - `object_name`: Name of the object on which the action was performed. If the object is deleted at the time of listing audit events, this field is empty.
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "44f326de-0ee3-4741-b72e-69e31b3ec55f",
#'      "date": "2020-10-23T12:21:12.460+00:00",
#'      "action": "create",
#'      "user": "user@example.com",
#'      "event": "Created pipeline object deployment-1 for pipeline pipeline-1",
#'      "object_type": "pipeline",
#'      "object_name": "pipeline-1"
#'    },
#'    {
#'      "id": "905cdc19-a02c-4f09-b2fb-42d92da21bda",
#'      "date": "2020-10-23T12:21:37.247+00:00",
#'      "action": "update",
#'      "user": "user@example.com",
#'      "event": "Updated pipeline object deployment-object for pipeline pipeline-1: name changed from deployment-1 to deployment-object",
#'      "object_type": "pipeline",
#'      "object_name": "pipeline-1"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param action descriptionhere
#' @param limit descriptionhere
#' @param offset descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_pipeline_audit_events_list <- function(project_name, pipeline_name, action, limit, offset, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/audit")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List objects in a pipeline
#'
#'
#'  ### Description
#'  List all pipeline objects in a pipeline
#'
#'  ### Response Structure
#'  A list of details of the pipeline objects in the pipeline
#'  - `id`: Unique identifier for the pipeline object (UUID)
#'  - `name`: Name of the pipeline object
#'  - `reference_name`: Name of the object it references
#'  - `version`: Version name of reference object
#'
#'  #### Response Examples
#'  A list of pipeline objects
#'  ```
#'  [
#'    {
#'      "id": "c91724b6-d73c-4933-b2aa-aefd9e34ce3e",
#'      "name": "deployment-1-v1",
#'      "reference_name": "deployment-1",
#'      "version": "version-1"
#'    },
#'    {
#'      "id": "1a4b0e28-3de1-442a-b1eb-947f22a69381",
#'      "name": "deployment-2-v1",
#'      "reference_name": "deployment-2",
#'      "version": "v1"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_pipeline_objects_list <- function(project_name, pipeline_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/objects")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Add an object to a pipeline
#'
#'
#'  ### Description
#'  Create a pipeline object. The pipeline object that is added is a reference to the real object. In this way, multiple references to the same object may be added to a pipeline.
#'  The reference_name refers to the deployment name and the version is the version of the deployment which will be added to the pipeline as an object.
#'
#'  ### Required Parameters
#'  - `name`: Name of the pipeline object. It is unique within a pipeline
#'  - `reference_name`: Name of the object it will reference
#'  - `version`: Version name of reference object
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "deployment-1-v1",
#'    "reference_name": "deployment-1",
#'    "version": "version-1"
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the created pipeline object
#'  - `id`: Unique identifier for the pipeline object (UUID)
#'  - `name`: Name of the pipeline object
#'  - `reference_name`: Name of the object it will reference
#'  - `version`: Version name of reference object
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "c91724b6-d73c-4933-b2aa-aefd9e34ce3e",
#'    "name": "deployment-1-v1",
#'    "reference_name": "deployment-1",
#'    "version": "version-1"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param name descriptionhere
#' @param reference_name descriptionhere
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_pipeline_objects_create <- function(project_name, pipeline_name, name, reference_name, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/objects")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List the attachments of a destination object
#'
#'
#'  ### Description
#'  List attachments of a destination object in a pipeline
#'
#'  ### Response Structure
#'  A list of details of the attachments of the given destination object in the pipeline
#'  - `destination_name`: Name of the destination pipeline object
#'  - `sources`: A list of dictionaries containing the link between a source object (source_name) and mapping of the source output field (source_field_name) and destination object input field (destination_field_name)
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "destination_name": "deployment-3-v1",
#'      "sources": [
#'        {
#'          "source_name": "deployment-2-v2",
#'          "mapping": [
#'            {
#'              "source_field_name": "deployment-2-output-field-1",
#'              "destination_field_name": "deployment-3-input-field-1"
#'            },
#'            {
#'              "source_field_name": "deployment-2-output-field-2",
#'              "destination_field_name": "deployment-3-input-field-2"
#'            }
#'          ]
#'        }
#'      ]
#'    },
#'      {
#'      "destination_name": "deployment-3-v1",
#'      "sources": [
#'        {
#'          "source_name": "deployment-2-v2",
#'          "mapping": [
#'            {
#'              "source_field_name": "deployment-2-output-field-1",
#'              "destination_field_name": "deployment-3-input-field-1"
#'            },
#'            {
#'              "source_field_name": "deployment-2-output-field-2",
#'              "destination_field_name": "deployment-3-input-field-2"
#'            }
#'          ]
#'        }
#'      ]
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param destination_name descriptionhere
#' @param pipeline_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_pipeline_object_attachments_destination_get <- function(project_name, destination_name, pipeline_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/objects/{destination_name}/attachments/")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get an object in a pipeline
#'
#'
#'  ### Description
#'  Retrieve the details of a single pipeline object
#'
#'  ### Response Structure
#'  Details of the pipeline object
#'  - `id`: Unique identifier for the pipeline object (UUID)
#'  - `name`: Name of the pipeline object
#'  - `reference_name`: Name of the object it references
#'  - `version`: Version name of reference object
#'
#'  #### Response Examples
#'  A dictionary containing details of the pipeline object
#'  ```
#'  {
#'    "id": "c91724b6-d73c-4933-b2aa-aefd9e34ce3e",
#'    "name": "deployment-1-v1",
#'    "reference_name": "deployment-1",
#'    "version": "version-1"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param name descriptionhere
#' @param pipeline_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_pipeline_objects_get <- function(project_name, name, pipeline_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/objects/{name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Update an object in a pipeline
#'
#'
#'  ### Description
#'  Update a pipeline object. It is not possible to update the reference_name. All necessary fields are validated again.
#'
#'  ### Optional Parameters
#'  - `name`: New name for the pipeline object
#'  - `version`: New version for the pipeline object. Since the input/output fields of different versions are the same, the version of a deployment pipeline object can be changed with another version of the same deployment.
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "new-pipeline-object-name"
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "name": "deployment-1-v2"
#'    "version": "version-2"
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the updated pipeline object
#'  - `id`: Unique identifier for the pipeline object (UUID)
#'  - `name`: Name of the pipeline object
#'  - `reference_name`: Name of the object it references
#'  - `version`: Version name of reference object
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "c91724b6-d73c-4933-b2aa-aefd9e34ce3e",
#'    "name": "deployment-1-v2",
#'    "reference_name": "deployment-1",
#'    "version": "version-2"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param name descriptionhere
#' @param pipeline_name descriptionhere
#' @param version descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_patch_pipeline_objects_update <- function(project_name, name, pipeline_name, version, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/objects/{name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::PATCH(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete object from pipeline
#'
#'
#'  ### Description
#'  Delete a pipeline object. Only the reference in the pipeline is deleted. The original object (deployment and version) still exists.
#'  If the object is attached to another object, the attachment is also deleted.
#'
#' @param project_name name of your project
#' @param name descriptionhere
#' @param pipeline_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_pipeline_objects_delete <- function(project_name, name, pipeline_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/objects/{name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List pipeline object environment variables
#'
#'
#'  ### Description
#'  List environment variables accessible to objects in the pipeline
#'
#'  ### Response Structure
#'  A list of variables described by the following fields:
#'  - `id`: Unique identifier for the environment variable
#'  - `name`: Variable name
#'  - `value`: Variable value (will be null for secret variables)
#'  - `secret`: Boolean that indicates if this variable contains sensitive information
#'  - `inheritance_type`: Type of parent object that this variable is inherited from - can be `project`, `deployment`, or `version`
#'  - `inheritance_name`: Name of the parent object that this variable is inherited from
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "4c15a27e-25ea-4be0-86c7-f4790389d061",
#'      "name": "database_schema",
#'      "value": "public",
#'      "secret": false,
#'      "inheritance_type": "deployment",
#'      "inheritance_name": "deployment_name"
#'    },
#'    {
#'      "id": "06c2c8be-507e-4fae-981d-54e94f22dab0",
#'      "name": "database_password",
#'      "value": null,
#'      "secret": true,
#'      "inheritance_type": "project",
#'      "inheritance_name": "project_name"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param name descriptionhere
#' @param pipeline_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_pipeline_object_environment_variables_list <- function(project_name, name, pipeline_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/objects/{name}/environment-variables")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Make a request to a pipeline
#'
#'
#'  ### Description
#'  Make a pipeline request. This method returns all the results of the deployment requests made within the pipeline.
#'
#'  ### Required Parameters
#'  A dictionary which contains the input fields of the pipeline as keys
#'
#'  ### Optional Parameters
#'  These parameters should be given as GET parameters
#'  - `pipeline_timeout`: Timeout for the entire pipeline request in seconds. The maximum allowed value is 7200 and the default value is 3600.
#'  - `deployment_timeout`: Timeout for each deployment request in the pipeline in seconds.  The maximum allowed value is 3600 and the default value is 300.
#'  Maximum allowed value for both is 3600 seconds and the default value is 300 seconds.
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "pipeline-input-field-1": 5.0,
#'    "pipeline-input-field-2": "N"
#'  }
#'  ```
#'
#'  ### Response Structure
#'  - `project`: Name of the project in which the request is made
#'  - `pipeline`: Name of the pipeline for which the request is made
#'  - `pipeline_request_id`: Unique identifier for the pipeline request
#'  - `success`: A boolean value that indicates whether the pipeline request was successful
#'  - `deployment_requests`: A list of dictionaries containing the results of the deployment requests made for the version objects in the pipeline. The dictionaries contain the following fields:
#'      - `request_id`: Unique identifier for the deployment request
#'      - `pipeline_object`: Name of the object in the pipeline
#'      - `success`: A boolean value that indicates whether the deployment request was successful
#'      - `request_data`: Input data for the deployment request
#'      - `result`: Deployment request result value. NULL if the request failed.
#'      - `error_message`: An error message explaining why the request has failed. NULL if the request was successful.
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "project": "project-1",
#'    "pipeline": "pipeline-1",
#'    "pipeline_request_id": "286f771b-6617-4985-ab49-12ed720e62b1",
#'    "success": false
#'    "deployment_requests": [
#'      {
#'        "request_id": "a7524614-bdb7-41e1-b4c1-653bb72c30b4",
#'        "pipeline_object": "deployment-object-1",
#'        "success": true,
#'        "request_data": {
#'          "deployment-1-input-field-1": 5,
#'          "deployment-1-input-field-2": 0.4
#'        },
#'        "result": {
#'          "deployment-1-output-field-1": 0.23,
#'          "deployment-1-output-field-2": 10
#'        },
#'        "error_message": None
#'      },
#'      {
#'        "request_id": "fe322c50-58f8-4e67-b7d6-cba14273874e",
#'        "pipeline_object": "deployment-object-2",
#'        "success": false,
#'        "request_data": {
#'          "deployment-2-input-field": 10
#'        },
#'        "result": None,
#'        "error_message": "Invalid message format"
#'      }
#'    ]
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param pipeline_input_field_1 descriptionhere
#' @param pipeline_input_field_2 descriptionhere
#' @param pipeline_timeout descriptionhere
#' @param deployment_timeout descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_pipeline_requests_create <- function(project_name, pipeline_name, pipeline_input_field_1, pipeline_input_field_2, pipeline_timeout, deployment_timeout, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/request")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List batch pipeline requests
#'
#'
#'  ### Description
#'  List all requests for a pipeline
#'
#'  ### Optional Parameters
#'  The following parameters should be given as query parameters:
#'  - `status`: Status of the request. Can be 'pending', 'processing', 'failed' or 'completed'.
#'  - `success`: A boolean value that indicates whether the pipeline request was successful
#'  - `limit`: The maximum number of requests given back, default is 50
#'  - `offset`: The number which forms the starting point of the requests given back. If offset equals 2, then the first 2 requests will be omitted from the list.
#'  - `sort`: Direction of sorting, can be 'asc' or 'desc'. The default sorting is done in descending order.
#'
#'  ### Response Structure
#'  A list of dictionaries containing the details of the pipeline requests with the following fields:
#'   - `id`: Unique identifier for the pipeline request
#'   - `status`: Status of the request. Always 'pending' when initialised, later it can be 'processing', 'failed' or 'completed'.
#'   - `success`: A boolean value that indicates whether the pipeline request was successful
#'   - `time_created`: Server time that the request was made (current time)
#'   - `time_started`: Server time that the processing of the request was started
#'   - `time_completed`: Server time that the processing of the request was completed
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "69eca481-8576-49e8-8e20-ea56f2005bcb",
#'      "status": "pending",
#'      "success": false,
#'      "time_created": "2020-03-28T20:00:26.613+00:00",
#'      "time_started": "2020-03-28T20:00:41.276+00:00",
#'      "time_completed": "2020-03-28T20:00:42.241+00:00"
#'    },
#'    {
#'      "id": "2521378e-263e-4e2e-85e9-a96254b36536",
#'      "status": "completed",
#'      "success": true,
#'      "time_created": "2020-03-28T20:00:26.613+00:00",
#'      "time_started": "2020-03-28T20:00:41.276+00:00",
#'      "time_completed": "2020-03-28T20:00:42.241+00:00"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param status descriptionhere
#' @param success descriptionhere
#' @param limit descriptionhere
#' @param offset descriptionhere
#' @param sort descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_batch_pipeline_requests_list <- function(project_name, pipeline_name, status, success, limit, offset, sort, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/request-batch")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Create batch pipeline requests
#'
#'
#'  ### Description
#'  Request multiple predictions from a pipeline. The request follows an asynchronous method, as the requests are queued in our back-end and can be collected at a later time using the pipeline request collect methods.
#'
#'  The maximum number of requests that can be created per batch is 100.
#'
#'  ### Required Parameters
#'  In case of structured input pipeline: A list of dictionaries, where each dictionary contains the input fields of the pipeline as keys. It is also possible to send a single dictionary as input.
#'  In case of plain input pipeline: A list of strings. It is also possible to send a single string as input.
#'
#'  #### Request Examples
#'  ```
#'  [
#'    {
#'      "pipeline-input-field-1": 5.0,
#'      "pipeline-input-field-2": "N",
#'      "pipeline-input-field-3": [0.25, 0.25, 2.1, 16.3]
#'    },
#'    {
#'      "pipeline-input-field-1": 3.0,
#'      "pipeline-input-field-2": "S",
#'      "pipeline-input-field-3": [4.23, 3.27, 2.41, 12.4]
#'    }
#'  ]
#'  ```
#'
#'  ### Response Structure
#'  A list of dictionaries containing the details of the created pipeline requests with the following fields:
#'   - `id`: Unique identifier for the pipeline request, which can be used to collect the result
#'   - `status`: Status of the request. Always 'pending' when initialised, later it can be 'processing', 'failed' or 'completed'.
#'   - `time_created`: Server time that the request was made (current time)
#'
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "69eca481-8576-49e8-8e20-ea56f2005bcb",
#'      "status": "pending",
#'      "time_created": "2020-03-28T20:00:26.613+00:00"
#'    },
#'    {
#'      "id": "2521378e-263e-4e2e-85e9-a96254b36536",
#'      "status": "pending",
#'      "time_created": "2020-03-28T20:00:26.613+00:00"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_batch_pipeline_requests_create <- function(project_name, pipeline_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/request-batch")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Retrieve multiple batch pipeline request results
#'
#'
#'  ### Description
#'  Retrieve multiple batch pipeline requests. If one of the given batch pipeline requests does not exist, an error message is given and no request is returned. A maximum of 100 pipeline requests can be retrieved with this method. The pipeline requests are NOT returned in the order they are given in.
#'
#'  ### Required Parameters
#'  A list of ids for the batch requests
#'
#'  #### Request Examples
#'  ```
#'  ["2521378e-263e-4e2e-85e9-a96254b36536", "69eca481-8576-49e8-8e20-ea56f2005bcb"]
#'  ```
#'
#'  ### Response Structure
#'  A list of dictionaries containing the details of the retrieved pipeline requests with the following fields:
#'   - `id`: Unique identifier for the pipeline request
#'   - `status`: Status of the request. Always 'pending' when initialised, later it can be 'processing', 'failed' or 'completed'.
#'   - `success`: A boolean value that indicates whether the pipeline request was successful
#'   - `time_created`: Server time that the request was made (current time)
#'   - `time_started`: Server time that the processing of the request was started
#'   - `time_completed`: Server time that the processing of the request was completed
#'   - `request_data`: A dictionary containing the data that was sent when the request was created
#'   - `deployment_requests`: A list of requests to the deployments in the pipeline. This field is empty when the request is initialized and is updated when all the deployment requests in the pipeline are completed.
#'   - `error_message`: An error message explaining why the request has failed. NULL if the request was successful.
#'
#'  #### Response Examples
#'  ```
#'  [
#'      {
#'        "id": "69eca481-8576-49e8-8e20-ea56f2005bcb",
#'        "status": "pending",
#'        "success": false,
#'        "time_created": "2020-063-28T20:00:26.613+00:00",
#'        "time_started": "2020-03-28T20:00:41.276+00:00",
#'        "time_completed": "2020-03-28T20:00:42.241+00:00"
#'        "request_data": {
#'          "input_field": 23.5
#'        },
#'        "deployment_requests": [],
#'        "error_message": null
#'      },
#'      {
#'        "id": "69eca481-8576-49e8-8e20-ea56f2005bcb",
#'        "status": "pending",
#'        "success": false,
#'        "time_created": "2020-063-28T20:00:26.613+00:00",
#'        "time_started": "2020-03-28T20:00:41.276+00:00",
#'        "time_completed": "2020-03-28T20:00:42.241+00:00"
#'        "request_data": {
#'          "input_field": 23.5
#'        },
#'        "deployment_requests": [],
#'        "error_message": null
#'      }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_batch_pipeline_requests_batch_get <- function(project_name, pipeline_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/request-batch-collect")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete multiple batch pipeline requests
#'
#'
#'  ### Description
#'  Delete multiple batch pipeline requests. If one of the given batch pipeline requests does not exist, an error message is given and no request is deleted. A maximum of 100 pipeline requests can be deleted with this method.
#'
#'  ### Required Parameters
#'  A list of ids for the batch requests
#'
#'  #### Request Examples
#'  ```
#'  ["2521378e-263e-4e2e-85e9-a96254b36536", "69eca481-8576-49e8-8e20-ea56f2005bcb"]
#'  ```
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_batch_pipeline_requests_batch_delete <- function(project_name, pipeline_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/request-batch-delete")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get batch pipeline request
#'
#'
#'  ### Description
#'  Get a batch request for a pipeline. With this method, the result of the batch request may be retrieved.
#'
#'  ### Response Structure
#'  A dictionary containing the details of the pipeline request with the following fields:
#'   - `id`: Unique identifier for the pipeline request
#'   - `status`: Status of the request. Always 'pending' when initialised, later it can be 'processing', 'failed' or 'completed'.
#'   - `success`: A boolean value that indicates whether the pipeline request was successful
#'   - `time_created`: Server time that the request was made (current time)
#'   - `time_started`: Server time that the processing of the request was started
#'   - `time_completed`: Server time that the processing of the request was completed
#'   - `request_data`: A dictionary containing the data that was sent when the request was created
#'   - `deployment_requests`: A list of requests of the deployments in the pipeline. This field is empty when the request is initialized and is updated when all the deployment requests in the pipeline are completed.
#'   - `error_message`: An error message explaining why the request has failed. NULL if the request was successful.
#'   - `created_by`: The email of the user that created the request. In case the request is created by a service, the field will have a "UbiOps" value.
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "69eca481-8576-49e8-8e20-ea56f2005bcb",
#'    "status": "pending",
#'    "success": true,
#'    "time_created": "2020-03-28T20:00:26.613+00:00",
#'    "time_started": "2020-03-28T20:00:41.276+00:00",
#'    "time_completed": "2020-03-28T20:00:42.241+00:00"
#'    "request_data": {
#'      "input_field": 23.5
#'    },
#'    "deployment_requests": [],
#'    "error_message": null,
#'    "created_by": "my.example.user@ubiops.com"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param pipeline_request_id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_batch_pipeline_requests_get <- function(project_name, pipeline_name, pipeline_request_id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/request-batch/{pipeline_request_id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete batch pipeline requests
#'
#'
#'  ### Description
#'  Delete a batch pipeline request. This action cancels all the deployment requests in the pipeline.
#'
#' @param project_name name of your project
#' @param pipeline_name descriptionhere
#' @param pipeline_request_id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_batch_pipeline_requests_delete <- function(project_name, pipeline_name, pipeline_request_id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/pipelines/{pipeline_name}/request-batch/{pipeline_request_id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List resource usage of a project
#'
#'
#'  ### Description
#'  List the total number of resources used in a project
#'
#'  ### Response Structure
#'  A list containing the number of
#'  - deployments
#'
#'  - versions
#'
#'  - pipelines
#'
#'  currently defined in the project.
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "deployments": 30,
#'    "versions": 47,
#'    "pipelines": 2
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_projects_resource_usage <- function(project_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/resources")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Assign a role to a user in a project
#'
#'
#'  ### Description
#'  Assign a role to a user in the scope of a project. This role can be assigned on either project level or on object level, which can be a deployment or pipeline.
#'  The user making the request must have appropriate permissions.
#'
#'  ### Required Parameters
#'  - `user_id`: Unique identifier for the user (UUID)
#'
#'  - `role`: Name of the role to be assigned to the user
#'
#'
#'  ### Optional Parameters
#'  - `object_name`: Name of the object for which the role will be assigned
#'
#'  - `object_type`: Type of the object for which the role will be assigned. It can be project, deployment or pipeline.
#'
#'  **object_name and object_type must be provided together. If neither of them is provided, the role is set on project level.**
#'
#'  #### Request Examples
#'  Setting the role deployment-admin on project level for user with id 02b77d8f-b312-47ef-990f-4685a7ab9363
#'  ```
#'  {
#'    "user_id": "02b77d8f-b312-47ef-990f-4685a7ab9363",
#'    "role": "deployment-admin"
#'  }
#'  ```
#'
#'  Setting the role deployment-viewer on deployment-1 for user with id 02b77d8f-b312-47ef-990f-4685a7ab9363
#'  ```
#'  {
#'    "user_id": "02b77d8f-b312-47ef-990f-4685a7ab9363",
#'    "role": "deployment-viewer",
#'    "object_name": "deployment-1",
#'    "object_type": "deployment"
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the created role assignment
#'  - `id`: Unique identifier for the role assignment (UUID)
#'
#'  - `user_id`: Unique identifier for the user (UUID)
#'
#'  - `role`: Name of the role assigned to the user
#'
#'  - `object_name`: Name of the object for which the role is assigned
#'
#'  - `object_type`: Type of the object for which the role is assigned. It can be project, deployment or pipeline.
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "e988ddc0-3ef1-42d2-ab30-9f810a5e7063",
#'    "user_id": "02b77d8f-b312-47ef-990f-4685a7ab9363",
#'    "role": "deployment-admin",
#'    "object_name": "project-1",
#'    "object_type": "project"
#'  }
#'  ```
#'
#'  ```
#'  {
#'    "id": "e988ddc0-3ef1-42d2-ab30-9f810a5e7063",
#'    "user_id": "02b77d8f-b312-47ef-990f-4685a7ab9363",
#'    "role": "deployment-viewer",
#'    "object_name": "deployment-1",
#'    "object_type": "deployment"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param user_id descriptionhere
#' @param role descriptionhere
#' @param object_name descriptionhere
#' @param object_type descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_role_assignments_create <- function(project_name, user_id, role, object_name, object_type, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/role-assignments")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get details of a role assignment
#'
#'
#'  ### Description
#'  Get the details of a role assignment of a user. The user making the request must have appropriate permissions.
#'
#'  ### Response Structure
#'  Details of the role assignment
#'  - `id`: Unique identifier for the role assignment (UUID)
#'
#'  - `user_id`: Unique identifier for the user (UUID)
#'
#'  - `role`: Name of the role assigned to the user
#'
#'  - `object_name`: Name of the object for which the role is assigned
#'
#'  - `object_type`: Type of the object for which the role is assigned. It can be project, deployment or pipeline.
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "e988ddc0-3ef1-42d2-ab30-9f810a5e7063",
#'    "user_id": "02b77d8f-b312-47ef-990f-4685a7ab9363",
#'    "role": "deployment-viewer",
#'    "object_name": "deployment-1",
#'    "object_type": "deployment"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_role_assignments_get <- function(project_name, id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/role-assignments/{id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete a role from a user with the given role assignment id
#'
#'
#'  ### Description
#'  Delete a role of a user. The user making the request must have appropriate permissions. It is possible for a user to delete their own role if they have permissions to do so.
#'
#' @param project_name name of your project
#' @param id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_role_assignments_delete <- function(project_name, id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/role-assignments/{id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List the available roles in a project
#'
#'
#'  ### Description
#'  List the roles available in the scope of a project. Information on which permissions each role contains, can be obtained with a call to get details of a single role.
#'
#'  ### Response Structure
#'  - `id`: Unique identifier for the role (UUID)
#'
#'  - `name`: Name of the role
#'
#'  - `default`: A boolean value that indicates whether the role is a default role or not
#'
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "34e53855-9b50-47bc-b516-6cb971b1949c",
#'      "name": "project-admin",
#'      "default": true
#'    },
#'    {
#'      "id": "00132911-b5dd-4017-b399-85f3ffd2a7c3",
#'      "name": "project-editor",
#'      "default": true
#'    },
#'    {
#'      "id": "bf0d5823-8062-40f6-bbd2-21bc732f3c3b",
#'      "name": "project-viewer",
#'      "default": true
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_roles_list <- function(project_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/roles")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Create a custom role scoped in a project
#'
#'
#'  ### Description
#'  Create a custom role in the scope of a project. This role is not accessible from other projects.
#'  The user making the request must have appropriate permissions.
#'
#'  ### Required Parameters
#'  - `name`: Name of the role which will be created. It can only consist of lowercase letters, numbers and dashes (-), and must start with a lowercase letter.
#'
#'  - `permissions`: A list of permissions which the role will contain. The list of available permissions can be obtained with */permissions* endpoint.
#'
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "custom-deployment-editor-role",
#'    "permissions": [
#'      "deployments.list",
#'      "deployments.get",
#'      "deployments.delete"
#'    ]
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the created role
#'  - `id`: Unique identifier for the created role (UUID)
#'
#'  - `name`: Name of the created role
#'
#'  - `default`: A boolean value that indicates whether the role is a default role or not
#'
#'  - `permissions`: A list of permissions which the role contains
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "18a4a60d-d5f0-4099-9c6e-543bf2fd5a1d",
#'    "name": "custom-deployment-editor-role",
#'    "default": false,
#'    "permissions": [
#'      "deployments.list",
#'      "deployments.get",
#'      "deployments.delete"
#'    ]
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param name descriptionhere
#' @param permissions descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_roles_create <- function(project_name, name, permissions, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/roles")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get details of a role
#'
#'
#'  ### Description
#'  Get the details of a role. The user making the request must have appropriate permissions.
#'
#'  ### Response Structure
#'  Details of the role
#'  - `id`: Unique identifier for the role (UUID)
#'
#'  - `name`: Name of the role
#'
#'  - `default`: A boolean value that indicates whether the role is a default role or not
#'
#'  - `permissions`: A list of permissions which the role contains
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "18a4a60d-d5f0-4099-9c6e-543bf2fd5a1d",
#'    "name": "custom-deployment-editor-role",
#'    "default": false,
#'    "permissions": [
#'      "deployments.list",
#'      "deployments.get",
#'      "deployments.delete"
#'    ]
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param role_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_roles_get <- function(project_name, role_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/roles/{role_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Update a role in a project
#'
#'
#'  ### Description
#'  Update a role in a project. The user making the request must have appropriate permissions.
#'  **Default roles cannot be updated.**
#'
#'  ### Optional Parameters
#'  - `name`: New name for the role. It can only consist of lowercase letters, numbers and dashes (-), and must start with a lowercase letter.
#'
#'  - `permissions`: A new list of permissions which the role will contain. The previous permissions will be replaced with the given ones. The list of available permissions can be obtained with */permissions* endpoint.
#'
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "new-deployment-editor-role",
#'    "permissions": [
#'      "deployments.list",
#'      "deployments.get"
#'    ]
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the updated role
#'  - `id`: Unique identifier for the role (UUID)
#'
#'  - `name`: Name of the updated role
#'
#'  - `default`: A boolean value that indicates whether the role is a default role or not
#'
#'  - `permissions`: A list of permissions which the role contains
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "18a4a60d-d5f0-4099-9c6e-543bf2fd5a1d",
#'    "name": "new-deployment-editor-role",
#'    "default": false,
#'    "permissions": [
#'      "deployments.list",
#'      "deployments.get"
#'    ]
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param role_name descriptionhere
#' @param name descriptionhere
#' @param permissions descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_patch_roles_update <- function(project_name, role_name, name, permissions, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/roles/{role_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::PATCH(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete a role from a project
#'
#'
#'  ### Description
#'  Delete a role from a project. The user making the request must have appropriate permissions.
#'  **Default roles cannot be deleted.**
#'
#' @param project_name name of your project
#' @param role_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_roles_delete <- function(project_name, role_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/roles/{role_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List request schedules
#'
#'
#'  ### Description
#'  List the request schedules in a project. The user has to have 'requests.list' permission on either 'deployments.versions' or 'pipelines' to list the request schedules.
#'
#'  ### Response Structure
#'  A list of details of all request schedules in a project
#'  - `name`: Name of the request
#'
#'  - `object_type`: Type of object for which the request is made
#'
#'  - `object_name`: Name of deployment or pipeline for which the request is made
#'
#'  - `schedule`: Schedule in crontab format
#'
#'  - `version`: Name of version if type of object is 'deployment'
#'
#'  - `request_data`: Input data for the request schedule
#'
#'  - `batch`: Boolean value indicating whether the requests will be performed as batch requests (true) or as direct requests (false)
#'
#'  - `timeout`: Timeout in seconds
#'
#'  - `enabled`: Boolean value indicating whether the request schedule is enabled or disabled
#'
#'  - `creation_date`: The date when the request schedule was created
#'
#'  #### Response Examples
#'  ```
#'  [
#'      {
#'        "id": "b4a06aed-f7ab-48b3-b579-b12b62db8058",
#'        "name": "test-request",
#'        "object_type": "deployment",
#'        "object_name": "test-deployment",
#'        "version": "v1",
#'        "schedule": "0 * 3 * *",
#'        "request_data": {
#'          "input_field_1": 2345,
#'          "input_field_2": 8765
#'        },
#'        "batch": false,
#'        "timeout": 200",
#'        "enabled": true,
#'        "creation_date": "2020-09-16T08:06:34.457679Z"
#'      }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_request_schedules_list <- function(project_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/schedules")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Create request schedules
#'
#'
#'  ### Description
#'  Create a new request schedule with the provided name
#'
#'  ### Required Parameters
#'  - `name`: Name of the request. The name is unique per project. It can only consist of lowercase letters, numbers and dashes (-), and must start with a lowercase letter.
#'
#'  - `object_type`: Type of object for which the request is made. Can be either 'deployment' or 'pipeline'.
#'
#'  - `object_name`: Name of deployment or pipeline for which the request is made
#'
#'  - `schedule`: Schedule in crontab format
#'
#'
#'  ### Optional Parameters
#'  - `version`: Name of version if type of object is 'deployment'
#'
#'  - `request_data`: Input data for the request schedule. For structured deployments/pipelines, it must be a dictionary.
#'
#'  - `batch`: Boolean value indicating whether the requests will be performed as batch requests (true) or as direct requests (false)
#'
#'  - `timeout`: Timeout in seconds. This field is not used for batch requests.
#'
#'  - `enabled`: Boolean value indicating whether the request schedule is enabled or disabled. Default is 'True'.
#'
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "test-request",
#'    "object_type": "deployment",
#'    "object_name": "test-deployment",
#'    "version": "v1",
#'    "schedule": "0 * 3 * *",
#'    "request_data": {
#'      "input_field_1": 2345,
#'      "input_field_2": 8765
#'    },
#'    "batch": false,
#'    "timeout": 300,
#'    "enabled": true
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the created request schedule
#'  - `name`: Name of the request
#'
#'  - `object_type`: Type of object for which the request is made
#'
#'  - `object_name`: Name of deployment or pipeline for which the request is made
#'
#'  - `schedule`: Schedule in crontab format
#'
#'  - `version`: Name of version if type of object is 'deployment'
#'
#'  - `request_data`: Input data for the request schedule
#'
#'  - `batch`: Boolean value indicating whether the requests will be performed as batch requests (true) or as direct requests (false)
#'
#'  - `timeout`: Timeout in seconds
#'
#'  - `enabled`: Boolean value indicating whether the request schedule is enabled or disabled
#'
#'  - `creation_date`: The date when the request schedule was created
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "b4a06aed-f7ab-48b3-b579-b12b62db8058",
#'    "name": "test-request",
#'    "object_type": "deployment",
#'    "object_name": "test-deployment",
#'    "version": "v1",
#'    "schedule": "0 * 3 * *",
#'    "request_data": {
#'      "input_field_1": 2345,
#'      "input_field_2": 8765
#'    },
#'    "batch": false,
#'    "timeout": 300,
#'    "enabled": true,
#'    "creation_date": "2020-09-16T08:06:34.457679Z"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param name descriptionhere
#' @param object_type descriptionhere
#' @param object_name descriptionhere
#' @param version descriptionhere
#' @param schedule descriptionhere
#' @param request_data descriptionhere
#' @param batch descriptionhere
#' @param timeout descriptionhere
#' @param enabled descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_request_schedules_create <- function(project_name, name, object_type, object_name, version, schedule, request_data, batch, timeout, enabled, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/schedules")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get details of a request schedule
#'
#'
#'  ### Description
#'  Retrieve details of a single request schedule
#'
#'  ### Response Structure
#'  Details of a request schedule
#'  - `name`: Name of the request
#'
#'  - `object_type`: Type of object for which the request is made
#'
#'  - `object_name`: Name of deployment or pipeline for which the request is made
#'
#'  - `schedule`: Schedule in crontab format
#'
#'  - `version`: Name of version if type of object is 'deployment'
#'
#'  - `request_data`: Input data for the request schedule
#'
#'  - `batch`: Boolean value indicating whether the requests will be performed as batch requests (true) or as direct requests (false)
#'
#'  - `timeout`: Timeout in seconds
#'
#'  - `enabled`: Boolean value indicating whether the request schedule is enabled or disabled
#'
#'  - `creation_date`: The date when the request schedule was created
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "b4a06aed-f7ab-48b3-b579-b12b62db8058",
#'    "name": "test-request",
#'    "object_type": "deployment",
#'    "object_name": "test-deployment",
#'    "version": "v1",
#'    "schedule": "0 * 3 * *",
#'    "request_data": {
#'      "input_field_1": 2345,
#'      "input_field_2": 8765
#'    },
#'    "batch": false,
#'    "timeout": 200,
#'    "enabled": true,
#'    "creation_date": "2020-09-16T08:06:34.457679Z"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param schedule_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_request_schedules_get <- function(project_name, schedule_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/schedules/{schedule_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Update a request schedule
#'
#'
#'  ### Description
#'  Update a request schedule in a project. Create permissions on the object are necessary for this action.
#'
#'  ### Optional Parameters
#'  - `name`: Name of the request. The name is unique per project. It can only consist of lowercase letters, numbers and dashes (-), and must start with a lowercase letter.
#'
#'  - `schedule`: Schedule in crontab format
#'
#'  - `request_data`: Input data for the request schedule. For structured deployments/pipelines, it must be a dictionary.
#'
#'  - `batch`: Boolean value indicating whether the requests will be performed as batch requests (true) or as direct requests (false)
#'
#'  - `timeout`: Timeout in seconds
#'
#'  - `enabled`: Boolean value indicating whether the request schedule is enabled or disabled. Default is 'True'.
#'
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "test-request",
#'    "schedule": "0 * 3 * *",
#'    "request_data": {
#'      "input_field_1": 2345,
#'      "input_field_2": 8765
#'    },
#'    "batch": true,
#'    "timeout": 360,
#'    "enabled": false
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the updated request schedule
#'  - `name`: Name of the request
#'
#'  - `object_type`: Type of object for which the request is made
#'
#'  - `object_name`: Name of deployment or pipeline for which the request is made
#'
#'  - `schedule`: Schedule in crontab format
#'
#'  - `version`: Name of version if type of object is 'deployment'
#'
#'  - `request_data`: Input data for the request schedule
#'
#'  - `batch`: Boolean value indicating whether the requests will be performed as batch requests (true) or as direct requests (false)
#'
#'  - `timeout`: Timeout in seconds
#'
#'  - `enabled`: Boolean value indicating whether the request schedule is enabled or disabled
#'
#'  - `creation_date`: The date when the request schedule was created
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "b4a06aed-f7ab-48b3-b579-b12b62db8058",
#'    "name": "test-request",
#'    "object_type": "deployment",
#'    "object_name": "test-deployment",
#'    "version": "v1",
#'    "schedule": "0 * 3 * *",
#'    "request_data": {
#'      "input_field_1": 2345,
#'      "input_field_2": 8765
#'    },
#'    "batch": false,
#'    "timeout": 360,
#'    "enabled": true,
#'    "creation_date": "2020-09-16T08:06:34.457679Z"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param schedule_name descriptionhere
#' @param name descriptionhere
#' @param schedule descriptionhere
#' @param request_data descriptionhere
#' @param batch descriptionhere
#' @param timeout descriptionhere
#' @param enabled descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_patch_request_schedules_update <- function(project_name, schedule_name, name, schedule, request_data, batch, timeout, enabled, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/schedules/{schedule_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::PATCH(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete a request schedule
#'
#'
#'  ### Description
#'  Delete the request schedule from the project.
#'
#'  If you want to temporarily disable a request schedule, update the request with `enabled` set to False.
#'
#' @param project_name name of your project
#' @param schedule_name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_request_schedules_delete <- function(project_name, schedule_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/schedules/{schedule_name}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List service users
#'
#'
#'  ### Description
#'  List service users defined in a project
#'
#'  ### Response Structure
#'  List of details of the service users:
#'  - `id`: Unique identifier for the service user (UUID)
#'
#'  - `email`: Email of the service user
#'
#'  - `name`: Name of the service user
#'
#'  - `creation_date`: Date when the service user was created
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "537bca64-5ab6-43eb-a7ef-1638bc30b6ed",
#'      "email": "537bca64-5ab6-43eb-a7ef-1638bc30b6ed.project1@serviceuser.ubiops.com",
#'      "name": "service-user-1",
#'      "creation_date": "2020-03-24T09:16:27.504+00:00"
#'    },
#'    {
#'      "id": "13a9ba27-6888-4528-826e-8e1002eab13d",
#'      "email": "13a9ba27-6888-4528-826e-8e1002eab13d.project1@serviceuser.ubiops.com",
#'      "name": "service-user-2",
#'      "creation_date": "2020-03-26T12:18:43.123+00:00"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_service_users_list <- function(project_name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/service-users")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Create a new service user
#'
#'
#'  ### Description
#'  Create a new service user. A unique email is generated for the service user. Additionally, a token for this service user is generated. This token can be used to authorize requests sent to our API.
#'
#'  The token is **ONLY** returned on creation and will not be accessible afterwards.
#'
#'  ### Optional Parameters
#'  - `name`: Name of the service user
#'
#'
#'  #### Request Examples
#'  ```
#'  {
#'    "name": "service-user-1"
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the created service user
#'  - `id`: Unique identifier for the service user (UUID)
#'
#'  - `email`: Email of the service user
#'
#'  - `token`: The API token for the created service user
#'
#'  - `name`: Name of the service user
#'
#'  - `creation_date`: Date when the service user was created
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "13a9ba27-6888-4528-826e-8e1002eab13d",
#'    "email": "13a9ba27-6888-4528-826e-8e1002eab13d.project1@serviceuser.ubiops.com",
#'    "token": "e962d9190348af7fa8d233d75cff7385b4335f81",
#'    "name": "service-user-1",
#'    "creation_date": "2020-03-24T09:16:27.504+00:00"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_post_service_users_create <- function(project_name, name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/service-users")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::POST(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Retrieve details of a service user
#'
#'
#'  ### Description
#'  Retrieve details of a service user
#'
#'  ### Response Structure
#'  Details of the service user
#'  - `id`: Unique identifier for the service user (UUID)
#'
#'  - `email`: Email of the service user
#'
#'  - `name`: Name of the service user
#'
#'  - `creation_date`: Date when the service user was created
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "13a9ba27-6888-4528-826e-8e1002eab13d",
#'    "email": "13a9ba27-6888-4528-826e-8e1002eab13d.project1@serviceuser.ubiops.com",
#'    "name": "new-service-user-name",
#'    "creation_date": "2020-03-26T12:18:43.123+00:00"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param service_user_id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_service_users_get <- function(project_name, service_user_id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/service-users/{service_user_id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Update service user details
#'
#'
#'  ### Description
#'  Update the name of a service user
#'
#'  ### Optional Parameters
#'  - `name`: Name of the service user
#'
#'
#'  #### Request Examples
#'
#'  ```
#'  {
#'    "name": "new-service-user-name",
#'  }
#'  ```
#'
#'  ### Response Structure
#'  Details of the updated service user
#'  - `id`: Unique identifier for the service user (UUID)
#'
#'  - `email`: Email of the service user
#'
#'  - `name`: Name of the service user
#'
#'  - `creation_date`: Date when the service user was created
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "id": "13a9ba27-6888-4528-826e-8e1002eab13d",
#'    "email": "13a9ba27-6888-4528-826e-8e1002eab13d.project1@serviceuser.ubiops.com",
#'    "name": "new-service-user-name",
#'    "creation_date": "2020-03-26T12:18:43.123+00:00"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param service_user_id descriptionhere
#' @param name descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_patch_service_users_update <- function(project_name, service_user_id, name, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/service-users/{service_user_id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::PATCH(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Delete service user
#'
#'
#'  ### Description
#'  Delete a service user from a project
#'
#' @param project_name name of your project
#' @param service_user_id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_delete_service_users_delete <- function(project_name, service_user_id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/service-users/{service_user_id}")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::DELETE(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Reset the token of a service user
#'
#'
#'  ### Description
#'  Reset the token of a service user. The old token will be deleted and a new one will be created for the service user. No data should be sent in the body of the request.
#'
#'  ### Response Structure
#'  Details of the new token for the service user
#'  - `token`: The new API token for the service user
#'
#'  #### Response Examples
#'  ```
#'  {
#'    "token": "e962d9190348af7fa8d233d75cff7385b4335f81"
#'  }
#'  ```
#'
#' @param project_name name of your project
#' @param service_user_id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_put_service_users_token <- function(project_name, service_user_id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/service-users/{service_user_id}/token")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::PUT(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' Get resource usage
#'
#'
#'  ### Description
#'  Get resource usage for the project. This returns a list of metrics that are used for billing, aggregated per month.
#'
#'  ### Optional Parameters
#'  - `start_month`: date indicating the start month to fetch usage data from, formatted `YYYY-MM`. If omitted results are generated from one year ago.
#'
#'  ### Response Structure
#'   - `metric`: The metric that was measured
#'   - `object_type`: Type of object the metric was measured for (version or pipeline)
#'   - `usage`: an array of objects each containing the following:
#'       - `month`: Timestamp denoting the start of the month
#'       - `value`: Aggregated metric value for the given unit over the given month
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "object_type": "pipeline",
#'      "metric": "input_volume",
#'      "usage": [
#'        {
#'          "month": "2019-08-01T00:00:00Z",
#'          "value": 1840
#'        },
#'        {
#'          "month": "2019-09-01T00:00:00Z",
#'          "value": 400
#'        },
#'        {
#'          "month": "2019-10-01T00:00:00Z",
#'          "value": 1204
#'        },
#'        {
#'          "month": "2019-11-01T00:00:00Z",
#'          "value": 1598
#'        },
#'        {
#'          "month": "2019-12-01T00:00:00Z",
#'          "value": 824
#'        },
#'        {
#'          "month": "2020-01-01T00:00:00Z",
#'          "value": 2036
#'        },
#'        {
#'          "month": "2020-02-01T00:00:00Z",
#'          "value": 1438
#'        },
#'        {
#'          "month": "2020-03-01T00:00:00Z",
#'          "value": 932
#'        },
#'        {
#'          "month": "2020-04-01T00:00:00Z",
#'          "value": 528
#'        },
#'        {
#'          "month": "2020-05-01T00:00:00Z",
#'          "value": 1484
#'        },
#'        {
#'          "month": "2020-06-01T00:00:00Z",
#'          "value": 1942
#'        },
#'        {
#'          "month": "2020-07-01T00:00:00Z",
#'          "value": 1332
#'        }
#'      ]
#'    }
#'  ]
#'
#'  ```
#'
#' @param project_name name of your project
#' @param start_month descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_project_usage_get <- function(project_name, start_month, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/usage")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}

#' List the roles assigned to a specific user in a project
#'
#'
#'  ### Description
#'  List the roles assigned to a user in the scope of a project.
#'
#'  ### Response Structure
#'  - `id`: Unique identifier for the role assignment (UUID)
#'
#'  - `user_id`: Unique identifier for the user (UUID)
#'
#'  - `role`: Name of the role assigned to the user
#'
#'  - `object_name`: Name of the object for which the role is assigned
#'
#'  - `object_type`: Type of the object for which the role is assigned. It can be project, deployment or pipeline.
#'
#'  #### Response Examples
#'  ```
#'  [
#'    {
#'      "id": "e988ddc0-3ef1-42d2-ab30-9f810a5e7063",
#'      "user_id": "02b77d8f-b312-47ef-990f-4685a7ab9363",
#'      "role": "deployment-viewer",
#'      "object_name": "deployment-1",
#'      "object_type": "deployment"
#'    },
#'    {
#'      "id": "13cf9dd7-7356-4797-b453-e0cb6b416162",
#'      "user_id": "02b77d8f-b312-47ef-990f-4685a7ab9363",
#'      "role": "pipeline-admin",
#'      "object_name": "pipeline-1",
#'      "object_type": "pipeline"
#'    }
#'  ]
#'  ```
#'
#' @param project_name name of your project
#' @param user_id descriptionhere
#' @param UBIOPS_TOKEN default NULL will search for token in environment
#' @return descriptionhere
#' @export
uo_get_role_assignments_per_user_list <- function(project_name, user_id, UBIOPS_TOKEN=NULL){
    endpoint=glue::glue("{base}/projects/{project_name}/users/{user_id}/role-assignments")
        tk <- check_ubiobstoken(UBIOPS_TOKEN)
        h  <- create_headers(tk)
    body<-'somethinghere'
    res <- httr::GET(url=endpoint,body=body,encode = "json",h)
    httr::stop_for_status(res)
    httr::content(res)
}
RMHogervorst/ubiopscontroller documentation built on May 25, 2021, 5:26 p.m.