mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-10-30 15:45:05 +01:00
Merge branch '135-batch-scheduler-integration' of github.com:ClusterCockpit/cc-backend into 135-batch-scheduler-integration
This commit is contained in:
24
internal/api/0.0.37/.gitignore
vendored
24
internal/api/0.0.37/.gitignore
vendored
@@ -1,24 +0,0 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
@@ -1,23 +0,0 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
||||
@@ -1,58 +0,0 @@
|
||||
.gitignore
|
||||
.openapi-generator-ignore
|
||||
.travis.yml
|
||||
README.md
|
||||
api/openapi.yaml
|
||||
api_openapi.go
|
||||
api_slurm.go
|
||||
client.go
|
||||
configuration.go
|
||||
docs/OpenapiAPI.md
|
||||
docs/SlurmAPI.md
|
||||
docs/V0037Diag.md
|
||||
docs/V0037DiagStatistics.md
|
||||
docs/V0037Error.md
|
||||
docs/V0037JobProperties.md
|
||||
docs/V0037JobResources.md
|
||||
docs/V0037JobResponseProperties.md
|
||||
docs/V0037JobSubmission.md
|
||||
docs/V0037JobSubmissionResponse.md
|
||||
docs/V0037JobsResponse.md
|
||||
docs/V0037Node.md
|
||||
docs/V0037NodeAllocation.md
|
||||
docs/V0037NodesResponse.md
|
||||
docs/V0037Partition.md
|
||||
docs/V0037PartitionsResponse.md
|
||||
docs/V0037Ping.md
|
||||
docs/V0037Pings.md
|
||||
docs/V0037Reservation.md
|
||||
docs/V0037ReservationPurgeCompleted.md
|
||||
docs/V0037ReservationsResponse.md
|
||||
docs/V0037Signal.md
|
||||
git_push.sh
|
||||
go.mod
|
||||
go.sum
|
||||
model_v0_0_37_diag.go
|
||||
model_v0_0_37_diag_statistics.go
|
||||
model_v0_0_37_error.go
|
||||
model_v0_0_37_job_properties.go
|
||||
model_v0_0_37_job_resources.go
|
||||
model_v0_0_37_job_response_properties.go
|
||||
model_v0_0_37_job_submission.go
|
||||
model_v0_0_37_job_submission_response.go
|
||||
model_v0_0_37_jobs_response.go
|
||||
model_v0_0_37_node.go
|
||||
model_v0_0_37_node_allocation.go
|
||||
model_v0_0_37_nodes_response.go
|
||||
model_v0_0_37_partition.go
|
||||
model_v0_0_37_partitions_response.go
|
||||
model_v0_0_37_ping.go
|
||||
model_v0_0_37_pings.go
|
||||
model_v0_0_37_reservation.go
|
||||
model_v0_0_37_reservation_purge_completed.go
|
||||
model_v0_0_37_reservations_response.go
|
||||
model_v0_0_37_signal.go
|
||||
response.go
|
||||
test/api_openapi_test.go
|
||||
test/api_slurm_test.go
|
||||
utils.go
|
||||
@@ -1 +0,0 @@
|
||||
7.0.0-SNAPSHOT
|
||||
@@ -1,8 +0,0 @@
|
||||
language: go
|
||||
|
||||
install:
|
||||
- go get -d -v .
|
||||
|
||||
script:
|
||||
- go build -v ./
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
# Go API client for openapi
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
## Overview
|
||||
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.
|
||||
|
||||
- API version: 0.0.37
|
||||
- Package version: 1.0.0
|
||||
- Build package: org.openapitools.codegen.languages.GoClientCodegen
|
||||
For more information, please visit [https://www.schedmd.com/](https://www.schedmd.com/)
|
||||
|
||||
## Installation
|
||||
|
||||
Install the following dependencies:
|
||||
|
||||
```shell
|
||||
go get github.com/stretchr/testify/assert
|
||||
go get golang.org/x/net/context
|
||||
```
|
||||
|
||||
Put the package under your project folder and add the following in import:
|
||||
|
||||
```golang
|
||||
import openapi "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
```
|
||||
|
||||
To use a proxy, set the environment variable `HTTP_PROXY`:
|
||||
|
||||
```golang
|
||||
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
|
||||
```
|
||||
|
||||
## Configuration of Server URL
|
||||
|
||||
Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.
|
||||
|
||||
### Select Server Configuration
|
||||
|
||||
For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`.
|
||||
|
||||
```golang
|
||||
ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)
|
||||
```
|
||||
|
||||
### Templated Server URL
|
||||
|
||||
Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`.
|
||||
|
||||
```golang
|
||||
ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
|
||||
"basePath": "v2",
|
||||
})
|
||||
```
|
||||
|
||||
Note, enum values are always validated and all unused variables are silently ignored.
|
||||
|
||||
### URLs Configuration per Operation
|
||||
|
||||
Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
|
||||
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
|
||||
Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps.
|
||||
|
||||
```golang
|
||||
ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
|
||||
"{classname}Service.{nickname}": 2,
|
||||
})
|
||||
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
|
||||
"{classname}Service.{nickname}": {
|
||||
"port": "8443",
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://localhost/slurm/v0.0.37*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*OpenapiAPI* | [**OpenapiGet**](docs/OpenapiAPI.md#openapiget) | **Get** /openapi | Retrieve OpenAPI Specification
|
||||
*OpenapiAPI* | [**OpenapiJsonGet**](docs/OpenapiAPI.md#openapijsonget) | **Get** /openapi.json | Retrieve OpenAPI Specification
|
||||
*OpenapiAPI* | [**OpenapiV3Get**](docs/OpenapiAPI.md#openapiv3get) | **Get** /openapi/v3 | Retrieve OpenAPI Specification
|
||||
*OpenapiAPI* | [**OpenapiYamlGet**](docs/OpenapiAPI.md#openapiyamlget) | **Get** /openapi.yaml | Retrieve OpenAPI Specification
|
||||
*SlurmAPI* | [**SlurmctldCancelJob**](docs/SlurmAPI.md#slurmctldcanceljob) | **Delete** /job/{job_id} | cancel or signal job
|
||||
*SlurmAPI* | [**SlurmctldDiag**](docs/SlurmAPI.md#slurmctlddiag) | **Get** /diag/ | get diagnostics
|
||||
*SlurmAPI* | [**SlurmctldGetJob**](docs/SlurmAPI.md#slurmctldgetjob) | **Get** /job/{job_id} | get job info
|
||||
*SlurmAPI* | [**SlurmctldGetJobs**](docs/SlurmAPI.md#slurmctldgetjobs) | **Get** /jobs/ | get list of jobs
|
||||
*SlurmAPI* | [**SlurmctldGetNode**](docs/SlurmAPI.md#slurmctldgetnode) | **Get** /node/{node_name} | get node info
|
||||
*SlurmAPI* | [**SlurmctldGetNodes**](docs/SlurmAPI.md#slurmctldgetnodes) | **Get** /nodes/ | get all node info
|
||||
*SlurmAPI* | [**SlurmctldGetPartition**](docs/SlurmAPI.md#slurmctldgetpartition) | **Get** /partition/{partition_name} | get partition info
|
||||
*SlurmAPI* | [**SlurmctldGetPartitions**](docs/SlurmAPI.md#slurmctldgetpartitions) | **Get** /partitions/ | get all partition info
|
||||
*SlurmAPI* | [**SlurmctldGetReservation**](docs/SlurmAPI.md#slurmctldgetreservation) | **Get** /reservation/{reservation_name} | get reservation info
|
||||
*SlurmAPI* | [**SlurmctldGetReservations**](docs/SlurmAPI.md#slurmctldgetreservations) | **Get** /reservations/ | get all reservation info
|
||||
*SlurmAPI* | [**SlurmctldPing**](docs/SlurmAPI.md#slurmctldping) | **Get** /ping/ | ping test
|
||||
*SlurmAPI* | [**SlurmctldSubmitJob**](docs/SlurmAPI.md#slurmctldsubmitjob) | **Post** /job/submit | submit new job
|
||||
*SlurmAPI* | [**SlurmctldUpdateJob**](docs/SlurmAPI.md#slurmctldupdatejob) | **Post** /job/{job_id} | update job
|
||||
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
- [V0037Diag](docs/V0037Diag.md)
|
||||
- [V0037DiagStatistics](docs/V0037DiagStatistics.md)
|
||||
- [V0037Error](docs/V0037Error.md)
|
||||
- [V0037JobProperties](docs/V0037JobProperties.md)
|
||||
- [V0037JobResources](docs/V0037JobResources.md)
|
||||
- [V0037JobResponseProperties](docs/V0037JobResponseProperties.md)
|
||||
- [V0037JobSubmission](docs/V0037JobSubmission.md)
|
||||
- [V0037JobSubmissionResponse](docs/V0037JobSubmissionResponse.md)
|
||||
- [V0037JobsResponse](docs/V0037JobsResponse.md)
|
||||
- [V0037Node](docs/V0037Node.md)
|
||||
- [V0037NodeAllocation](docs/V0037NodeAllocation.md)
|
||||
- [V0037NodesResponse](docs/V0037NodesResponse.md)
|
||||
- [V0037Partition](docs/V0037Partition.md)
|
||||
- [V0037PartitionsResponse](docs/V0037PartitionsResponse.md)
|
||||
- [V0037Ping](docs/V0037Ping.md)
|
||||
- [V0037Pings](docs/V0037Pings.md)
|
||||
- [V0037Reservation](docs/V0037Reservation.md)
|
||||
- [V0037ReservationPurgeCompleted](docs/V0037ReservationPurgeCompleted.md)
|
||||
- [V0037ReservationsResponse](docs/V0037ReservationsResponse.md)
|
||||
- [V0037Signal](docs/V0037Signal.md)
|
||||
|
||||
|
||||
## Documentation For Authorization
|
||||
|
||||
|
||||
Authentication schemes defined for the API:
|
||||
### user
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: X-SLURM-USER-NAME
|
||||
- **Location**: HTTP header
|
||||
|
||||
Note, each API key must be added to a map of `map[string]APIKey` where the key is: X-SLURM-USER-NAME and passed in as the auth context for each request.
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
auth := context.WithValue(
|
||||
context.Background(),
|
||||
sw.ContextAPIKeys,
|
||||
map[string]sw.APIKey{
|
||||
"X-SLURM-USER-NAME": {Key: "API_KEY_STRING"},
|
||||
},
|
||||
)
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
||||
### token
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: X-SLURM-USER-TOKEN
|
||||
- **Location**: HTTP header
|
||||
|
||||
Note, each API key must be added to a map of `map[string]APIKey` where the key is: X-SLURM-USER-TOKEN and passed in as the auth context for each request.
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
auth := context.WithValue(
|
||||
context.Background(),
|
||||
sw.ContextAPIKeys,
|
||||
map[string]sw.APIKey{
|
||||
"X-SLURM-USER-TOKEN": {Key: "API_KEY_STRING"},
|
||||
},
|
||||
)
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
||||
|
||||
## Documentation for Utility Methods
|
||||
|
||||
Due to the fact that model structure members are all pointers, this package contains
|
||||
a number of utility functions to easily obtain pointers to values of basic types.
|
||||
Each of these functions takes a value of the given basic type and returns a pointer to it:
|
||||
|
||||
* `PtrBool`
|
||||
* `PtrInt`
|
||||
* `PtrInt32`
|
||||
* `PtrInt64`
|
||||
* `PtrFloat`
|
||||
* `PtrFloat32`
|
||||
* `PtrFloat64`
|
||||
* `PtrString`
|
||||
* `PtrTime`
|
||||
|
||||
## Author
|
||||
|
||||
sales@schedmd.com
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,480 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
|
||||
// OpenapiAPIService OpenapiAPI service
|
||||
type OpenapiAPIService service
|
||||
|
||||
type ApiOpenapiGetRequest struct {
|
||||
ctx context.Context
|
||||
ApiService *OpenapiAPIService
|
||||
}
|
||||
|
||||
func (r ApiOpenapiGetRequest) Execute() (*http.Response, error) {
|
||||
return r.ApiService.OpenapiGetExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
OpenapiGet Retrieve OpenAPI Specification
|
||||
|
||||
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
@return ApiOpenapiGetRequest
|
||||
*/
|
||||
func (a *OpenapiAPIService) OpenapiGet(ctx context.Context) ApiOpenapiGetRequest {
|
||||
return ApiOpenapiGetRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// Execute executes the request
|
||||
func (a *OpenapiAPIService) OpenapiGetExecute(r ApiOpenapiGetRequest) (*http.Response, error) {
|
||||
var (
|
||||
localVarHTTPMethod = http.MethodGet
|
||||
localVarPostBody interface{}
|
||||
formFiles []formFile
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OpenapiAPIService.OpenapiGet")
|
||||
if err != nil {
|
||||
return nil, &GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
|
||||
localVarPath := localBasePath + "/openapi"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHTTPContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
||||
if localVarHTTPContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHTTPHeaderAccepts := []string{}
|
||||
|
||||
// set Accept header
|
||||
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
||||
if localVarHTTPHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
||||
}
|
||||
if r.ctx != nil {
|
||||
// API Key Authentication
|
||||
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
||||
if apiKey, ok := auth["user"]; ok {
|
||||
var key string
|
||||
if apiKey.Prefix != "" {
|
||||
key = apiKey.Prefix + " " + apiKey.Key
|
||||
} else {
|
||||
key = apiKey.Key
|
||||
}
|
||||
localVarHeaderParams["X-SLURM-USER-NAME"] = key
|
||||
}
|
||||
}
|
||||
}
|
||||
if r.ctx != nil {
|
||||
// API Key Authentication
|
||||
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
||||
if apiKey, ok := auth["token"]; ok {
|
||||
var key string
|
||||
if apiKey.Prefix != "" {
|
||||
key = apiKey.Prefix + " " + apiKey.Key
|
||||
} else {
|
||||
key = apiKey.Key
|
||||
}
|
||||
localVarHeaderParams["X-SLURM-USER-TOKEN"] = key
|
||||
}
|
||||
}
|
||||
}
|
||||
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHTTPResponse, err := a.client.callAPI(req)
|
||||
if err != nil || localVarHTTPResponse == nil {
|
||||
return localVarHTTPResponse, err
|
||||
}
|
||||
|
||||
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
||||
localVarHTTPResponse.Body.Close()
|
||||
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
||||
if err != nil {
|
||||
return localVarHTTPResponse, err
|
||||
}
|
||||
|
||||
if localVarHTTPResponse.StatusCode >= 300 {
|
||||
newErr := &GenericOpenAPIError{
|
||||
body: localVarBody,
|
||||
error: localVarHTTPResponse.Status,
|
||||
}
|
||||
return localVarHTTPResponse, newErr
|
||||
}
|
||||
|
||||
return localVarHTTPResponse, nil
|
||||
}
|
||||
|
||||
type ApiOpenapiJsonGetRequest struct {
|
||||
ctx context.Context
|
||||
ApiService *OpenapiAPIService
|
||||
}
|
||||
|
||||
func (r ApiOpenapiJsonGetRequest) Execute() (*http.Response, error) {
|
||||
return r.ApiService.OpenapiJsonGetExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
OpenapiJsonGet Retrieve OpenAPI Specification
|
||||
|
||||
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
@return ApiOpenapiJsonGetRequest
|
||||
*/
|
||||
func (a *OpenapiAPIService) OpenapiJsonGet(ctx context.Context) ApiOpenapiJsonGetRequest {
|
||||
return ApiOpenapiJsonGetRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// Execute executes the request
|
||||
func (a *OpenapiAPIService) OpenapiJsonGetExecute(r ApiOpenapiJsonGetRequest) (*http.Response, error) {
|
||||
var (
|
||||
localVarHTTPMethod = http.MethodGet
|
||||
localVarPostBody interface{}
|
||||
formFiles []formFile
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OpenapiAPIService.OpenapiJsonGet")
|
||||
if err != nil {
|
||||
return nil, &GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
|
||||
localVarPath := localBasePath + "/openapi.json"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHTTPContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
||||
if localVarHTTPContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHTTPHeaderAccepts := []string{}
|
||||
|
||||
// set Accept header
|
||||
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
||||
if localVarHTTPHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
||||
}
|
||||
if r.ctx != nil {
|
||||
// API Key Authentication
|
||||
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
||||
if apiKey, ok := auth["user"]; ok {
|
||||
var key string
|
||||
if apiKey.Prefix != "" {
|
||||
key = apiKey.Prefix + " " + apiKey.Key
|
||||
} else {
|
||||
key = apiKey.Key
|
||||
}
|
||||
localVarHeaderParams["X-SLURM-USER-NAME"] = key
|
||||
}
|
||||
}
|
||||
}
|
||||
if r.ctx != nil {
|
||||
// API Key Authentication
|
||||
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
||||
if apiKey, ok := auth["token"]; ok {
|
||||
var key string
|
||||
if apiKey.Prefix != "" {
|
||||
key = apiKey.Prefix + " " + apiKey.Key
|
||||
} else {
|
||||
key = apiKey.Key
|
||||
}
|
||||
localVarHeaderParams["X-SLURM-USER-TOKEN"] = key
|
||||
}
|
||||
}
|
||||
}
|
||||
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHTTPResponse, err := a.client.callAPI(req)
|
||||
if err != nil || localVarHTTPResponse == nil {
|
||||
return localVarHTTPResponse, err
|
||||
}
|
||||
|
||||
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
||||
localVarHTTPResponse.Body.Close()
|
||||
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
||||
if err != nil {
|
||||
return localVarHTTPResponse, err
|
||||
}
|
||||
|
||||
if localVarHTTPResponse.StatusCode >= 300 {
|
||||
newErr := &GenericOpenAPIError{
|
||||
body: localVarBody,
|
||||
error: localVarHTTPResponse.Status,
|
||||
}
|
||||
return localVarHTTPResponse, newErr
|
||||
}
|
||||
|
||||
return localVarHTTPResponse, nil
|
||||
}
|
||||
|
||||
type ApiOpenapiV3GetRequest struct {
|
||||
ctx context.Context
|
||||
ApiService *OpenapiAPIService
|
||||
}
|
||||
|
||||
func (r ApiOpenapiV3GetRequest) Execute() (*http.Response, error) {
|
||||
return r.ApiService.OpenapiV3GetExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
OpenapiV3Get Retrieve OpenAPI Specification
|
||||
|
||||
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
@return ApiOpenapiV3GetRequest
|
||||
*/
|
||||
func (a *OpenapiAPIService) OpenapiV3Get(ctx context.Context) ApiOpenapiV3GetRequest {
|
||||
return ApiOpenapiV3GetRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// Execute executes the request
|
||||
func (a *OpenapiAPIService) OpenapiV3GetExecute(r ApiOpenapiV3GetRequest) (*http.Response, error) {
|
||||
var (
|
||||
localVarHTTPMethod = http.MethodGet
|
||||
localVarPostBody interface{}
|
||||
formFiles []formFile
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OpenapiAPIService.OpenapiV3Get")
|
||||
if err != nil {
|
||||
return nil, &GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
|
||||
localVarPath := localBasePath + "/openapi/v3"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHTTPContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
||||
if localVarHTTPContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHTTPHeaderAccepts := []string{}
|
||||
|
||||
// set Accept header
|
||||
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
||||
if localVarHTTPHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
||||
}
|
||||
if r.ctx != nil {
|
||||
// API Key Authentication
|
||||
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
||||
if apiKey, ok := auth["user"]; ok {
|
||||
var key string
|
||||
if apiKey.Prefix != "" {
|
||||
key = apiKey.Prefix + " " + apiKey.Key
|
||||
} else {
|
||||
key = apiKey.Key
|
||||
}
|
||||
localVarHeaderParams["X-SLURM-USER-NAME"] = key
|
||||
}
|
||||
}
|
||||
}
|
||||
if r.ctx != nil {
|
||||
// API Key Authentication
|
||||
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
||||
if apiKey, ok := auth["token"]; ok {
|
||||
var key string
|
||||
if apiKey.Prefix != "" {
|
||||
key = apiKey.Prefix + " " + apiKey.Key
|
||||
} else {
|
||||
key = apiKey.Key
|
||||
}
|
||||
localVarHeaderParams["X-SLURM-USER-TOKEN"] = key
|
||||
}
|
||||
}
|
||||
}
|
||||
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHTTPResponse, err := a.client.callAPI(req)
|
||||
if err != nil || localVarHTTPResponse == nil {
|
||||
return localVarHTTPResponse, err
|
||||
}
|
||||
|
||||
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
||||
localVarHTTPResponse.Body.Close()
|
||||
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
||||
if err != nil {
|
||||
return localVarHTTPResponse, err
|
||||
}
|
||||
|
||||
if localVarHTTPResponse.StatusCode >= 300 {
|
||||
newErr := &GenericOpenAPIError{
|
||||
body: localVarBody,
|
||||
error: localVarHTTPResponse.Status,
|
||||
}
|
||||
return localVarHTTPResponse, newErr
|
||||
}
|
||||
|
||||
return localVarHTTPResponse, nil
|
||||
}
|
||||
|
||||
type ApiOpenapiYamlGetRequest struct {
|
||||
ctx context.Context
|
||||
ApiService *OpenapiAPIService
|
||||
}
|
||||
|
||||
func (r ApiOpenapiYamlGetRequest) Execute() (*http.Response, error) {
|
||||
return r.ApiService.OpenapiYamlGetExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
OpenapiYamlGet Retrieve OpenAPI Specification
|
||||
|
||||
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
@return ApiOpenapiYamlGetRequest
|
||||
*/
|
||||
func (a *OpenapiAPIService) OpenapiYamlGet(ctx context.Context) ApiOpenapiYamlGetRequest {
|
||||
return ApiOpenapiYamlGetRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// Execute executes the request
|
||||
func (a *OpenapiAPIService) OpenapiYamlGetExecute(r ApiOpenapiYamlGetRequest) (*http.Response, error) {
|
||||
var (
|
||||
localVarHTTPMethod = http.MethodGet
|
||||
localVarPostBody interface{}
|
||||
formFiles []formFile
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OpenapiAPIService.OpenapiYamlGet")
|
||||
if err != nil {
|
||||
return nil, &GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
|
||||
localVarPath := localBasePath + "/openapi.yaml"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHTTPContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
||||
if localVarHTTPContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHTTPHeaderAccepts := []string{}
|
||||
|
||||
// set Accept header
|
||||
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
||||
if localVarHTTPHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
||||
}
|
||||
if r.ctx != nil {
|
||||
// API Key Authentication
|
||||
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
||||
if apiKey, ok := auth["user"]; ok {
|
||||
var key string
|
||||
if apiKey.Prefix != "" {
|
||||
key = apiKey.Prefix + " " + apiKey.Key
|
||||
} else {
|
||||
key = apiKey.Key
|
||||
}
|
||||
localVarHeaderParams["X-SLURM-USER-NAME"] = key
|
||||
}
|
||||
}
|
||||
}
|
||||
if r.ctx != nil {
|
||||
// API Key Authentication
|
||||
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
|
||||
if apiKey, ok := auth["token"]; ok {
|
||||
var key string
|
||||
if apiKey.Prefix != "" {
|
||||
key = apiKey.Prefix + " " + apiKey.Key
|
||||
} else {
|
||||
key = apiKey.Key
|
||||
}
|
||||
localVarHeaderParams["X-SLURM-USER-TOKEN"] = key
|
||||
}
|
||||
}
|
||||
}
|
||||
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHTTPResponse, err := a.client.callAPI(req)
|
||||
if err != nil || localVarHTTPResponse == nil {
|
||||
return localVarHTTPResponse, err
|
||||
}
|
||||
|
||||
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
||||
localVarHTTPResponse.Body.Close()
|
||||
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
||||
if err != nil {
|
||||
return localVarHTTPResponse, err
|
||||
}
|
||||
|
||||
if localVarHTTPResponse.StatusCode >= 300 {
|
||||
newErr := &GenericOpenAPIError{
|
||||
body: localVarBody,
|
||||
error: localVarHTTPResponse.Status,
|
||||
}
|
||||
return localVarHTTPResponse, newErr
|
||||
}
|
||||
|
||||
return localVarHTTPResponse, nil
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,666 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
)
|
||||
|
||||
var (
|
||||
jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`)
|
||||
xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`)
|
||||
queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`)
|
||||
queryDescape = strings.NewReplacer( "%5B", "[", "%5D", "]" )
|
||||
)
|
||||
|
||||
// APIClient manages communication with the Slurm Rest API API v0.0.37
|
||||
// In most cases there should be only one, shared, APIClient.
|
||||
type APIClient struct {
|
||||
cfg *Configuration
|
||||
common service // Reuse a single struct instead of allocating one for each service on the heap.
|
||||
|
||||
// API Services
|
||||
|
||||
OpenapiAPI *OpenapiAPIService
|
||||
|
||||
SlurmAPI *SlurmAPIService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *APIClient
|
||||
}
|
||||
|
||||
// NewAPIClient creates a new API client. Requires a userAgent string describing your application.
|
||||
// optionally a custom http.Client to allow for advanced features such as caching.
|
||||
func NewAPIClient(cfg *Configuration) *APIClient {
|
||||
if cfg.HTTPClient == nil {
|
||||
cfg.HTTPClient = http.DefaultClient
|
||||
}
|
||||
|
||||
c := &APIClient{}
|
||||
c.cfg = cfg
|
||||
c.common.client = c
|
||||
|
||||
// API Services
|
||||
c.OpenapiAPI = (*OpenapiAPIService)(&c.common)
|
||||
c.SlurmAPI = (*SlurmAPIService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func atoi(in string) (int, error) {
|
||||
return strconv.Atoi(in)
|
||||
}
|
||||
|
||||
// selectHeaderContentType select a content type from the available list.
|
||||
func selectHeaderContentType(contentTypes []string) string {
|
||||
if len(contentTypes) == 0 {
|
||||
return ""
|
||||
}
|
||||
if contains(contentTypes, "application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
return contentTypes[0] // use the first content type specified in 'consumes'
|
||||
}
|
||||
|
||||
// selectHeaderAccept join all accept types and return
|
||||
func selectHeaderAccept(accepts []string) string {
|
||||
if len(accepts) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
if contains(accepts, "application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
|
||||
return strings.Join(accepts, ",")
|
||||
}
|
||||
|
||||
// contains is a case insensitive match, finding needle in a haystack
|
||||
func contains(haystack []string, needle string) bool {
|
||||
for _, a := range haystack {
|
||||
if strings.EqualFold(a, needle) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Verify optional parameters are of the correct type.
|
||||
func typeCheckParameter(obj interface{}, expected string, name string) error {
|
||||
// Make sure there is an object.
|
||||
if obj == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check the type is as expected.
|
||||
if reflect.TypeOf(obj).String() != expected {
|
||||
return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func parameterValueToString( obj interface{}, key string ) string {
|
||||
if reflect.TypeOf(obj).Kind() != reflect.Ptr {
|
||||
return fmt.Sprintf("%v", obj)
|
||||
}
|
||||
var param,ok = obj.(MappedNullable)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
dataMap,err := param.ToMap()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("%v", dataMap[key])
|
||||
}
|
||||
|
||||
// parameterAddToHeaderOrQuery adds the provided object to the request header or url query
|
||||
// supporting deep object syntax
|
||||
func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
|
||||
var v = reflect.ValueOf(obj)
|
||||
var value = ""
|
||||
if v == reflect.ValueOf(nil) {
|
||||
value = "null"
|
||||
} else {
|
||||
switch v.Kind() {
|
||||
case reflect.Invalid:
|
||||
value = "invalid"
|
||||
|
||||
case reflect.Struct:
|
||||
if t,ok := obj.(MappedNullable); ok {
|
||||
dataMap,err := t.ToMap()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, collectionType)
|
||||
return
|
||||
}
|
||||
if t, ok := obj.(time.Time); ok {
|
||||
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339), collectionType)
|
||||
return
|
||||
}
|
||||
value = v.Type().String() + " value"
|
||||
case reflect.Slice:
|
||||
var indValue = reflect.ValueOf(obj)
|
||||
if indValue == reflect.ValueOf(nil) {
|
||||
return
|
||||
}
|
||||
var lenIndValue = indValue.Len()
|
||||
for i:=0;i<lenIndValue;i++ {
|
||||
var arrayValue = indValue.Index(i)
|
||||
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, arrayValue.Interface(), collectionType)
|
||||
}
|
||||
return
|
||||
|
||||
case reflect.Map:
|
||||
var indValue = reflect.ValueOf(obj)
|
||||
if indValue == reflect.ValueOf(nil) {
|
||||
return
|
||||
}
|
||||
iter := indValue.MapRange()
|
||||
for iter.Next() {
|
||||
k,v := iter.Key(), iter.Value()
|
||||
parameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), collectionType)
|
||||
}
|
||||
return
|
||||
|
||||
case reflect.Interface:
|
||||
fallthrough
|
||||
case reflect.Ptr:
|
||||
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, v.Elem().Interface(), collectionType)
|
||||
return
|
||||
|
||||
case reflect.Int, reflect.Int8, reflect.Int16,
|
||||
reflect.Int32, reflect.Int64:
|
||||
value = strconv.FormatInt(v.Int(), 10)
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16,
|
||||
reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
value = strconv.FormatUint(v.Uint(), 10)
|
||||
case reflect.Float32, reflect.Float64:
|
||||
value = strconv.FormatFloat(v.Float(), 'g', -1, 32)
|
||||
case reflect.Bool:
|
||||
value = strconv.FormatBool(v.Bool())
|
||||
case reflect.String:
|
||||
value = v.String()
|
||||
default:
|
||||
value = v.Type().String() + " value"
|
||||
}
|
||||
}
|
||||
|
||||
switch valuesMap := headerOrQueryParams.(type) {
|
||||
case url.Values:
|
||||
if collectionType == "csv" && valuesMap.Get(keyPrefix) != "" {
|
||||
valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix) + "," + value)
|
||||
} else {
|
||||
valuesMap.Add(keyPrefix, value)
|
||||
}
|
||||
break
|
||||
case map[string]string:
|
||||
valuesMap[keyPrefix] = value
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// helper for converting interface{} parameters to json strings
|
||||
func parameterToJson(obj interface{}) (string, error) {
|
||||
jsonBuf, err := json.Marshal(obj)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(jsonBuf), err
|
||||
}
|
||||
|
||||
// callAPI do the request.
|
||||
func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
|
||||
if c.cfg.Debug {
|
||||
dump, err := httputil.DumpRequestOut(request, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Printf("\n%s\n", string(dump))
|
||||
}
|
||||
|
||||
resp, err := c.cfg.HTTPClient.Do(request)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
if c.cfg.Debug {
|
||||
dump, err := httputil.DumpResponse(resp, true)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
log.Printf("\n%s\n", string(dump))
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// Allow modification of underlying config for alternate implementations and testing
|
||||
// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior
|
||||
func (c *APIClient) GetConfig() *Configuration {
|
||||
return c.cfg
|
||||
}
|
||||
|
||||
type formFile struct {
|
||||
fileBytes []byte
|
||||
fileName string
|
||||
formFileName string
|
||||
}
|
||||
|
||||
// prepareRequest build the request
|
||||
func (c *APIClient) prepareRequest(
|
||||
ctx context.Context,
|
||||
path string, method string,
|
||||
postBody interface{},
|
||||
headerParams map[string]string,
|
||||
queryParams url.Values,
|
||||
formParams url.Values,
|
||||
formFiles []formFile) (localVarRequest *http.Request, err error) {
|
||||
|
||||
var body *bytes.Buffer
|
||||
|
||||
// Detect postBody type and post.
|
||||
if postBody != nil {
|
||||
contentType := headerParams["Content-Type"]
|
||||
if contentType == "" {
|
||||
contentType = detectContentType(postBody)
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
body, err = setBody(postBody, contentType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// add form parameters and file if available.
|
||||
if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(formFiles) > 0) {
|
||||
if body != nil {
|
||||
return nil, errors.New("Cannot specify postBody and multipart form at the same time.")
|
||||
}
|
||||
body = &bytes.Buffer{}
|
||||
w := multipart.NewWriter(body)
|
||||
|
||||
for k, v := range formParams {
|
||||
for _, iv := range v {
|
||||
if strings.HasPrefix(k, "@") { // file
|
||||
err = addFile(w, k[1:], iv)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else { // form value
|
||||
w.WriteField(k, iv)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, formFile := range formFiles {
|
||||
if len(formFile.fileBytes) > 0 && formFile.fileName != "" {
|
||||
w.Boundary()
|
||||
part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = part.Write(formFile.fileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the Boundary in the Content-Type
|
||||
headerParams["Content-Type"] = w.FormDataContentType()
|
||||
|
||||
// Set Content-Length
|
||||
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
|
||||
w.Close()
|
||||
}
|
||||
|
||||
if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 {
|
||||
if body != nil {
|
||||
return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.")
|
||||
}
|
||||
body = &bytes.Buffer{}
|
||||
body.WriteString(formParams.Encode())
|
||||
// Set Content-Length
|
||||
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
|
||||
}
|
||||
|
||||
// Setup path and query parameters
|
||||
url, err := url.Parse(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Override request host, if applicable
|
||||
if c.cfg.Host != "" {
|
||||
url.Host = c.cfg.Host
|
||||
}
|
||||
|
||||
// Override request scheme, if applicable
|
||||
if c.cfg.Scheme != "" {
|
||||
url.Scheme = c.cfg.Scheme
|
||||
}
|
||||
|
||||
// Adding Query Param
|
||||
query := url.Query()
|
||||
for k, v := range queryParams {
|
||||
for _, iv := range v {
|
||||
query.Add(k, iv)
|
||||
}
|
||||
}
|
||||
|
||||
// Encode the parameters.
|
||||
url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string {
|
||||
pieces := strings.Split(s, "=")
|
||||
pieces[0] = queryDescape.Replace(pieces[0])
|
||||
return strings.Join(pieces, "=")
|
||||
})
|
||||
|
||||
// Generate a new request
|
||||
if body != nil {
|
||||
localVarRequest, err = http.NewRequest(method, url.String(), body)
|
||||
} else {
|
||||
localVarRequest, err = http.NewRequest(method, url.String(), nil)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// add header parameters, if any
|
||||
if len(headerParams) > 0 {
|
||||
headers := http.Header{}
|
||||
for h, v := range headerParams {
|
||||
headers[h] = []string{v}
|
||||
}
|
||||
localVarRequest.Header = headers
|
||||
}
|
||||
|
||||
// Add the user agent to the request.
|
||||
localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent)
|
||||
|
||||
if ctx != nil {
|
||||
// add context to the request
|
||||
localVarRequest = localVarRequest.WithContext(ctx)
|
||||
|
||||
// Walk through any authentication.
|
||||
|
||||
}
|
||||
|
||||
for header, value := range c.cfg.DefaultHeader {
|
||||
localVarRequest.Header.Add(header, value)
|
||||
}
|
||||
return localVarRequest, nil
|
||||
}
|
||||
|
||||
func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) {
|
||||
if len(b) == 0 {
|
||||
return nil
|
||||
}
|
||||
if s, ok := v.(*string); ok {
|
||||
*s = string(b)
|
||||
return nil
|
||||
}
|
||||
if f, ok := v.(*os.File); ok {
|
||||
f, err = os.CreateTemp("", "HttpClientFile")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = f.Write(b)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = f.Seek(0, io.SeekStart)
|
||||
err = os.Remove(f.Name())
|
||||
return
|
||||
}
|
||||
if f, ok := v.(**os.File); ok {
|
||||
*f, err = os.CreateTemp("", "HttpClientFile")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = (*f).Write(b)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = (*f).Seek(0, io.SeekStart)
|
||||
err = os.Remove((*f).Name())
|
||||
return
|
||||
}
|
||||
if xmlCheck.MatchString(contentType) {
|
||||
if err = xml.Unmarshal(b, v); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if jsonCheck.MatchString(contentType) {
|
||||
if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas
|
||||
if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined
|
||||
if err = unmarshalObj.UnmarshalJSON(b); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined")
|
||||
}
|
||||
} else if err = json.Unmarshal(b, v); err != nil { // simple model
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return errors.New("undefined response type")
|
||||
}
|
||||
|
||||
// Add a file to the multipart request
|
||||
func addFile(w *multipart.Writer, fieldName, path string) error {
|
||||
file, err := os.Open(filepath.Clean(path))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = file.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
part, err := w.CreateFormFile(fieldName, filepath.Base(path))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = io.Copy(part, file)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// Prevent trying to import "fmt"
|
||||
func reportError(format string, a ...interface{}) error {
|
||||
return fmt.Errorf(format, a...)
|
||||
}
|
||||
|
||||
// A wrapper for strict JSON decoding
|
||||
func newStrictDecoder(data []byte) *json.Decoder {
|
||||
dec := json.NewDecoder(bytes.NewBuffer(data))
|
||||
dec.DisallowUnknownFields()
|
||||
return dec
|
||||
}
|
||||
|
||||
// Set request body from an interface{}
|
||||
func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) {
|
||||
if bodyBuf == nil {
|
||||
bodyBuf = &bytes.Buffer{}
|
||||
}
|
||||
|
||||
if reader, ok := body.(io.Reader); ok {
|
||||
_, err = bodyBuf.ReadFrom(reader)
|
||||
} else if fp, ok := body.(*os.File); ok {
|
||||
_, err = bodyBuf.ReadFrom(fp)
|
||||
} else if b, ok := body.([]byte); ok {
|
||||
_, err = bodyBuf.Write(b)
|
||||
} else if s, ok := body.(string); ok {
|
||||
_, err = bodyBuf.WriteString(s)
|
||||
} else if s, ok := body.(*string); ok {
|
||||
_, err = bodyBuf.WriteString(*s)
|
||||
} else if jsonCheck.MatchString(contentType) {
|
||||
err = json.NewEncoder(bodyBuf).Encode(body)
|
||||
} else if xmlCheck.MatchString(contentType) {
|
||||
var bs []byte
|
||||
bs, err = xml.Marshal(body)
|
||||
if err == nil {
|
||||
bodyBuf.Write(bs)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if bodyBuf.Len() == 0 {
|
||||
err = fmt.Errorf("invalid body type %s\n", contentType)
|
||||
return nil, err
|
||||
}
|
||||
return bodyBuf, nil
|
||||
}
|
||||
|
||||
// detectContentType method is used to figure out `Request.Body` content type for request header
|
||||
func detectContentType(body interface{}) string {
|
||||
contentType := "text/plain; charset=utf-8"
|
||||
kind := reflect.TypeOf(body).Kind()
|
||||
|
||||
switch kind {
|
||||
case reflect.Struct, reflect.Map, reflect.Ptr:
|
||||
contentType = "application/json; charset=utf-8"
|
||||
case reflect.String:
|
||||
contentType = "text/plain; charset=utf-8"
|
||||
default:
|
||||
if b, ok := body.([]byte); ok {
|
||||
contentType = http.DetectContentType(b)
|
||||
} else if kind == reflect.Slice {
|
||||
contentType = "application/json; charset=utf-8"
|
||||
}
|
||||
}
|
||||
|
||||
return contentType
|
||||
}
|
||||
|
||||
// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go
|
||||
type cacheControl map[string]string
|
||||
|
||||
func parseCacheControl(headers http.Header) cacheControl {
|
||||
cc := cacheControl{}
|
||||
ccHeader := headers.Get("Cache-Control")
|
||||
for _, part := range strings.Split(ccHeader, ",") {
|
||||
part = strings.Trim(part, " ")
|
||||
if part == "" {
|
||||
continue
|
||||
}
|
||||
if strings.ContainsRune(part, '=') {
|
||||
keyval := strings.Split(part, "=")
|
||||
cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",")
|
||||
} else {
|
||||
cc[part] = ""
|
||||
}
|
||||
}
|
||||
return cc
|
||||
}
|
||||
|
||||
// CacheExpires helper function to determine remaining time before repeating a request.
|
||||
func CacheExpires(r *http.Response) time.Time {
|
||||
// Figure out when the cache expires.
|
||||
var expires time.Time
|
||||
now, err := time.Parse(time.RFC1123, r.Header.Get("date"))
|
||||
if err != nil {
|
||||
return time.Now()
|
||||
}
|
||||
respCacheControl := parseCacheControl(r.Header)
|
||||
|
||||
if maxAge, ok := respCacheControl["max-age"]; ok {
|
||||
lifetime, err := time.ParseDuration(maxAge + "s")
|
||||
if err != nil {
|
||||
expires = now
|
||||
} else {
|
||||
expires = now.Add(lifetime)
|
||||
}
|
||||
} else {
|
||||
expiresHeader := r.Header.Get("Expires")
|
||||
if expiresHeader != "" {
|
||||
expires, err = time.Parse(time.RFC1123, expiresHeader)
|
||||
if err != nil {
|
||||
expires = now
|
||||
}
|
||||
}
|
||||
}
|
||||
return expires
|
||||
}
|
||||
|
||||
func strlen(s string) int {
|
||||
return utf8.RuneCountInString(s)
|
||||
}
|
||||
|
||||
// GenericOpenAPIError Provides access to the body, error and model on returned errors.
|
||||
type GenericOpenAPIError struct {
|
||||
body []byte
|
||||
error string
|
||||
model interface{}
|
||||
}
|
||||
|
||||
// Error returns non-empty string if there was an error.
|
||||
func (e GenericOpenAPIError) Error() string {
|
||||
return e.error
|
||||
}
|
||||
|
||||
// Body returns the raw bytes of the response
|
||||
func (e GenericOpenAPIError) Body() []byte {
|
||||
return e.body
|
||||
}
|
||||
|
||||
// Model returns the unpacked model of the error
|
||||
func (e GenericOpenAPIError) Model() interface{} {
|
||||
return e.model
|
||||
}
|
||||
|
||||
// format error message using title and detail when model implements rfc7807
|
||||
func formatErrorMessage(status string, v interface{}) string {
|
||||
str := ""
|
||||
metaValue := reflect.ValueOf(v).Elem()
|
||||
|
||||
if metaValue.Kind() == reflect.Struct {
|
||||
field := metaValue.FieldByName("Title")
|
||||
if field != (reflect.Value{}) {
|
||||
str = fmt.Sprintf("%s", field.Interface())
|
||||
}
|
||||
|
||||
field = metaValue.FieldByName("Detail")
|
||||
if field != (reflect.Value{}) {
|
||||
str = fmt.Sprintf("%s (%s)", str, field.Interface())
|
||||
}
|
||||
}
|
||||
|
||||
return strings.TrimSpace(fmt.Sprintf("%s %s", status, str))
|
||||
}
|
||||
@@ -1,243 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// contextKeys are used to identify the type of value in the context.
|
||||
// Since these are string, it is possible to get a short description of the
|
||||
// context key for logging and debugging using key.String().
|
||||
|
||||
type contextKey string
|
||||
|
||||
func (c contextKey) String() string {
|
||||
return "auth " + string(c)
|
||||
}
|
||||
|
||||
var (
|
||||
// ContextAPIKeys takes a string apikey as authentication for the request
|
||||
ContextAPIKeys = contextKey("apiKeys")
|
||||
|
||||
// ContextServerIndex uses a server configuration from the index.
|
||||
ContextServerIndex = contextKey("serverIndex")
|
||||
|
||||
// ContextOperationServerIndices uses a server configuration from the index mapping.
|
||||
ContextOperationServerIndices = contextKey("serverOperationIndices")
|
||||
|
||||
// ContextServerVariables overrides a server configuration variables.
|
||||
ContextServerVariables = contextKey("serverVariables")
|
||||
|
||||
// ContextOperationServerVariables overrides a server configuration variables using operation specific values.
|
||||
ContextOperationServerVariables = contextKey("serverOperationVariables")
|
||||
)
|
||||
|
||||
// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
|
||||
type BasicAuth struct {
|
||||
UserName string `json:"userName,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
}
|
||||
|
||||
// APIKey provides API key based authentication to a request passed via context using ContextAPIKey
|
||||
type APIKey struct {
|
||||
Key string
|
||||
Prefix string
|
||||
}
|
||||
|
||||
// ServerVariable stores the information about a server variable
|
||||
type ServerVariable struct {
|
||||
Description string
|
||||
DefaultValue string
|
||||
EnumValues []string
|
||||
}
|
||||
|
||||
// ServerConfiguration stores the information about a server
|
||||
type ServerConfiguration struct {
|
||||
URL string
|
||||
Description string
|
||||
Variables map[string]ServerVariable
|
||||
}
|
||||
|
||||
// ServerConfigurations stores multiple ServerConfiguration items
|
||||
type ServerConfigurations []ServerConfiguration
|
||||
|
||||
// Configuration stores the configuration of the API client
|
||||
type Configuration struct {
|
||||
Host string `json:"host,omitempty"`
|
||||
Scheme string `json:"scheme,omitempty"`
|
||||
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
||||
UserAgent string `json:"userAgent,omitempty"`
|
||||
Debug bool `json:"debug,omitempty"`
|
||||
Servers ServerConfigurations
|
||||
OperationServers map[string]ServerConfigurations
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// NewConfiguration returns a new Configuration object
|
||||
func NewConfiguration() *Configuration {
|
||||
cfg := &Configuration{
|
||||
DefaultHeader: make(map[string]string),
|
||||
UserAgent: "OpenAPI-Generator/1.0.0/go",
|
||||
Debug: false,
|
||||
Servers: ServerConfigurations{
|
||||
{
|
||||
URL: "/slurm/v0.0.37",
|
||||
Description: "No description provided",
|
||||
},
|
||||
},
|
||||
OperationServers: map[string]ServerConfigurations{
|
||||
"OpenapiAPIService.OpenapiGet": {
|
||||
{
|
||||
URL: "/",
|
||||
Description: "No description provided",
|
||||
},
|
||||
},
|
||||
"OpenapiAPIService.OpenapiJsonGet": {
|
||||
{
|
||||
URL: "/",
|
||||
Description: "No description provided",
|
||||
},
|
||||
},
|
||||
"OpenapiAPIService.OpenapiV3Get": {
|
||||
{
|
||||
URL: "/",
|
||||
Description: "No description provided",
|
||||
},
|
||||
},
|
||||
"OpenapiAPIService.OpenapiYamlGet": {
|
||||
{
|
||||
URL: "/",
|
||||
Description: "No description provided",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
||||
// AddDefaultHeader adds a new HTTP header to the default header in the request
|
||||
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
||||
c.DefaultHeader[key] = value
|
||||
}
|
||||
|
||||
// URL formats template on a index using given variables
|
||||
func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) {
|
||||
if index < 0 || len(sc) <= index {
|
||||
return "", fmt.Errorf("index %v out of range %v", index, len(sc)-1)
|
||||
}
|
||||
server := sc[index]
|
||||
url := server.URL
|
||||
|
||||
// go through variables and replace placeholders
|
||||
for name, variable := range server.Variables {
|
||||
if value, ok := variables[name]; ok {
|
||||
found := bool(len(variable.EnumValues) == 0)
|
||||
for _, enumValue := range variable.EnumValues {
|
||||
if value == enumValue {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return "", fmt.Errorf("the variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues)
|
||||
}
|
||||
url = strings.Replace(url, "{"+name+"}", value, -1)
|
||||
} else {
|
||||
url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1)
|
||||
}
|
||||
}
|
||||
return url, nil
|
||||
}
|
||||
|
||||
// ServerURL returns URL based on server settings
|
||||
func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) {
|
||||
return c.Servers.URL(index, variables)
|
||||
}
|
||||
|
||||
func getServerIndex(ctx context.Context) (int, error) {
|
||||
si := ctx.Value(ContextServerIndex)
|
||||
if si != nil {
|
||||
if index, ok := si.(int); ok {
|
||||
return index, nil
|
||||
}
|
||||
return 0, reportError("Invalid type %T should be int", si)
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func getServerOperationIndex(ctx context.Context, endpoint string) (int, error) {
|
||||
osi := ctx.Value(ContextOperationServerIndices)
|
||||
if osi != nil {
|
||||
if operationIndices, ok := osi.(map[string]int); !ok {
|
||||
return 0, reportError("Invalid type %T should be map[string]int", osi)
|
||||
} else {
|
||||
index, ok := operationIndices[endpoint]
|
||||
if ok {
|
||||
return index, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return getServerIndex(ctx)
|
||||
}
|
||||
|
||||
func getServerVariables(ctx context.Context) (map[string]string, error) {
|
||||
sv := ctx.Value(ContextServerVariables)
|
||||
if sv != nil {
|
||||
if variables, ok := sv.(map[string]string); ok {
|
||||
return variables, nil
|
||||
}
|
||||
return nil, reportError("ctx value of ContextServerVariables has invalid type %T should be map[string]string", sv)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func getServerOperationVariables(ctx context.Context, endpoint string) (map[string]string, error) {
|
||||
osv := ctx.Value(ContextOperationServerVariables)
|
||||
if osv != nil {
|
||||
if operationVariables, ok := osv.(map[string]map[string]string); !ok {
|
||||
return nil, reportError("ctx value of ContextOperationServerVariables has invalid type %T should be map[string]map[string]string", osv)
|
||||
} else {
|
||||
variables, ok := operationVariables[endpoint]
|
||||
if ok {
|
||||
return variables, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return getServerVariables(ctx)
|
||||
}
|
||||
|
||||
// ServerURLWithContext returns a new server URL given an endpoint
|
||||
func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error) {
|
||||
sc, ok := c.OperationServers[endpoint]
|
||||
if !ok {
|
||||
sc = c.Servers
|
||||
}
|
||||
|
||||
if ctx == nil {
|
||||
return sc.URL(0, nil)
|
||||
}
|
||||
|
||||
index, err := getServerOperationIndex(ctx, endpoint)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
variables, err := getServerOperationVariables(ctx, endpoint)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return sc.URL(index, variables)
|
||||
}
|
||||
@@ -1,240 +0,0 @@
|
||||
# \OpenapiAPI
|
||||
|
||||
All URIs are relative to *http://localhost/slurm/v0.0.37*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**OpenapiGet**](OpenapiAPI.md#OpenapiGet) | **Get** /openapi | Retrieve OpenAPI Specification
|
||||
[**OpenapiJsonGet**](OpenapiAPI.md#OpenapiJsonGet) | **Get** /openapi.json | Retrieve OpenAPI Specification
|
||||
[**OpenapiV3Get**](OpenapiAPI.md#OpenapiV3Get) | **Get** /openapi/v3 | Retrieve OpenAPI Specification
|
||||
[**OpenapiYamlGet**](OpenapiAPI.md#OpenapiYamlGet) | **Get** /openapi.yaml | Retrieve OpenAPI Specification
|
||||
|
||||
|
||||
|
||||
## OpenapiGet
|
||||
|
||||
> OpenapiGet(ctx).Execute()
|
||||
|
||||
Retrieve OpenAPI Specification
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
r, err := apiClient.OpenapiAPI.OpenapiGet(context.Background()).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `OpenapiAPI.OpenapiGet``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiOpenapiGetRequest struct via the builder pattern
|
||||
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## OpenapiJsonGet
|
||||
|
||||
> OpenapiJsonGet(ctx).Execute()
|
||||
|
||||
Retrieve OpenAPI Specification
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
r, err := apiClient.OpenapiAPI.OpenapiJsonGet(context.Background()).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `OpenapiAPI.OpenapiJsonGet``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiOpenapiJsonGetRequest struct via the builder pattern
|
||||
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## OpenapiV3Get
|
||||
|
||||
> OpenapiV3Get(ctx).Execute()
|
||||
|
||||
Retrieve OpenAPI Specification
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
r, err := apiClient.OpenapiAPI.OpenapiV3Get(context.Background()).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `OpenapiAPI.OpenapiV3Get``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiOpenapiV3GetRequest struct via the builder pattern
|
||||
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## OpenapiYamlGet
|
||||
|
||||
> OpenapiYamlGet(ctx).Execute()
|
||||
|
||||
Retrieve OpenAPI Specification
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
r, err := apiClient.OpenapiAPI.OpenapiYamlGet(context.Background()).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `OpenapiAPI.OpenapiYamlGet``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiOpenapiYamlGetRequest struct via the builder pattern
|
||||
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
@@ -1,871 +0,0 @@
|
||||
# \SlurmAPI
|
||||
|
||||
All URIs are relative to *http://localhost/slurm/v0.0.37*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**SlurmctldCancelJob**](SlurmAPI.md#SlurmctldCancelJob) | **Delete** /job/{job_id} | cancel or signal job
|
||||
[**SlurmctldDiag**](SlurmAPI.md#SlurmctldDiag) | **Get** /diag/ | get diagnostics
|
||||
[**SlurmctldGetJob**](SlurmAPI.md#SlurmctldGetJob) | **Get** /job/{job_id} | get job info
|
||||
[**SlurmctldGetJobs**](SlurmAPI.md#SlurmctldGetJobs) | **Get** /jobs/ | get list of jobs
|
||||
[**SlurmctldGetNode**](SlurmAPI.md#SlurmctldGetNode) | **Get** /node/{node_name} | get node info
|
||||
[**SlurmctldGetNodes**](SlurmAPI.md#SlurmctldGetNodes) | **Get** /nodes/ | get all node info
|
||||
[**SlurmctldGetPartition**](SlurmAPI.md#SlurmctldGetPartition) | **Get** /partition/{partition_name} | get partition info
|
||||
[**SlurmctldGetPartitions**](SlurmAPI.md#SlurmctldGetPartitions) | **Get** /partitions/ | get all partition info
|
||||
[**SlurmctldGetReservation**](SlurmAPI.md#SlurmctldGetReservation) | **Get** /reservation/{reservation_name} | get reservation info
|
||||
[**SlurmctldGetReservations**](SlurmAPI.md#SlurmctldGetReservations) | **Get** /reservations/ | get all reservation info
|
||||
[**SlurmctldPing**](SlurmAPI.md#SlurmctldPing) | **Get** /ping/ | ping test
|
||||
[**SlurmctldSubmitJob**](SlurmAPI.md#SlurmctldSubmitJob) | **Post** /job/submit | submit new job
|
||||
[**SlurmctldUpdateJob**](SlurmAPI.md#SlurmctldUpdateJob) | **Post** /job/{job_id} | update job
|
||||
|
||||
|
||||
|
||||
## SlurmctldCancelJob
|
||||
|
||||
> SlurmctldCancelJob(ctx, jobId).Signal(signal).Execute()
|
||||
|
||||
cancel or signal job
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
jobId := "jobId_example" // string | Slurm Job ID
|
||||
signal := openapiclient.v0.0.37_signal("HUP") // V0037Signal | signal to send to job (optional)
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
r, err := apiClient.SlurmAPI.SlurmctldCancelJob(context.Background(), jobId).Signal(signal).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `SlurmAPI.SlurmctldCancelJob``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
|
||||
**jobId** | **string** | Slurm Job ID |
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSlurmctldCancelJobRequest struct via the builder pattern
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
|
||||
**signal** | [**V0037Signal**](V0037Signal.md) | signal to send to job |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## SlurmctldDiag
|
||||
|
||||
> V0037Diag SlurmctldDiag(ctx).Execute()
|
||||
|
||||
get diagnostics
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
resp, r, err := apiClient.SlurmAPI.SlurmctldDiag(context.Background()).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `SlurmAPI.SlurmctldDiag``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
// response from `SlurmctldDiag`: V0037Diag
|
||||
fmt.Fprintf(os.Stdout, "Response from `SlurmAPI.SlurmctldDiag`: %v\n", resp)
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSlurmctldDiagRequest struct via the builder pattern
|
||||
|
||||
|
||||
### Return type
|
||||
|
||||
[**V0037Diag**](V0037Diag.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json, application/x-yaml
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## SlurmctldGetJob
|
||||
|
||||
> V0037JobsResponse SlurmctldGetJob(ctx, jobId).Execute()
|
||||
|
||||
get job info
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
jobId := "jobId_example" // string | Slurm JobID
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
resp, r, err := apiClient.SlurmAPI.SlurmctldGetJob(context.Background(), jobId).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `SlurmAPI.SlurmctldGetJob``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
// response from `SlurmctldGetJob`: V0037JobsResponse
|
||||
fmt.Fprintf(os.Stdout, "Response from `SlurmAPI.SlurmctldGetJob`: %v\n", resp)
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
|
||||
**jobId** | **string** | Slurm JobID |
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSlurmctldGetJobRequest struct via the builder pattern
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
|
||||
|
||||
### Return type
|
||||
|
||||
[**V0037JobsResponse**](V0037JobsResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json, application/x-yaml
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## SlurmctldGetJobs
|
||||
|
||||
> V0037JobsResponse SlurmctldGetJobs(ctx).UpdateTime(updateTime).Execute()
|
||||
|
||||
get list of jobs
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
updateTime := int64(789) // int64 | Filter if changed since update_time. Use of this parameter can result in faster replies. (optional)
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
resp, r, err := apiClient.SlurmAPI.SlurmctldGetJobs(context.Background()).UpdateTime(updateTime).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `SlurmAPI.SlurmctldGetJobs``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
// response from `SlurmctldGetJobs`: V0037JobsResponse
|
||||
fmt.Fprintf(os.Stdout, "Response from `SlurmAPI.SlurmctldGetJobs`: %v\n", resp)
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSlurmctldGetJobsRequest struct via the builder pattern
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**updateTime** | **int64** | Filter if changed since update_time. Use of this parameter can result in faster replies. |
|
||||
|
||||
### Return type
|
||||
|
||||
[**V0037JobsResponse**](V0037JobsResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json, application/x-yaml
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## SlurmctldGetNode
|
||||
|
||||
> V0037NodesResponse SlurmctldGetNode(ctx, nodeName).Execute()
|
||||
|
||||
get node info
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
nodeName := "nodeName_example" // string | Slurm Node Name
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
resp, r, err := apiClient.SlurmAPI.SlurmctldGetNode(context.Background(), nodeName).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `SlurmAPI.SlurmctldGetNode``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
// response from `SlurmctldGetNode`: V0037NodesResponse
|
||||
fmt.Fprintf(os.Stdout, "Response from `SlurmAPI.SlurmctldGetNode`: %v\n", resp)
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
|
||||
**nodeName** | **string** | Slurm Node Name |
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSlurmctldGetNodeRequest struct via the builder pattern
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
|
||||
|
||||
### Return type
|
||||
|
||||
[**V0037NodesResponse**](V0037NodesResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json, application/x-yaml
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## SlurmctldGetNodes
|
||||
|
||||
> V0037NodesResponse SlurmctldGetNodes(ctx).UpdateTime(updateTime).Execute()
|
||||
|
||||
get all node info
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
updateTime := int64(789) // int64 | Filter if changed since update_time. Use of this parameter can result in faster replies. (optional)
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
resp, r, err := apiClient.SlurmAPI.SlurmctldGetNodes(context.Background()).UpdateTime(updateTime).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `SlurmAPI.SlurmctldGetNodes``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
// response from `SlurmctldGetNodes`: V0037NodesResponse
|
||||
fmt.Fprintf(os.Stdout, "Response from `SlurmAPI.SlurmctldGetNodes`: %v\n", resp)
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSlurmctldGetNodesRequest struct via the builder pattern
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**updateTime** | **int64** | Filter if changed since update_time. Use of this parameter can result in faster replies. |
|
||||
|
||||
### Return type
|
||||
|
||||
[**V0037NodesResponse**](V0037NodesResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json, application/x-yaml
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## SlurmctldGetPartition
|
||||
|
||||
> V0037PartitionsResponse SlurmctldGetPartition(ctx, partitionName).UpdateTime(updateTime).Execute()
|
||||
|
||||
get partition info
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
partitionName := "partitionName_example" // string | Slurm Partition Name
|
||||
updateTime := int64(789) // int64 | Filter if there were no partition changes (not limited to partition in URL endpoint) since update_time. (optional)
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
resp, r, err := apiClient.SlurmAPI.SlurmctldGetPartition(context.Background(), partitionName).UpdateTime(updateTime).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `SlurmAPI.SlurmctldGetPartition``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
// response from `SlurmctldGetPartition`: V0037PartitionsResponse
|
||||
fmt.Fprintf(os.Stdout, "Response from `SlurmAPI.SlurmctldGetPartition`: %v\n", resp)
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
|
||||
**partitionName** | **string** | Slurm Partition Name |
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSlurmctldGetPartitionRequest struct via the builder pattern
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
|
||||
**updateTime** | **int64** | Filter if there were no partition changes (not limited to partition in URL endpoint) since update_time. |
|
||||
|
||||
### Return type
|
||||
|
||||
[**V0037PartitionsResponse**](V0037PartitionsResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json, application/x-yaml
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## SlurmctldGetPartitions
|
||||
|
||||
> V0037PartitionsResponse SlurmctldGetPartitions(ctx).UpdateTime(updateTime).Execute()
|
||||
|
||||
get all partition info
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
updateTime := int64(789) // int64 | Filter if changed since update_time. Use of this parameter can result in faster replies. (optional)
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
resp, r, err := apiClient.SlurmAPI.SlurmctldGetPartitions(context.Background()).UpdateTime(updateTime).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `SlurmAPI.SlurmctldGetPartitions``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
// response from `SlurmctldGetPartitions`: V0037PartitionsResponse
|
||||
fmt.Fprintf(os.Stdout, "Response from `SlurmAPI.SlurmctldGetPartitions`: %v\n", resp)
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSlurmctldGetPartitionsRequest struct via the builder pattern
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**updateTime** | **int64** | Filter if changed since update_time. Use of this parameter can result in faster replies. |
|
||||
|
||||
### Return type
|
||||
|
||||
[**V0037PartitionsResponse**](V0037PartitionsResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json, application/x-yaml
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## SlurmctldGetReservation
|
||||
|
||||
> V0037ReservationsResponse SlurmctldGetReservation(ctx, reservationName).UpdateTime(updateTime).Execute()
|
||||
|
||||
get reservation info
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
reservationName := "reservationName_example" // string | Slurm Reservation Name
|
||||
updateTime := int64(789) // int64 | Filter if no reservation (not limited to reservation in URL) changed since update_time. (optional)
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
resp, r, err := apiClient.SlurmAPI.SlurmctldGetReservation(context.Background(), reservationName).UpdateTime(updateTime).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `SlurmAPI.SlurmctldGetReservation``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
// response from `SlurmctldGetReservation`: V0037ReservationsResponse
|
||||
fmt.Fprintf(os.Stdout, "Response from `SlurmAPI.SlurmctldGetReservation`: %v\n", resp)
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
|
||||
**reservationName** | **string** | Slurm Reservation Name |
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSlurmctldGetReservationRequest struct via the builder pattern
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
|
||||
**updateTime** | **int64** | Filter if no reservation (not limited to reservation in URL) changed since update_time. |
|
||||
|
||||
### Return type
|
||||
|
||||
[**V0037ReservationsResponse**](V0037ReservationsResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json, application/x-yaml
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## SlurmctldGetReservations
|
||||
|
||||
> V0037ReservationsResponse SlurmctldGetReservations(ctx).UpdateTime(updateTime).Execute()
|
||||
|
||||
get all reservation info
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
updateTime := int64(789) // int64 | Filter if changed since update_time. Use of this parameter can result in faster replies. (optional)
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
resp, r, err := apiClient.SlurmAPI.SlurmctldGetReservations(context.Background()).UpdateTime(updateTime).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `SlurmAPI.SlurmctldGetReservations``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
// response from `SlurmctldGetReservations`: V0037ReservationsResponse
|
||||
fmt.Fprintf(os.Stdout, "Response from `SlurmAPI.SlurmctldGetReservations`: %v\n", resp)
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSlurmctldGetReservationsRequest struct via the builder pattern
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**updateTime** | **int64** | Filter if changed since update_time. Use of this parameter can result in faster replies. |
|
||||
|
||||
### Return type
|
||||
|
||||
[**V0037ReservationsResponse**](V0037ReservationsResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json, application/x-yaml
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## SlurmctldPing
|
||||
|
||||
> V0037Pings SlurmctldPing(ctx).Execute()
|
||||
|
||||
ping test
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
resp, r, err := apiClient.SlurmAPI.SlurmctldPing(context.Background()).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `SlurmAPI.SlurmctldPing``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
// response from `SlurmctldPing`: V0037Pings
|
||||
fmt.Fprintf(os.Stdout, "Response from `SlurmAPI.SlurmctldPing`: %v\n", resp)
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSlurmctldPingRequest struct via the builder pattern
|
||||
|
||||
|
||||
### Return type
|
||||
|
||||
[**V0037Pings**](V0037Pings.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json, application/x-yaml
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## SlurmctldSubmitJob
|
||||
|
||||
> V0037JobSubmissionResponse SlurmctldSubmitJob(ctx).V0037JobSubmission(v0037JobSubmission).Execute()
|
||||
|
||||
submit new job
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
v0037JobSubmission := *openapiclient.NewV0037JobSubmission("Script_example") // V0037JobSubmission | submit new job
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
resp, r, err := apiClient.SlurmAPI.SlurmctldSubmitJob(context.Background()).V0037JobSubmission(v0037JobSubmission).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `SlurmAPI.SlurmctldSubmitJob``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
// response from `SlurmctldSubmitJob`: V0037JobSubmissionResponse
|
||||
fmt.Fprintf(os.Stdout, "Response from `SlurmAPI.SlurmctldSubmitJob`: %v\n", resp)
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSlurmctldSubmitJobRequest struct via the builder pattern
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**v0037JobSubmission** | [**V0037JobSubmission**](V0037JobSubmission.md) | submit new job |
|
||||
|
||||
### Return type
|
||||
|
||||
[**V0037JobSubmissionResponse**](V0037JobSubmissionResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/x-yaml
|
||||
- **Accept**: application/json, application/x-yaml
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
|
||||
## SlurmctldUpdateJob
|
||||
|
||||
> SlurmctldUpdateJob(ctx, jobId).V0037JobProperties(v0037JobProperties).Execute()
|
||||
|
||||
update job
|
||||
|
||||
### Example
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
jobId := "jobId_example" // string | Slurm Job ID
|
||||
v0037JobProperties := *openapiclient.NewV0037JobProperties(map[string]interface{}(123)) // V0037JobProperties | update job
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
r, err := apiClient.SlurmAPI.SlurmctldUpdateJob(context.Background(), jobId).V0037JobProperties(v0037JobProperties).Execute()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error when calling `SlurmAPI.SlurmctldUpdateJob``: %v\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Path Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
|
||||
**jobId** | **string** | Slurm Job ID |
|
||||
|
||||
### Other Parameters
|
||||
|
||||
Other parameters are passed through a pointer to a apiSlurmctldUpdateJobRequest struct via the builder pattern
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
|
||||
**v0037JobProperties** | [**V0037JobProperties**](V0037JobProperties.md) | update job |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[user](../README.md#user), [token](../README.md#token)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/x-yaml
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
# V0037Diag
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Errors** | Pointer to [**[]V0037Error**](V0037Error.md) | slurm errors | [optional]
|
||||
**Statistics** | Pointer to [**V0037DiagStatistics**](V0037DiagStatistics.md) | | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037Diag
|
||||
|
||||
`func NewV0037Diag() *V0037Diag`
|
||||
|
||||
NewV0037Diag instantiates a new V0037Diag object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037DiagWithDefaults
|
||||
|
||||
`func NewV0037DiagWithDefaults() *V0037Diag`
|
||||
|
||||
NewV0037DiagWithDefaults instantiates a new V0037Diag object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetErrors
|
||||
|
||||
`func (o *V0037Diag) GetErrors() []V0037Error`
|
||||
|
||||
GetErrors returns the Errors field if non-nil, zero value otherwise.
|
||||
|
||||
### GetErrorsOk
|
||||
|
||||
`func (o *V0037Diag) GetErrorsOk() (*[]V0037Error, bool)`
|
||||
|
||||
GetErrorsOk returns a tuple with the Errors field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetErrors
|
||||
|
||||
`func (o *V0037Diag) SetErrors(v []V0037Error)`
|
||||
|
||||
SetErrors sets Errors field to given value.
|
||||
|
||||
### HasErrors
|
||||
|
||||
`func (o *V0037Diag) HasErrors() bool`
|
||||
|
||||
HasErrors returns a boolean if a field has been set.
|
||||
|
||||
### GetStatistics
|
||||
|
||||
`func (o *V0037Diag) GetStatistics() V0037DiagStatistics`
|
||||
|
||||
GetStatistics returns the Statistics field if non-nil, zero value otherwise.
|
||||
|
||||
### GetStatisticsOk
|
||||
|
||||
`func (o *V0037Diag) GetStatisticsOk() (*V0037DiagStatistics, bool)`
|
||||
|
||||
GetStatisticsOk returns a tuple with the Statistics field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetStatistics
|
||||
|
||||
`func (o *V0037Diag) SetStatistics(v V0037DiagStatistics)`
|
||||
|
||||
SetStatistics sets Statistics field to given value.
|
||||
|
||||
### HasStatistics
|
||||
|
||||
`func (o *V0037Diag) HasStatistics() bool`
|
||||
|
||||
HasStatistics returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,82 +0,0 @@
|
||||
# V0037Error
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Error** | Pointer to **string** | error message | [optional]
|
||||
**Errno** | Pointer to **int32** | error number | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037Error
|
||||
|
||||
`func NewV0037Error() *V0037Error`
|
||||
|
||||
NewV0037Error instantiates a new V0037Error object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037ErrorWithDefaults
|
||||
|
||||
`func NewV0037ErrorWithDefaults() *V0037Error`
|
||||
|
||||
NewV0037ErrorWithDefaults instantiates a new V0037Error object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetError
|
||||
|
||||
`func (o *V0037Error) GetError() string`
|
||||
|
||||
GetError returns the Error field if non-nil, zero value otherwise.
|
||||
|
||||
### GetErrorOk
|
||||
|
||||
`func (o *V0037Error) GetErrorOk() (*string, bool)`
|
||||
|
||||
GetErrorOk returns a tuple with the Error field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetError
|
||||
|
||||
`func (o *V0037Error) SetError(v string)`
|
||||
|
||||
SetError sets Error field to given value.
|
||||
|
||||
### HasError
|
||||
|
||||
`func (o *V0037Error) HasError() bool`
|
||||
|
||||
HasError returns a boolean if a field has been set.
|
||||
|
||||
### GetErrno
|
||||
|
||||
`func (o *V0037Error) GetErrno() int32`
|
||||
|
||||
GetErrno returns the Errno field if non-nil, zero value otherwise.
|
||||
|
||||
### GetErrnoOk
|
||||
|
||||
`func (o *V0037Error) GetErrnoOk() (*int32, bool)`
|
||||
|
||||
GetErrnoOk returns a tuple with the Errno field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetErrno
|
||||
|
||||
`func (o *V0037Error) SetErrno(v int32)`
|
||||
|
||||
SetErrno sets Errno field to given value.
|
||||
|
||||
### HasErrno
|
||||
|
||||
`func (o *V0037Error) HasErrno() bool`
|
||||
|
||||
HasErrno returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,134 +0,0 @@
|
||||
# V0037JobResources
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Nodes** | Pointer to **string** | list of assigned job nodes | [optional]
|
||||
**AllocatedCpus** | Pointer to **int32** | number of assigned job cpus | [optional]
|
||||
**AllocatedHosts** | Pointer to **int32** | number of assigned job hosts | [optional]
|
||||
**AllocatedNodes** | Pointer to [**[]V0037NodeAllocation**](V0037NodeAllocation.md) | node allocations | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037JobResources
|
||||
|
||||
`func NewV0037JobResources() *V0037JobResources`
|
||||
|
||||
NewV0037JobResources instantiates a new V0037JobResources object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037JobResourcesWithDefaults
|
||||
|
||||
`func NewV0037JobResourcesWithDefaults() *V0037JobResources`
|
||||
|
||||
NewV0037JobResourcesWithDefaults instantiates a new V0037JobResources object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetNodes
|
||||
|
||||
`func (o *V0037JobResources) GetNodes() string`
|
||||
|
||||
GetNodes returns the Nodes field if non-nil, zero value otherwise.
|
||||
|
||||
### GetNodesOk
|
||||
|
||||
`func (o *V0037JobResources) GetNodesOk() (*string, bool)`
|
||||
|
||||
GetNodesOk returns a tuple with the Nodes field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetNodes
|
||||
|
||||
`func (o *V0037JobResources) SetNodes(v string)`
|
||||
|
||||
SetNodes sets Nodes field to given value.
|
||||
|
||||
### HasNodes
|
||||
|
||||
`func (o *V0037JobResources) HasNodes() bool`
|
||||
|
||||
HasNodes returns a boolean if a field has been set.
|
||||
|
||||
### GetAllocatedCpus
|
||||
|
||||
`func (o *V0037JobResources) GetAllocatedCpus() int32`
|
||||
|
||||
GetAllocatedCpus returns the AllocatedCpus field if non-nil, zero value otherwise.
|
||||
|
||||
### GetAllocatedCpusOk
|
||||
|
||||
`func (o *V0037JobResources) GetAllocatedCpusOk() (*int32, bool)`
|
||||
|
||||
GetAllocatedCpusOk returns a tuple with the AllocatedCpus field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetAllocatedCpus
|
||||
|
||||
`func (o *V0037JobResources) SetAllocatedCpus(v int32)`
|
||||
|
||||
SetAllocatedCpus sets AllocatedCpus field to given value.
|
||||
|
||||
### HasAllocatedCpus
|
||||
|
||||
`func (o *V0037JobResources) HasAllocatedCpus() bool`
|
||||
|
||||
HasAllocatedCpus returns a boolean if a field has been set.
|
||||
|
||||
### GetAllocatedHosts
|
||||
|
||||
`func (o *V0037JobResources) GetAllocatedHosts() int32`
|
||||
|
||||
GetAllocatedHosts returns the AllocatedHosts field if non-nil, zero value otherwise.
|
||||
|
||||
### GetAllocatedHostsOk
|
||||
|
||||
`func (o *V0037JobResources) GetAllocatedHostsOk() (*int32, bool)`
|
||||
|
||||
GetAllocatedHostsOk returns a tuple with the AllocatedHosts field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetAllocatedHosts
|
||||
|
||||
`func (o *V0037JobResources) SetAllocatedHosts(v int32)`
|
||||
|
||||
SetAllocatedHosts sets AllocatedHosts field to given value.
|
||||
|
||||
### HasAllocatedHosts
|
||||
|
||||
`func (o *V0037JobResources) HasAllocatedHosts() bool`
|
||||
|
||||
HasAllocatedHosts returns a boolean if a field has been set.
|
||||
|
||||
### GetAllocatedNodes
|
||||
|
||||
`func (o *V0037JobResources) GetAllocatedNodes() []V0037NodeAllocation`
|
||||
|
||||
GetAllocatedNodes returns the AllocatedNodes field if non-nil, zero value otherwise.
|
||||
|
||||
### GetAllocatedNodesOk
|
||||
|
||||
`func (o *V0037JobResources) GetAllocatedNodesOk() (*[]V0037NodeAllocation, bool)`
|
||||
|
||||
GetAllocatedNodesOk returns a tuple with the AllocatedNodes field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetAllocatedNodes
|
||||
|
||||
`func (o *V0037JobResources) SetAllocatedNodes(v []V0037NodeAllocation)`
|
||||
|
||||
SetAllocatedNodes sets AllocatedNodes field to given value.
|
||||
|
||||
### HasAllocatedNodes
|
||||
|
||||
`func (o *V0037JobResources) HasAllocatedNodes() bool`
|
||||
|
||||
HasAllocatedNodes returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,103 +0,0 @@
|
||||
# V0037JobSubmission
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Script** | **string** | Executable script (full contents) to run in batch step |
|
||||
**Job** | Pointer to [**V0037JobProperties**](V0037JobProperties.md) | | [optional]
|
||||
**Jobs** | Pointer to [**[]V0037JobProperties**](V0037JobProperties.md) | Properties of an HetJob | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037JobSubmission
|
||||
|
||||
`func NewV0037JobSubmission(script string, ) *V0037JobSubmission`
|
||||
|
||||
NewV0037JobSubmission instantiates a new V0037JobSubmission object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037JobSubmissionWithDefaults
|
||||
|
||||
`func NewV0037JobSubmissionWithDefaults() *V0037JobSubmission`
|
||||
|
||||
NewV0037JobSubmissionWithDefaults instantiates a new V0037JobSubmission object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetScript
|
||||
|
||||
`func (o *V0037JobSubmission) GetScript() string`
|
||||
|
||||
GetScript returns the Script field if non-nil, zero value otherwise.
|
||||
|
||||
### GetScriptOk
|
||||
|
||||
`func (o *V0037JobSubmission) GetScriptOk() (*string, bool)`
|
||||
|
||||
GetScriptOk returns a tuple with the Script field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetScript
|
||||
|
||||
`func (o *V0037JobSubmission) SetScript(v string)`
|
||||
|
||||
SetScript sets Script field to given value.
|
||||
|
||||
|
||||
### GetJob
|
||||
|
||||
`func (o *V0037JobSubmission) GetJob() V0037JobProperties`
|
||||
|
||||
GetJob returns the Job field if non-nil, zero value otherwise.
|
||||
|
||||
### GetJobOk
|
||||
|
||||
`func (o *V0037JobSubmission) GetJobOk() (*V0037JobProperties, bool)`
|
||||
|
||||
GetJobOk returns a tuple with the Job field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetJob
|
||||
|
||||
`func (o *V0037JobSubmission) SetJob(v V0037JobProperties)`
|
||||
|
||||
SetJob sets Job field to given value.
|
||||
|
||||
### HasJob
|
||||
|
||||
`func (o *V0037JobSubmission) HasJob() bool`
|
||||
|
||||
HasJob returns a boolean if a field has been set.
|
||||
|
||||
### GetJobs
|
||||
|
||||
`func (o *V0037JobSubmission) GetJobs() []V0037JobProperties`
|
||||
|
||||
GetJobs returns the Jobs field if non-nil, zero value otherwise.
|
||||
|
||||
### GetJobsOk
|
||||
|
||||
`func (o *V0037JobSubmission) GetJobsOk() (*[]V0037JobProperties, bool)`
|
||||
|
||||
GetJobsOk returns a tuple with the Jobs field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetJobs
|
||||
|
||||
`func (o *V0037JobSubmission) SetJobs(v []V0037JobProperties)`
|
||||
|
||||
SetJobs sets Jobs field to given value.
|
||||
|
||||
### HasJobs
|
||||
|
||||
`func (o *V0037JobSubmission) HasJobs() bool`
|
||||
|
||||
HasJobs returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
# V0037JobSubmissionResponse
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Errors** | Pointer to [**[]V0037Error**](V0037Error.md) | slurm errors | [optional]
|
||||
**JobId** | Pointer to **int32** | new job ID | [optional]
|
||||
**StepId** | Pointer to **string** | new job step ID | [optional]
|
||||
**JobSubmitUserMsg** | Pointer to **string** | Message to user from job_submit plugin | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037JobSubmissionResponse
|
||||
|
||||
`func NewV0037JobSubmissionResponse() *V0037JobSubmissionResponse`
|
||||
|
||||
NewV0037JobSubmissionResponse instantiates a new V0037JobSubmissionResponse object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037JobSubmissionResponseWithDefaults
|
||||
|
||||
`func NewV0037JobSubmissionResponseWithDefaults() *V0037JobSubmissionResponse`
|
||||
|
||||
NewV0037JobSubmissionResponseWithDefaults instantiates a new V0037JobSubmissionResponse object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetErrors
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) GetErrors() []V0037Error`
|
||||
|
||||
GetErrors returns the Errors field if non-nil, zero value otherwise.
|
||||
|
||||
### GetErrorsOk
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) GetErrorsOk() (*[]V0037Error, bool)`
|
||||
|
||||
GetErrorsOk returns a tuple with the Errors field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetErrors
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) SetErrors(v []V0037Error)`
|
||||
|
||||
SetErrors sets Errors field to given value.
|
||||
|
||||
### HasErrors
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) HasErrors() bool`
|
||||
|
||||
HasErrors returns a boolean if a field has been set.
|
||||
|
||||
### GetJobId
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) GetJobId() int32`
|
||||
|
||||
GetJobId returns the JobId field if non-nil, zero value otherwise.
|
||||
|
||||
### GetJobIdOk
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) GetJobIdOk() (*int32, bool)`
|
||||
|
||||
GetJobIdOk returns a tuple with the JobId field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetJobId
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) SetJobId(v int32)`
|
||||
|
||||
SetJobId sets JobId field to given value.
|
||||
|
||||
### HasJobId
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) HasJobId() bool`
|
||||
|
||||
HasJobId returns a boolean if a field has been set.
|
||||
|
||||
### GetStepId
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) GetStepId() string`
|
||||
|
||||
GetStepId returns the StepId field if non-nil, zero value otherwise.
|
||||
|
||||
### GetStepIdOk
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) GetStepIdOk() (*string, bool)`
|
||||
|
||||
GetStepIdOk returns a tuple with the StepId field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetStepId
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) SetStepId(v string)`
|
||||
|
||||
SetStepId sets StepId field to given value.
|
||||
|
||||
### HasStepId
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) HasStepId() bool`
|
||||
|
||||
HasStepId returns a boolean if a field has been set.
|
||||
|
||||
### GetJobSubmitUserMsg
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) GetJobSubmitUserMsg() string`
|
||||
|
||||
GetJobSubmitUserMsg returns the JobSubmitUserMsg field if non-nil, zero value otherwise.
|
||||
|
||||
### GetJobSubmitUserMsgOk
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) GetJobSubmitUserMsgOk() (*string, bool)`
|
||||
|
||||
GetJobSubmitUserMsgOk returns a tuple with the JobSubmitUserMsg field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetJobSubmitUserMsg
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) SetJobSubmitUserMsg(v string)`
|
||||
|
||||
SetJobSubmitUserMsg sets JobSubmitUserMsg field to given value.
|
||||
|
||||
### HasJobSubmitUserMsg
|
||||
|
||||
`func (o *V0037JobSubmissionResponse) HasJobSubmitUserMsg() bool`
|
||||
|
||||
HasJobSubmitUserMsg returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
# V0037JobsResponse
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Errors** | Pointer to [**[]V0037Error**](V0037Error.md) | slurm errors | [optional]
|
||||
**Jobs** | Pointer to [**[]V0037JobResponseProperties**](V0037JobResponseProperties.md) | job descriptions | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037JobsResponse
|
||||
|
||||
`func NewV0037JobsResponse() *V0037JobsResponse`
|
||||
|
||||
NewV0037JobsResponse instantiates a new V0037JobsResponse object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037JobsResponseWithDefaults
|
||||
|
||||
`func NewV0037JobsResponseWithDefaults() *V0037JobsResponse`
|
||||
|
||||
NewV0037JobsResponseWithDefaults instantiates a new V0037JobsResponse object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetErrors
|
||||
|
||||
`func (o *V0037JobsResponse) GetErrors() []V0037Error`
|
||||
|
||||
GetErrors returns the Errors field if non-nil, zero value otherwise.
|
||||
|
||||
### GetErrorsOk
|
||||
|
||||
`func (o *V0037JobsResponse) GetErrorsOk() (*[]V0037Error, bool)`
|
||||
|
||||
GetErrorsOk returns a tuple with the Errors field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetErrors
|
||||
|
||||
`func (o *V0037JobsResponse) SetErrors(v []V0037Error)`
|
||||
|
||||
SetErrors sets Errors field to given value.
|
||||
|
||||
### HasErrors
|
||||
|
||||
`func (o *V0037JobsResponse) HasErrors() bool`
|
||||
|
||||
HasErrors returns a boolean if a field has been set.
|
||||
|
||||
### GetJobs
|
||||
|
||||
`func (o *V0037JobsResponse) GetJobs() []V0037JobResponseProperties`
|
||||
|
||||
GetJobs returns the Jobs field if non-nil, zero value otherwise.
|
||||
|
||||
### GetJobsOk
|
||||
|
||||
`func (o *V0037JobsResponse) GetJobsOk() (*[]V0037JobResponseProperties, bool)`
|
||||
|
||||
GetJobsOk returns a tuple with the Jobs field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetJobs
|
||||
|
||||
`func (o *V0037JobsResponse) SetJobs(v []V0037JobResponseProperties)`
|
||||
|
||||
SetJobs sets Jobs field to given value.
|
||||
|
||||
### HasJobs
|
||||
|
||||
`func (o *V0037JobsResponse) HasJobs() bool`
|
||||
|
||||
HasJobs returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,134 +0,0 @@
|
||||
# V0037NodeAllocation
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Memory** | Pointer to **int32** | amount of assigned job memory | [optional]
|
||||
**Cpus** | Pointer to **map[string]interface{}** | amount of assigned job CPUs | [optional]
|
||||
**Sockets** | Pointer to **map[string]interface{}** | assignment status of each socket by socket id | [optional]
|
||||
**Cores** | Pointer to **map[string]interface{}** | assignment status of each core by core id | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037NodeAllocation
|
||||
|
||||
`func NewV0037NodeAllocation() *V0037NodeAllocation`
|
||||
|
||||
NewV0037NodeAllocation instantiates a new V0037NodeAllocation object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037NodeAllocationWithDefaults
|
||||
|
||||
`func NewV0037NodeAllocationWithDefaults() *V0037NodeAllocation`
|
||||
|
||||
NewV0037NodeAllocationWithDefaults instantiates a new V0037NodeAllocation object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetMemory
|
||||
|
||||
`func (o *V0037NodeAllocation) GetMemory() int32`
|
||||
|
||||
GetMemory returns the Memory field if non-nil, zero value otherwise.
|
||||
|
||||
### GetMemoryOk
|
||||
|
||||
`func (o *V0037NodeAllocation) GetMemoryOk() (*int32, bool)`
|
||||
|
||||
GetMemoryOk returns a tuple with the Memory field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetMemory
|
||||
|
||||
`func (o *V0037NodeAllocation) SetMemory(v int32)`
|
||||
|
||||
SetMemory sets Memory field to given value.
|
||||
|
||||
### HasMemory
|
||||
|
||||
`func (o *V0037NodeAllocation) HasMemory() bool`
|
||||
|
||||
HasMemory returns a boolean if a field has been set.
|
||||
|
||||
### GetCpus
|
||||
|
||||
`func (o *V0037NodeAllocation) GetCpus() map[string]interface{}`
|
||||
|
||||
GetCpus returns the Cpus field if non-nil, zero value otherwise.
|
||||
|
||||
### GetCpusOk
|
||||
|
||||
`func (o *V0037NodeAllocation) GetCpusOk() (*map[string]interface{}, bool)`
|
||||
|
||||
GetCpusOk returns a tuple with the Cpus field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetCpus
|
||||
|
||||
`func (o *V0037NodeAllocation) SetCpus(v map[string]interface{})`
|
||||
|
||||
SetCpus sets Cpus field to given value.
|
||||
|
||||
### HasCpus
|
||||
|
||||
`func (o *V0037NodeAllocation) HasCpus() bool`
|
||||
|
||||
HasCpus returns a boolean if a field has been set.
|
||||
|
||||
### GetSockets
|
||||
|
||||
`func (o *V0037NodeAllocation) GetSockets() map[string]interface{}`
|
||||
|
||||
GetSockets returns the Sockets field if non-nil, zero value otherwise.
|
||||
|
||||
### GetSocketsOk
|
||||
|
||||
`func (o *V0037NodeAllocation) GetSocketsOk() (*map[string]interface{}, bool)`
|
||||
|
||||
GetSocketsOk returns a tuple with the Sockets field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetSockets
|
||||
|
||||
`func (o *V0037NodeAllocation) SetSockets(v map[string]interface{})`
|
||||
|
||||
SetSockets sets Sockets field to given value.
|
||||
|
||||
### HasSockets
|
||||
|
||||
`func (o *V0037NodeAllocation) HasSockets() bool`
|
||||
|
||||
HasSockets returns a boolean if a field has been set.
|
||||
|
||||
### GetCores
|
||||
|
||||
`func (o *V0037NodeAllocation) GetCores() map[string]interface{}`
|
||||
|
||||
GetCores returns the Cores field if non-nil, zero value otherwise.
|
||||
|
||||
### GetCoresOk
|
||||
|
||||
`func (o *V0037NodeAllocation) GetCoresOk() (*map[string]interface{}, bool)`
|
||||
|
||||
GetCoresOk returns a tuple with the Cores field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetCores
|
||||
|
||||
`func (o *V0037NodeAllocation) SetCores(v map[string]interface{})`
|
||||
|
||||
SetCores sets Cores field to given value.
|
||||
|
||||
### HasCores
|
||||
|
||||
`func (o *V0037NodeAllocation) HasCores() bool`
|
||||
|
||||
HasCores returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
# V0037NodesResponse
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Errors** | Pointer to [**[]V0037Error**](V0037Error.md) | slurm errors | [optional]
|
||||
**Nodes** | Pointer to [**[]V0037Node**](V0037Node.md) | nodes info | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037NodesResponse
|
||||
|
||||
`func NewV0037NodesResponse() *V0037NodesResponse`
|
||||
|
||||
NewV0037NodesResponse instantiates a new V0037NodesResponse object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037NodesResponseWithDefaults
|
||||
|
||||
`func NewV0037NodesResponseWithDefaults() *V0037NodesResponse`
|
||||
|
||||
NewV0037NodesResponseWithDefaults instantiates a new V0037NodesResponse object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetErrors
|
||||
|
||||
`func (o *V0037NodesResponse) GetErrors() []V0037Error`
|
||||
|
||||
GetErrors returns the Errors field if non-nil, zero value otherwise.
|
||||
|
||||
### GetErrorsOk
|
||||
|
||||
`func (o *V0037NodesResponse) GetErrorsOk() (*[]V0037Error, bool)`
|
||||
|
||||
GetErrorsOk returns a tuple with the Errors field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetErrors
|
||||
|
||||
`func (o *V0037NodesResponse) SetErrors(v []V0037Error)`
|
||||
|
||||
SetErrors sets Errors field to given value.
|
||||
|
||||
### HasErrors
|
||||
|
||||
`func (o *V0037NodesResponse) HasErrors() bool`
|
||||
|
||||
HasErrors returns a boolean if a field has been set.
|
||||
|
||||
### GetNodes
|
||||
|
||||
`func (o *V0037NodesResponse) GetNodes() []V0037Node`
|
||||
|
||||
GetNodes returns the Nodes field if non-nil, zero value otherwise.
|
||||
|
||||
### GetNodesOk
|
||||
|
||||
`func (o *V0037NodesResponse) GetNodesOk() (*[]V0037Node, bool)`
|
||||
|
||||
GetNodesOk returns a tuple with the Nodes field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetNodes
|
||||
|
||||
`func (o *V0037NodesResponse) SetNodes(v []V0037Node)`
|
||||
|
||||
SetNodes sets Nodes field to given value.
|
||||
|
||||
### HasNodes
|
||||
|
||||
`func (o *V0037NodesResponse) HasNodes() bool`
|
||||
|
||||
HasNodes returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,758 +0,0 @@
|
||||
# V0037Partition
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Flags** | Pointer to **[]string** | partition options | [optional]
|
||||
**PreemptionMode** | Pointer to **[]string** | preemption type | [optional]
|
||||
**AllowedAllocationNodes** | Pointer to **string** | list names of allowed allocating nodes | [optional]
|
||||
**AllowedAccounts** | Pointer to **string** | comma delimited list of accounts | [optional]
|
||||
**AllowedGroups** | Pointer to **string** | comma delimited list of groups | [optional]
|
||||
**AllowedQos** | Pointer to **string** | comma delimited list of qos | [optional]
|
||||
**Alternative** | Pointer to **string** | name of alternate partition | [optional]
|
||||
**BillingWeights** | Pointer to **string** | TRES billing weights | [optional]
|
||||
**DefaultMemoryPerCpu** | Pointer to **int64** | default MB memory per allocated CPU | [optional]
|
||||
**DefaultTimeLimit** | Pointer to **int64** | default time limit (minutes) | [optional]
|
||||
**DeniedAccounts** | Pointer to **string** | comma delimited list of denied accounts | [optional]
|
||||
**DeniedQos** | Pointer to **string** | comma delimited list of denied qos | [optional]
|
||||
**PreemptionGraceTime** | Pointer to **int64** | preemption grace time (seconds) | [optional]
|
||||
**MaximumCpusPerNode** | Pointer to **int32** | maximum allocated CPUs per node | [optional]
|
||||
**MaximumMemoryPerNode** | Pointer to **int64** | maximum memory per allocated CPU (MiB) | [optional]
|
||||
**MaximumNodesPerJob** | Pointer to **int32** | Max nodes per job | [optional]
|
||||
**MaxTimeLimit** | Pointer to **int64** | Max time limit per job | [optional]
|
||||
**MinNodesPerJob** | Pointer to **int32** | Min number of nodes per job | [optional]
|
||||
**Name** | Pointer to **string** | Partition name | [optional]
|
||||
**Nodes** | Pointer to **string** | list names of nodes in partition | [optional]
|
||||
**OverTimeLimit** | Pointer to **int32** | job's time limit can be exceeded by this number of minutes before cancellation | [optional]
|
||||
**PriorityJobFactor** | Pointer to **int32** | job priority weight factor | [optional]
|
||||
**PriorityTier** | Pointer to **int32** | tier for scheduling and preemption | [optional]
|
||||
**Qos** | Pointer to **string** | partition QOS name | [optional]
|
||||
**State** | Pointer to **string** | Partition state | [optional]
|
||||
**TotalCpus** | Pointer to **int32** | Total cpus in partition | [optional]
|
||||
**TotalNodes** | Pointer to **int32** | Total number of nodes in partition | [optional]
|
||||
**Tres** | Pointer to **string** | configured TRES in partition | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037Partition
|
||||
|
||||
`func NewV0037Partition() *V0037Partition`
|
||||
|
||||
NewV0037Partition instantiates a new V0037Partition object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037PartitionWithDefaults
|
||||
|
||||
`func NewV0037PartitionWithDefaults() *V0037Partition`
|
||||
|
||||
NewV0037PartitionWithDefaults instantiates a new V0037Partition object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetFlags
|
||||
|
||||
`func (o *V0037Partition) GetFlags() []string`
|
||||
|
||||
GetFlags returns the Flags field if non-nil, zero value otherwise.
|
||||
|
||||
### GetFlagsOk
|
||||
|
||||
`func (o *V0037Partition) GetFlagsOk() (*[]string, bool)`
|
||||
|
||||
GetFlagsOk returns a tuple with the Flags field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetFlags
|
||||
|
||||
`func (o *V0037Partition) SetFlags(v []string)`
|
||||
|
||||
SetFlags sets Flags field to given value.
|
||||
|
||||
### HasFlags
|
||||
|
||||
`func (o *V0037Partition) HasFlags() bool`
|
||||
|
||||
HasFlags returns a boolean if a field has been set.
|
||||
|
||||
### GetPreemptionMode
|
||||
|
||||
`func (o *V0037Partition) GetPreemptionMode() []string`
|
||||
|
||||
GetPreemptionMode returns the PreemptionMode field if non-nil, zero value otherwise.
|
||||
|
||||
### GetPreemptionModeOk
|
||||
|
||||
`func (o *V0037Partition) GetPreemptionModeOk() (*[]string, bool)`
|
||||
|
||||
GetPreemptionModeOk returns a tuple with the PreemptionMode field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetPreemptionMode
|
||||
|
||||
`func (o *V0037Partition) SetPreemptionMode(v []string)`
|
||||
|
||||
SetPreemptionMode sets PreemptionMode field to given value.
|
||||
|
||||
### HasPreemptionMode
|
||||
|
||||
`func (o *V0037Partition) HasPreemptionMode() bool`
|
||||
|
||||
HasPreemptionMode returns a boolean if a field has been set.
|
||||
|
||||
### GetAllowedAllocationNodes
|
||||
|
||||
`func (o *V0037Partition) GetAllowedAllocationNodes() string`
|
||||
|
||||
GetAllowedAllocationNodes returns the AllowedAllocationNodes field if non-nil, zero value otherwise.
|
||||
|
||||
### GetAllowedAllocationNodesOk
|
||||
|
||||
`func (o *V0037Partition) GetAllowedAllocationNodesOk() (*string, bool)`
|
||||
|
||||
GetAllowedAllocationNodesOk returns a tuple with the AllowedAllocationNodes field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetAllowedAllocationNodes
|
||||
|
||||
`func (o *V0037Partition) SetAllowedAllocationNodes(v string)`
|
||||
|
||||
SetAllowedAllocationNodes sets AllowedAllocationNodes field to given value.
|
||||
|
||||
### HasAllowedAllocationNodes
|
||||
|
||||
`func (o *V0037Partition) HasAllowedAllocationNodes() bool`
|
||||
|
||||
HasAllowedAllocationNodes returns a boolean if a field has been set.
|
||||
|
||||
### GetAllowedAccounts
|
||||
|
||||
`func (o *V0037Partition) GetAllowedAccounts() string`
|
||||
|
||||
GetAllowedAccounts returns the AllowedAccounts field if non-nil, zero value otherwise.
|
||||
|
||||
### GetAllowedAccountsOk
|
||||
|
||||
`func (o *V0037Partition) GetAllowedAccountsOk() (*string, bool)`
|
||||
|
||||
GetAllowedAccountsOk returns a tuple with the AllowedAccounts field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetAllowedAccounts
|
||||
|
||||
`func (o *V0037Partition) SetAllowedAccounts(v string)`
|
||||
|
||||
SetAllowedAccounts sets AllowedAccounts field to given value.
|
||||
|
||||
### HasAllowedAccounts
|
||||
|
||||
`func (o *V0037Partition) HasAllowedAccounts() bool`
|
||||
|
||||
HasAllowedAccounts returns a boolean if a field has been set.
|
||||
|
||||
### GetAllowedGroups
|
||||
|
||||
`func (o *V0037Partition) GetAllowedGroups() string`
|
||||
|
||||
GetAllowedGroups returns the AllowedGroups field if non-nil, zero value otherwise.
|
||||
|
||||
### GetAllowedGroupsOk
|
||||
|
||||
`func (o *V0037Partition) GetAllowedGroupsOk() (*string, bool)`
|
||||
|
||||
GetAllowedGroupsOk returns a tuple with the AllowedGroups field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetAllowedGroups
|
||||
|
||||
`func (o *V0037Partition) SetAllowedGroups(v string)`
|
||||
|
||||
SetAllowedGroups sets AllowedGroups field to given value.
|
||||
|
||||
### HasAllowedGroups
|
||||
|
||||
`func (o *V0037Partition) HasAllowedGroups() bool`
|
||||
|
||||
HasAllowedGroups returns a boolean if a field has been set.
|
||||
|
||||
### GetAllowedQos
|
||||
|
||||
`func (o *V0037Partition) GetAllowedQos() string`
|
||||
|
||||
GetAllowedQos returns the AllowedQos field if non-nil, zero value otherwise.
|
||||
|
||||
### GetAllowedQosOk
|
||||
|
||||
`func (o *V0037Partition) GetAllowedQosOk() (*string, bool)`
|
||||
|
||||
GetAllowedQosOk returns a tuple with the AllowedQos field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetAllowedQos
|
||||
|
||||
`func (o *V0037Partition) SetAllowedQos(v string)`
|
||||
|
||||
SetAllowedQos sets AllowedQos field to given value.
|
||||
|
||||
### HasAllowedQos
|
||||
|
||||
`func (o *V0037Partition) HasAllowedQos() bool`
|
||||
|
||||
HasAllowedQos returns a boolean if a field has been set.
|
||||
|
||||
### GetAlternative
|
||||
|
||||
`func (o *V0037Partition) GetAlternative() string`
|
||||
|
||||
GetAlternative returns the Alternative field if non-nil, zero value otherwise.
|
||||
|
||||
### GetAlternativeOk
|
||||
|
||||
`func (o *V0037Partition) GetAlternativeOk() (*string, bool)`
|
||||
|
||||
GetAlternativeOk returns a tuple with the Alternative field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetAlternative
|
||||
|
||||
`func (o *V0037Partition) SetAlternative(v string)`
|
||||
|
||||
SetAlternative sets Alternative field to given value.
|
||||
|
||||
### HasAlternative
|
||||
|
||||
`func (o *V0037Partition) HasAlternative() bool`
|
||||
|
||||
HasAlternative returns a boolean if a field has been set.
|
||||
|
||||
### GetBillingWeights
|
||||
|
||||
`func (o *V0037Partition) GetBillingWeights() string`
|
||||
|
||||
GetBillingWeights returns the BillingWeights field if non-nil, zero value otherwise.
|
||||
|
||||
### GetBillingWeightsOk
|
||||
|
||||
`func (o *V0037Partition) GetBillingWeightsOk() (*string, bool)`
|
||||
|
||||
GetBillingWeightsOk returns a tuple with the BillingWeights field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetBillingWeights
|
||||
|
||||
`func (o *V0037Partition) SetBillingWeights(v string)`
|
||||
|
||||
SetBillingWeights sets BillingWeights field to given value.
|
||||
|
||||
### HasBillingWeights
|
||||
|
||||
`func (o *V0037Partition) HasBillingWeights() bool`
|
||||
|
||||
HasBillingWeights returns a boolean if a field has been set.
|
||||
|
||||
### GetDefaultMemoryPerCpu
|
||||
|
||||
`func (o *V0037Partition) GetDefaultMemoryPerCpu() int64`
|
||||
|
||||
GetDefaultMemoryPerCpu returns the DefaultMemoryPerCpu field if non-nil, zero value otherwise.
|
||||
|
||||
### GetDefaultMemoryPerCpuOk
|
||||
|
||||
`func (o *V0037Partition) GetDefaultMemoryPerCpuOk() (*int64, bool)`
|
||||
|
||||
GetDefaultMemoryPerCpuOk returns a tuple with the DefaultMemoryPerCpu field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetDefaultMemoryPerCpu
|
||||
|
||||
`func (o *V0037Partition) SetDefaultMemoryPerCpu(v int64)`
|
||||
|
||||
SetDefaultMemoryPerCpu sets DefaultMemoryPerCpu field to given value.
|
||||
|
||||
### HasDefaultMemoryPerCpu
|
||||
|
||||
`func (o *V0037Partition) HasDefaultMemoryPerCpu() bool`
|
||||
|
||||
HasDefaultMemoryPerCpu returns a boolean if a field has been set.
|
||||
|
||||
### GetDefaultTimeLimit
|
||||
|
||||
`func (o *V0037Partition) GetDefaultTimeLimit() int64`
|
||||
|
||||
GetDefaultTimeLimit returns the DefaultTimeLimit field if non-nil, zero value otherwise.
|
||||
|
||||
### GetDefaultTimeLimitOk
|
||||
|
||||
`func (o *V0037Partition) GetDefaultTimeLimitOk() (*int64, bool)`
|
||||
|
||||
GetDefaultTimeLimitOk returns a tuple with the DefaultTimeLimit field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetDefaultTimeLimit
|
||||
|
||||
`func (o *V0037Partition) SetDefaultTimeLimit(v int64)`
|
||||
|
||||
SetDefaultTimeLimit sets DefaultTimeLimit field to given value.
|
||||
|
||||
### HasDefaultTimeLimit
|
||||
|
||||
`func (o *V0037Partition) HasDefaultTimeLimit() bool`
|
||||
|
||||
HasDefaultTimeLimit returns a boolean if a field has been set.
|
||||
|
||||
### GetDeniedAccounts
|
||||
|
||||
`func (o *V0037Partition) GetDeniedAccounts() string`
|
||||
|
||||
GetDeniedAccounts returns the DeniedAccounts field if non-nil, zero value otherwise.
|
||||
|
||||
### GetDeniedAccountsOk
|
||||
|
||||
`func (o *V0037Partition) GetDeniedAccountsOk() (*string, bool)`
|
||||
|
||||
GetDeniedAccountsOk returns a tuple with the DeniedAccounts field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetDeniedAccounts
|
||||
|
||||
`func (o *V0037Partition) SetDeniedAccounts(v string)`
|
||||
|
||||
SetDeniedAccounts sets DeniedAccounts field to given value.
|
||||
|
||||
### HasDeniedAccounts
|
||||
|
||||
`func (o *V0037Partition) HasDeniedAccounts() bool`
|
||||
|
||||
HasDeniedAccounts returns a boolean if a field has been set.
|
||||
|
||||
### GetDeniedQos
|
||||
|
||||
`func (o *V0037Partition) GetDeniedQos() string`
|
||||
|
||||
GetDeniedQos returns the DeniedQos field if non-nil, zero value otherwise.
|
||||
|
||||
### GetDeniedQosOk
|
||||
|
||||
`func (o *V0037Partition) GetDeniedQosOk() (*string, bool)`
|
||||
|
||||
GetDeniedQosOk returns a tuple with the DeniedQos field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetDeniedQos
|
||||
|
||||
`func (o *V0037Partition) SetDeniedQos(v string)`
|
||||
|
||||
SetDeniedQos sets DeniedQos field to given value.
|
||||
|
||||
### HasDeniedQos
|
||||
|
||||
`func (o *V0037Partition) HasDeniedQos() bool`
|
||||
|
||||
HasDeniedQos returns a boolean if a field has been set.
|
||||
|
||||
### GetPreemptionGraceTime
|
||||
|
||||
`func (o *V0037Partition) GetPreemptionGraceTime() int64`
|
||||
|
||||
GetPreemptionGraceTime returns the PreemptionGraceTime field if non-nil, zero value otherwise.
|
||||
|
||||
### GetPreemptionGraceTimeOk
|
||||
|
||||
`func (o *V0037Partition) GetPreemptionGraceTimeOk() (*int64, bool)`
|
||||
|
||||
GetPreemptionGraceTimeOk returns a tuple with the PreemptionGraceTime field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetPreemptionGraceTime
|
||||
|
||||
`func (o *V0037Partition) SetPreemptionGraceTime(v int64)`
|
||||
|
||||
SetPreemptionGraceTime sets PreemptionGraceTime field to given value.
|
||||
|
||||
### HasPreemptionGraceTime
|
||||
|
||||
`func (o *V0037Partition) HasPreemptionGraceTime() bool`
|
||||
|
||||
HasPreemptionGraceTime returns a boolean if a field has been set.
|
||||
|
||||
### GetMaximumCpusPerNode
|
||||
|
||||
`func (o *V0037Partition) GetMaximumCpusPerNode() int32`
|
||||
|
||||
GetMaximumCpusPerNode returns the MaximumCpusPerNode field if non-nil, zero value otherwise.
|
||||
|
||||
### GetMaximumCpusPerNodeOk
|
||||
|
||||
`func (o *V0037Partition) GetMaximumCpusPerNodeOk() (*int32, bool)`
|
||||
|
||||
GetMaximumCpusPerNodeOk returns a tuple with the MaximumCpusPerNode field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetMaximumCpusPerNode
|
||||
|
||||
`func (o *V0037Partition) SetMaximumCpusPerNode(v int32)`
|
||||
|
||||
SetMaximumCpusPerNode sets MaximumCpusPerNode field to given value.
|
||||
|
||||
### HasMaximumCpusPerNode
|
||||
|
||||
`func (o *V0037Partition) HasMaximumCpusPerNode() bool`
|
||||
|
||||
HasMaximumCpusPerNode returns a boolean if a field has been set.
|
||||
|
||||
### GetMaximumMemoryPerNode
|
||||
|
||||
`func (o *V0037Partition) GetMaximumMemoryPerNode() int64`
|
||||
|
||||
GetMaximumMemoryPerNode returns the MaximumMemoryPerNode field if non-nil, zero value otherwise.
|
||||
|
||||
### GetMaximumMemoryPerNodeOk
|
||||
|
||||
`func (o *V0037Partition) GetMaximumMemoryPerNodeOk() (*int64, bool)`
|
||||
|
||||
GetMaximumMemoryPerNodeOk returns a tuple with the MaximumMemoryPerNode field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetMaximumMemoryPerNode
|
||||
|
||||
`func (o *V0037Partition) SetMaximumMemoryPerNode(v int64)`
|
||||
|
||||
SetMaximumMemoryPerNode sets MaximumMemoryPerNode field to given value.
|
||||
|
||||
### HasMaximumMemoryPerNode
|
||||
|
||||
`func (o *V0037Partition) HasMaximumMemoryPerNode() bool`
|
||||
|
||||
HasMaximumMemoryPerNode returns a boolean if a field has been set.
|
||||
|
||||
### GetMaximumNodesPerJob
|
||||
|
||||
`func (o *V0037Partition) GetMaximumNodesPerJob() int32`
|
||||
|
||||
GetMaximumNodesPerJob returns the MaximumNodesPerJob field if non-nil, zero value otherwise.
|
||||
|
||||
### GetMaximumNodesPerJobOk
|
||||
|
||||
`func (o *V0037Partition) GetMaximumNodesPerJobOk() (*int32, bool)`
|
||||
|
||||
GetMaximumNodesPerJobOk returns a tuple with the MaximumNodesPerJob field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetMaximumNodesPerJob
|
||||
|
||||
`func (o *V0037Partition) SetMaximumNodesPerJob(v int32)`
|
||||
|
||||
SetMaximumNodesPerJob sets MaximumNodesPerJob field to given value.
|
||||
|
||||
### HasMaximumNodesPerJob
|
||||
|
||||
`func (o *V0037Partition) HasMaximumNodesPerJob() bool`
|
||||
|
||||
HasMaximumNodesPerJob returns a boolean if a field has been set.
|
||||
|
||||
### GetMaxTimeLimit
|
||||
|
||||
`func (o *V0037Partition) GetMaxTimeLimit() int64`
|
||||
|
||||
GetMaxTimeLimit returns the MaxTimeLimit field if non-nil, zero value otherwise.
|
||||
|
||||
### GetMaxTimeLimitOk
|
||||
|
||||
`func (o *V0037Partition) GetMaxTimeLimitOk() (*int64, bool)`
|
||||
|
||||
GetMaxTimeLimitOk returns a tuple with the MaxTimeLimit field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetMaxTimeLimit
|
||||
|
||||
`func (o *V0037Partition) SetMaxTimeLimit(v int64)`
|
||||
|
||||
SetMaxTimeLimit sets MaxTimeLimit field to given value.
|
||||
|
||||
### HasMaxTimeLimit
|
||||
|
||||
`func (o *V0037Partition) HasMaxTimeLimit() bool`
|
||||
|
||||
HasMaxTimeLimit returns a boolean if a field has been set.
|
||||
|
||||
### GetMinNodesPerJob
|
||||
|
||||
`func (o *V0037Partition) GetMinNodesPerJob() int32`
|
||||
|
||||
GetMinNodesPerJob returns the MinNodesPerJob field if non-nil, zero value otherwise.
|
||||
|
||||
### GetMinNodesPerJobOk
|
||||
|
||||
`func (o *V0037Partition) GetMinNodesPerJobOk() (*int32, bool)`
|
||||
|
||||
GetMinNodesPerJobOk returns a tuple with the MinNodesPerJob field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetMinNodesPerJob
|
||||
|
||||
`func (o *V0037Partition) SetMinNodesPerJob(v int32)`
|
||||
|
||||
SetMinNodesPerJob sets MinNodesPerJob field to given value.
|
||||
|
||||
### HasMinNodesPerJob
|
||||
|
||||
`func (o *V0037Partition) HasMinNodesPerJob() bool`
|
||||
|
||||
HasMinNodesPerJob returns a boolean if a field has been set.
|
||||
|
||||
### GetName
|
||||
|
||||
`func (o *V0037Partition) GetName() string`
|
||||
|
||||
GetName returns the Name field if non-nil, zero value otherwise.
|
||||
|
||||
### GetNameOk
|
||||
|
||||
`func (o *V0037Partition) GetNameOk() (*string, bool)`
|
||||
|
||||
GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetName
|
||||
|
||||
`func (o *V0037Partition) SetName(v string)`
|
||||
|
||||
SetName sets Name field to given value.
|
||||
|
||||
### HasName
|
||||
|
||||
`func (o *V0037Partition) HasName() bool`
|
||||
|
||||
HasName returns a boolean if a field has been set.
|
||||
|
||||
### GetNodes
|
||||
|
||||
`func (o *V0037Partition) GetNodes() string`
|
||||
|
||||
GetNodes returns the Nodes field if non-nil, zero value otherwise.
|
||||
|
||||
### GetNodesOk
|
||||
|
||||
`func (o *V0037Partition) GetNodesOk() (*string, bool)`
|
||||
|
||||
GetNodesOk returns a tuple with the Nodes field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetNodes
|
||||
|
||||
`func (o *V0037Partition) SetNodes(v string)`
|
||||
|
||||
SetNodes sets Nodes field to given value.
|
||||
|
||||
### HasNodes
|
||||
|
||||
`func (o *V0037Partition) HasNodes() bool`
|
||||
|
||||
HasNodes returns a boolean if a field has been set.
|
||||
|
||||
### GetOverTimeLimit
|
||||
|
||||
`func (o *V0037Partition) GetOverTimeLimit() int32`
|
||||
|
||||
GetOverTimeLimit returns the OverTimeLimit field if non-nil, zero value otherwise.
|
||||
|
||||
### GetOverTimeLimitOk
|
||||
|
||||
`func (o *V0037Partition) GetOverTimeLimitOk() (*int32, bool)`
|
||||
|
||||
GetOverTimeLimitOk returns a tuple with the OverTimeLimit field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetOverTimeLimit
|
||||
|
||||
`func (o *V0037Partition) SetOverTimeLimit(v int32)`
|
||||
|
||||
SetOverTimeLimit sets OverTimeLimit field to given value.
|
||||
|
||||
### HasOverTimeLimit
|
||||
|
||||
`func (o *V0037Partition) HasOverTimeLimit() bool`
|
||||
|
||||
HasOverTimeLimit returns a boolean if a field has been set.
|
||||
|
||||
### GetPriorityJobFactor
|
||||
|
||||
`func (o *V0037Partition) GetPriorityJobFactor() int32`
|
||||
|
||||
GetPriorityJobFactor returns the PriorityJobFactor field if non-nil, zero value otherwise.
|
||||
|
||||
### GetPriorityJobFactorOk
|
||||
|
||||
`func (o *V0037Partition) GetPriorityJobFactorOk() (*int32, bool)`
|
||||
|
||||
GetPriorityJobFactorOk returns a tuple with the PriorityJobFactor field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetPriorityJobFactor
|
||||
|
||||
`func (o *V0037Partition) SetPriorityJobFactor(v int32)`
|
||||
|
||||
SetPriorityJobFactor sets PriorityJobFactor field to given value.
|
||||
|
||||
### HasPriorityJobFactor
|
||||
|
||||
`func (o *V0037Partition) HasPriorityJobFactor() bool`
|
||||
|
||||
HasPriorityJobFactor returns a boolean if a field has been set.
|
||||
|
||||
### GetPriorityTier
|
||||
|
||||
`func (o *V0037Partition) GetPriorityTier() int32`
|
||||
|
||||
GetPriorityTier returns the PriorityTier field if non-nil, zero value otherwise.
|
||||
|
||||
### GetPriorityTierOk
|
||||
|
||||
`func (o *V0037Partition) GetPriorityTierOk() (*int32, bool)`
|
||||
|
||||
GetPriorityTierOk returns a tuple with the PriorityTier field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetPriorityTier
|
||||
|
||||
`func (o *V0037Partition) SetPriorityTier(v int32)`
|
||||
|
||||
SetPriorityTier sets PriorityTier field to given value.
|
||||
|
||||
### HasPriorityTier
|
||||
|
||||
`func (o *V0037Partition) HasPriorityTier() bool`
|
||||
|
||||
HasPriorityTier returns a boolean if a field has been set.
|
||||
|
||||
### GetQos
|
||||
|
||||
`func (o *V0037Partition) GetQos() string`
|
||||
|
||||
GetQos returns the Qos field if non-nil, zero value otherwise.
|
||||
|
||||
### GetQosOk
|
||||
|
||||
`func (o *V0037Partition) GetQosOk() (*string, bool)`
|
||||
|
||||
GetQosOk returns a tuple with the Qos field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetQos
|
||||
|
||||
`func (o *V0037Partition) SetQos(v string)`
|
||||
|
||||
SetQos sets Qos field to given value.
|
||||
|
||||
### HasQos
|
||||
|
||||
`func (o *V0037Partition) HasQos() bool`
|
||||
|
||||
HasQos returns a boolean if a field has been set.
|
||||
|
||||
### GetState
|
||||
|
||||
`func (o *V0037Partition) GetState() string`
|
||||
|
||||
GetState returns the State field if non-nil, zero value otherwise.
|
||||
|
||||
### GetStateOk
|
||||
|
||||
`func (o *V0037Partition) GetStateOk() (*string, bool)`
|
||||
|
||||
GetStateOk returns a tuple with the State field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetState
|
||||
|
||||
`func (o *V0037Partition) SetState(v string)`
|
||||
|
||||
SetState sets State field to given value.
|
||||
|
||||
### HasState
|
||||
|
||||
`func (o *V0037Partition) HasState() bool`
|
||||
|
||||
HasState returns a boolean if a field has been set.
|
||||
|
||||
### GetTotalCpus
|
||||
|
||||
`func (o *V0037Partition) GetTotalCpus() int32`
|
||||
|
||||
GetTotalCpus returns the TotalCpus field if non-nil, zero value otherwise.
|
||||
|
||||
### GetTotalCpusOk
|
||||
|
||||
`func (o *V0037Partition) GetTotalCpusOk() (*int32, bool)`
|
||||
|
||||
GetTotalCpusOk returns a tuple with the TotalCpus field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetTotalCpus
|
||||
|
||||
`func (o *V0037Partition) SetTotalCpus(v int32)`
|
||||
|
||||
SetTotalCpus sets TotalCpus field to given value.
|
||||
|
||||
### HasTotalCpus
|
||||
|
||||
`func (o *V0037Partition) HasTotalCpus() bool`
|
||||
|
||||
HasTotalCpus returns a boolean if a field has been set.
|
||||
|
||||
### GetTotalNodes
|
||||
|
||||
`func (o *V0037Partition) GetTotalNodes() int32`
|
||||
|
||||
GetTotalNodes returns the TotalNodes field if non-nil, zero value otherwise.
|
||||
|
||||
### GetTotalNodesOk
|
||||
|
||||
`func (o *V0037Partition) GetTotalNodesOk() (*int32, bool)`
|
||||
|
||||
GetTotalNodesOk returns a tuple with the TotalNodes field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetTotalNodes
|
||||
|
||||
`func (o *V0037Partition) SetTotalNodes(v int32)`
|
||||
|
||||
SetTotalNodes sets TotalNodes field to given value.
|
||||
|
||||
### HasTotalNodes
|
||||
|
||||
`func (o *V0037Partition) HasTotalNodes() bool`
|
||||
|
||||
HasTotalNodes returns a boolean if a field has been set.
|
||||
|
||||
### GetTres
|
||||
|
||||
`func (o *V0037Partition) GetTres() string`
|
||||
|
||||
GetTres returns the Tres field if non-nil, zero value otherwise.
|
||||
|
||||
### GetTresOk
|
||||
|
||||
`func (o *V0037Partition) GetTresOk() (*string, bool)`
|
||||
|
||||
GetTresOk returns a tuple with the Tres field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetTres
|
||||
|
||||
`func (o *V0037Partition) SetTres(v string)`
|
||||
|
||||
SetTres sets Tres field to given value.
|
||||
|
||||
### HasTres
|
||||
|
||||
`func (o *V0037Partition) HasTres() bool`
|
||||
|
||||
HasTres returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
# V0037PartitionsResponse
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Errors** | Pointer to [**[]V0037Error**](V0037Error.md) | slurm errors | [optional]
|
||||
**Partitions** | Pointer to [**[]V0037Partition**](V0037Partition.md) | partition info | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037PartitionsResponse
|
||||
|
||||
`func NewV0037PartitionsResponse() *V0037PartitionsResponse`
|
||||
|
||||
NewV0037PartitionsResponse instantiates a new V0037PartitionsResponse object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037PartitionsResponseWithDefaults
|
||||
|
||||
`func NewV0037PartitionsResponseWithDefaults() *V0037PartitionsResponse`
|
||||
|
||||
NewV0037PartitionsResponseWithDefaults instantiates a new V0037PartitionsResponse object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetErrors
|
||||
|
||||
`func (o *V0037PartitionsResponse) GetErrors() []V0037Error`
|
||||
|
||||
GetErrors returns the Errors field if non-nil, zero value otherwise.
|
||||
|
||||
### GetErrorsOk
|
||||
|
||||
`func (o *V0037PartitionsResponse) GetErrorsOk() (*[]V0037Error, bool)`
|
||||
|
||||
GetErrorsOk returns a tuple with the Errors field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetErrors
|
||||
|
||||
`func (o *V0037PartitionsResponse) SetErrors(v []V0037Error)`
|
||||
|
||||
SetErrors sets Errors field to given value.
|
||||
|
||||
### HasErrors
|
||||
|
||||
`func (o *V0037PartitionsResponse) HasErrors() bool`
|
||||
|
||||
HasErrors returns a boolean if a field has been set.
|
||||
|
||||
### GetPartitions
|
||||
|
||||
`func (o *V0037PartitionsResponse) GetPartitions() []V0037Partition`
|
||||
|
||||
GetPartitions returns the Partitions field if non-nil, zero value otherwise.
|
||||
|
||||
### GetPartitionsOk
|
||||
|
||||
`func (o *V0037PartitionsResponse) GetPartitionsOk() (*[]V0037Partition, bool)`
|
||||
|
||||
GetPartitionsOk returns a tuple with the Partitions field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetPartitions
|
||||
|
||||
`func (o *V0037PartitionsResponse) SetPartitions(v []V0037Partition)`
|
||||
|
||||
SetPartitions sets Partitions field to given value.
|
||||
|
||||
### HasPartitions
|
||||
|
||||
`func (o *V0037PartitionsResponse) HasPartitions() bool`
|
||||
|
||||
HasPartitions returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
# V0037Ping
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Hostname** | Pointer to **string** | slurm controller hostname | [optional]
|
||||
**Ping** | Pointer to **string** | slurm controller host up | [optional]
|
||||
**Mode** | Pointer to **string** | slurm controller mode | [optional]
|
||||
**Status** | Pointer to **int32** | slurm controller status | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037Ping
|
||||
|
||||
`func NewV0037Ping() *V0037Ping`
|
||||
|
||||
NewV0037Ping instantiates a new V0037Ping object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037PingWithDefaults
|
||||
|
||||
`func NewV0037PingWithDefaults() *V0037Ping`
|
||||
|
||||
NewV0037PingWithDefaults instantiates a new V0037Ping object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetHostname
|
||||
|
||||
`func (o *V0037Ping) GetHostname() string`
|
||||
|
||||
GetHostname returns the Hostname field if non-nil, zero value otherwise.
|
||||
|
||||
### GetHostnameOk
|
||||
|
||||
`func (o *V0037Ping) GetHostnameOk() (*string, bool)`
|
||||
|
||||
GetHostnameOk returns a tuple with the Hostname field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetHostname
|
||||
|
||||
`func (o *V0037Ping) SetHostname(v string)`
|
||||
|
||||
SetHostname sets Hostname field to given value.
|
||||
|
||||
### HasHostname
|
||||
|
||||
`func (o *V0037Ping) HasHostname() bool`
|
||||
|
||||
HasHostname returns a boolean if a field has been set.
|
||||
|
||||
### GetPing
|
||||
|
||||
`func (o *V0037Ping) GetPing() string`
|
||||
|
||||
GetPing returns the Ping field if non-nil, zero value otherwise.
|
||||
|
||||
### GetPingOk
|
||||
|
||||
`func (o *V0037Ping) GetPingOk() (*string, bool)`
|
||||
|
||||
GetPingOk returns a tuple with the Ping field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetPing
|
||||
|
||||
`func (o *V0037Ping) SetPing(v string)`
|
||||
|
||||
SetPing sets Ping field to given value.
|
||||
|
||||
### HasPing
|
||||
|
||||
`func (o *V0037Ping) HasPing() bool`
|
||||
|
||||
HasPing returns a boolean if a field has been set.
|
||||
|
||||
### GetMode
|
||||
|
||||
`func (o *V0037Ping) GetMode() string`
|
||||
|
||||
GetMode returns the Mode field if non-nil, zero value otherwise.
|
||||
|
||||
### GetModeOk
|
||||
|
||||
`func (o *V0037Ping) GetModeOk() (*string, bool)`
|
||||
|
||||
GetModeOk returns a tuple with the Mode field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetMode
|
||||
|
||||
`func (o *V0037Ping) SetMode(v string)`
|
||||
|
||||
SetMode sets Mode field to given value.
|
||||
|
||||
### HasMode
|
||||
|
||||
`func (o *V0037Ping) HasMode() bool`
|
||||
|
||||
HasMode returns a boolean if a field has been set.
|
||||
|
||||
### GetStatus
|
||||
|
||||
`func (o *V0037Ping) GetStatus() int32`
|
||||
|
||||
GetStatus returns the Status field if non-nil, zero value otherwise.
|
||||
|
||||
### GetStatusOk
|
||||
|
||||
`func (o *V0037Ping) GetStatusOk() (*int32, bool)`
|
||||
|
||||
GetStatusOk returns a tuple with the Status field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetStatus
|
||||
|
||||
`func (o *V0037Ping) SetStatus(v int32)`
|
||||
|
||||
SetStatus sets Status field to given value.
|
||||
|
||||
### HasStatus
|
||||
|
||||
`func (o *V0037Ping) HasStatus() bool`
|
||||
|
||||
HasStatus returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
# V0037Pings
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Errors** | Pointer to [**[]V0037Error**](V0037Error.md) | slurm errors | [optional]
|
||||
**Pings** | Pointer to [**[]V0037Ping**](V0037Ping.md) | slurm controller pings | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037Pings
|
||||
|
||||
`func NewV0037Pings() *V0037Pings`
|
||||
|
||||
NewV0037Pings instantiates a new V0037Pings object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037PingsWithDefaults
|
||||
|
||||
`func NewV0037PingsWithDefaults() *V0037Pings`
|
||||
|
||||
NewV0037PingsWithDefaults instantiates a new V0037Pings object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetErrors
|
||||
|
||||
`func (o *V0037Pings) GetErrors() []V0037Error`
|
||||
|
||||
GetErrors returns the Errors field if non-nil, zero value otherwise.
|
||||
|
||||
### GetErrorsOk
|
||||
|
||||
`func (o *V0037Pings) GetErrorsOk() (*[]V0037Error, bool)`
|
||||
|
||||
GetErrorsOk returns a tuple with the Errors field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetErrors
|
||||
|
||||
`func (o *V0037Pings) SetErrors(v []V0037Error)`
|
||||
|
||||
SetErrors sets Errors field to given value.
|
||||
|
||||
### HasErrors
|
||||
|
||||
`func (o *V0037Pings) HasErrors() bool`
|
||||
|
||||
HasErrors returns a boolean if a field has been set.
|
||||
|
||||
### GetPings
|
||||
|
||||
`func (o *V0037Pings) GetPings() []V0037Ping`
|
||||
|
||||
GetPings returns the Pings field if non-nil, zero value otherwise.
|
||||
|
||||
### GetPingsOk
|
||||
|
||||
`func (o *V0037Pings) GetPingsOk() (*[]V0037Ping, bool)`
|
||||
|
||||
GetPingsOk returns a tuple with the Pings field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetPings
|
||||
|
||||
`func (o *V0037Pings) SetPings(v []V0037Ping)`
|
||||
|
||||
SetPings sets Pings field to given value.
|
||||
|
||||
### HasPings
|
||||
|
||||
`func (o *V0037Pings) HasPings() bool`
|
||||
|
||||
HasPings returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,524 +0,0 @@
|
||||
# V0037Reservation
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Accounts** | Pointer to **string** | Allowed accounts | [optional]
|
||||
**BurstBuffer** | Pointer to **string** | Reserved burst buffer | [optional]
|
||||
**CoreCount** | Pointer to **int32** | Number of reserved cores | [optional]
|
||||
**CoreSpecCnt** | Pointer to **int32** | Number of reserved specialized cores | [optional]
|
||||
**EndTime** | Pointer to **int32** | End time of the reservation | [optional]
|
||||
**Features** | Pointer to **string** | List of features | [optional]
|
||||
**Flags** | Pointer to **[]string** | Reservation options | [optional]
|
||||
**Groups** | Pointer to **string** | List of groups permitted to use the reserved nodes | [optional]
|
||||
**Licenses** | Pointer to **string** | List of licenses | [optional]
|
||||
**MaxStartDelay** | Pointer to **int32** | Maximum delay in which jobs outside of the reservation will be permitted to overlap once any jobs are queued for the reservation | [optional]
|
||||
**Name** | Pointer to **string** | Reservationn name | [optional]
|
||||
**NodeCount** | Pointer to **int32** | Count of nodes reserved | [optional]
|
||||
**NodeList** | Pointer to **string** | List of reserved nodes | [optional]
|
||||
**Partition** | Pointer to **string** | Partition | [optional]
|
||||
**PurgeCompleted** | Pointer to [**V0037ReservationPurgeCompleted**](V0037ReservationPurgeCompleted.md) | | [optional]
|
||||
**StartTime** | Pointer to **int32** | Start time of reservation | [optional]
|
||||
**Watts** | Pointer to **int32** | amount of power to reserve in watts | [optional]
|
||||
**Tres** | Pointer to **string** | List of TRES | [optional]
|
||||
**Users** | Pointer to **string** | List of users | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037Reservation
|
||||
|
||||
`func NewV0037Reservation() *V0037Reservation`
|
||||
|
||||
NewV0037Reservation instantiates a new V0037Reservation object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037ReservationWithDefaults
|
||||
|
||||
`func NewV0037ReservationWithDefaults() *V0037Reservation`
|
||||
|
||||
NewV0037ReservationWithDefaults instantiates a new V0037Reservation object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetAccounts
|
||||
|
||||
`func (o *V0037Reservation) GetAccounts() string`
|
||||
|
||||
GetAccounts returns the Accounts field if non-nil, zero value otherwise.
|
||||
|
||||
### GetAccountsOk
|
||||
|
||||
`func (o *V0037Reservation) GetAccountsOk() (*string, bool)`
|
||||
|
||||
GetAccountsOk returns a tuple with the Accounts field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetAccounts
|
||||
|
||||
`func (o *V0037Reservation) SetAccounts(v string)`
|
||||
|
||||
SetAccounts sets Accounts field to given value.
|
||||
|
||||
### HasAccounts
|
||||
|
||||
`func (o *V0037Reservation) HasAccounts() bool`
|
||||
|
||||
HasAccounts returns a boolean if a field has been set.
|
||||
|
||||
### GetBurstBuffer
|
||||
|
||||
`func (o *V0037Reservation) GetBurstBuffer() string`
|
||||
|
||||
GetBurstBuffer returns the BurstBuffer field if non-nil, zero value otherwise.
|
||||
|
||||
### GetBurstBufferOk
|
||||
|
||||
`func (o *V0037Reservation) GetBurstBufferOk() (*string, bool)`
|
||||
|
||||
GetBurstBufferOk returns a tuple with the BurstBuffer field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetBurstBuffer
|
||||
|
||||
`func (o *V0037Reservation) SetBurstBuffer(v string)`
|
||||
|
||||
SetBurstBuffer sets BurstBuffer field to given value.
|
||||
|
||||
### HasBurstBuffer
|
||||
|
||||
`func (o *V0037Reservation) HasBurstBuffer() bool`
|
||||
|
||||
HasBurstBuffer returns a boolean if a field has been set.
|
||||
|
||||
### GetCoreCount
|
||||
|
||||
`func (o *V0037Reservation) GetCoreCount() int32`
|
||||
|
||||
GetCoreCount returns the CoreCount field if non-nil, zero value otherwise.
|
||||
|
||||
### GetCoreCountOk
|
||||
|
||||
`func (o *V0037Reservation) GetCoreCountOk() (*int32, bool)`
|
||||
|
||||
GetCoreCountOk returns a tuple with the CoreCount field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetCoreCount
|
||||
|
||||
`func (o *V0037Reservation) SetCoreCount(v int32)`
|
||||
|
||||
SetCoreCount sets CoreCount field to given value.
|
||||
|
||||
### HasCoreCount
|
||||
|
||||
`func (o *V0037Reservation) HasCoreCount() bool`
|
||||
|
||||
HasCoreCount returns a boolean if a field has been set.
|
||||
|
||||
### GetCoreSpecCnt
|
||||
|
||||
`func (o *V0037Reservation) GetCoreSpecCnt() int32`
|
||||
|
||||
GetCoreSpecCnt returns the CoreSpecCnt field if non-nil, zero value otherwise.
|
||||
|
||||
### GetCoreSpecCntOk
|
||||
|
||||
`func (o *V0037Reservation) GetCoreSpecCntOk() (*int32, bool)`
|
||||
|
||||
GetCoreSpecCntOk returns a tuple with the CoreSpecCnt field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetCoreSpecCnt
|
||||
|
||||
`func (o *V0037Reservation) SetCoreSpecCnt(v int32)`
|
||||
|
||||
SetCoreSpecCnt sets CoreSpecCnt field to given value.
|
||||
|
||||
### HasCoreSpecCnt
|
||||
|
||||
`func (o *V0037Reservation) HasCoreSpecCnt() bool`
|
||||
|
||||
HasCoreSpecCnt returns a boolean if a field has been set.
|
||||
|
||||
### GetEndTime
|
||||
|
||||
`func (o *V0037Reservation) GetEndTime() int32`
|
||||
|
||||
GetEndTime returns the EndTime field if non-nil, zero value otherwise.
|
||||
|
||||
### GetEndTimeOk
|
||||
|
||||
`func (o *V0037Reservation) GetEndTimeOk() (*int32, bool)`
|
||||
|
||||
GetEndTimeOk returns a tuple with the EndTime field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetEndTime
|
||||
|
||||
`func (o *V0037Reservation) SetEndTime(v int32)`
|
||||
|
||||
SetEndTime sets EndTime field to given value.
|
||||
|
||||
### HasEndTime
|
||||
|
||||
`func (o *V0037Reservation) HasEndTime() bool`
|
||||
|
||||
HasEndTime returns a boolean if a field has been set.
|
||||
|
||||
### GetFeatures
|
||||
|
||||
`func (o *V0037Reservation) GetFeatures() string`
|
||||
|
||||
GetFeatures returns the Features field if non-nil, zero value otherwise.
|
||||
|
||||
### GetFeaturesOk
|
||||
|
||||
`func (o *V0037Reservation) GetFeaturesOk() (*string, bool)`
|
||||
|
||||
GetFeaturesOk returns a tuple with the Features field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetFeatures
|
||||
|
||||
`func (o *V0037Reservation) SetFeatures(v string)`
|
||||
|
||||
SetFeatures sets Features field to given value.
|
||||
|
||||
### HasFeatures
|
||||
|
||||
`func (o *V0037Reservation) HasFeatures() bool`
|
||||
|
||||
HasFeatures returns a boolean if a field has been set.
|
||||
|
||||
### GetFlags
|
||||
|
||||
`func (o *V0037Reservation) GetFlags() []string`
|
||||
|
||||
GetFlags returns the Flags field if non-nil, zero value otherwise.
|
||||
|
||||
### GetFlagsOk
|
||||
|
||||
`func (o *V0037Reservation) GetFlagsOk() (*[]string, bool)`
|
||||
|
||||
GetFlagsOk returns a tuple with the Flags field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetFlags
|
||||
|
||||
`func (o *V0037Reservation) SetFlags(v []string)`
|
||||
|
||||
SetFlags sets Flags field to given value.
|
||||
|
||||
### HasFlags
|
||||
|
||||
`func (o *V0037Reservation) HasFlags() bool`
|
||||
|
||||
HasFlags returns a boolean if a field has been set.
|
||||
|
||||
### GetGroups
|
||||
|
||||
`func (o *V0037Reservation) GetGroups() string`
|
||||
|
||||
GetGroups returns the Groups field if non-nil, zero value otherwise.
|
||||
|
||||
### GetGroupsOk
|
||||
|
||||
`func (o *V0037Reservation) GetGroupsOk() (*string, bool)`
|
||||
|
||||
GetGroupsOk returns a tuple with the Groups field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetGroups
|
||||
|
||||
`func (o *V0037Reservation) SetGroups(v string)`
|
||||
|
||||
SetGroups sets Groups field to given value.
|
||||
|
||||
### HasGroups
|
||||
|
||||
`func (o *V0037Reservation) HasGroups() bool`
|
||||
|
||||
HasGroups returns a boolean if a field has been set.
|
||||
|
||||
### GetLicenses
|
||||
|
||||
`func (o *V0037Reservation) GetLicenses() string`
|
||||
|
||||
GetLicenses returns the Licenses field if non-nil, zero value otherwise.
|
||||
|
||||
### GetLicensesOk
|
||||
|
||||
`func (o *V0037Reservation) GetLicensesOk() (*string, bool)`
|
||||
|
||||
GetLicensesOk returns a tuple with the Licenses field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetLicenses
|
||||
|
||||
`func (o *V0037Reservation) SetLicenses(v string)`
|
||||
|
||||
SetLicenses sets Licenses field to given value.
|
||||
|
||||
### HasLicenses
|
||||
|
||||
`func (o *V0037Reservation) HasLicenses() bool`
|
||||
|
||||
HasLicenses returns a boolean if a field has been set.
|
||||
|
||||
### GetMaxStartDelay
|
||||
|
||||
`func (o *V0037Reservation) GetMaxStartDelay() int32`
|
||||
|
||||
GetMaxStartDelay returns the MaxStartDelay field if non-nil, zero value otherwise.
|
||||
|
||||
### GetMaxStartDelayOk
|
||||
|
||||
`func (o *V0037Reservation) GetMaxStartDelayOk() (*int32, bool)`
|
||||
|
||||
GetMaxStartDelayOk returns a tuple with the MaxStartDelay field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetMaxStartDelay
|
||||
|
||||
`func (o *V0037Reservation) SetMaxStartDelay(v int32)`
|
||||
|
||||
SetMaxStartDelay sets MaxStartDelay field to given value.
|
||||
|
||||
### HasMaxStartDelay
|
||||
|
||||
`func (o *V0037Reservation) HasMaxStartDelay() bool`
|
||||
|
||||
HasMaxStartDelay returns a boolean if a field has been set.
|
||||
|
||||
### GetName
|
||||
|
||||
`func (o *V0037Reservation) GetName() string`
|
||||
|
||||
GetName returns the Name field if non-nil, zero value otherwise.
|
||||
|
||||
### GetNameOk
|
||||
|
||||
`func (o *V0037Reservation) GetNameOk() (*string, bool)`
|
||||
|
||||
GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetName
|
||||
|
||||
`func (o *V0037Reservation) SetName(v string)`
|
||||
|
||||
SetName sets Name field to given value.
|
||||
|
||||
### HasName
|
||||
|
||||
`func (o *V0037Reservation) HasName() bool`
|
||||
|
||||
HasName returns a boolean if a field has been set.
|
||||
|
||||
### GetNodeCount
|
||||
|
||||
`func (o *V0037Reservation) GetNodeCount() int32`
|
||||
|
||||
GetNodeCount returns the NodeCount field if non-nil, zero value otherwise.
|
||||
|
||||
### GetNodeCountOk
|
||||
|
||||
`func (o *V0037Reservation) GetNodeCountOk() (*int32, bool)`
|
||||
|
||||
GetNodeCountOk returns a tuple with the NodeCount field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetNodeCount
|
||||
|
||||
`func (o *V0037Reservation) SetNodeCount(v int32)`
|
||||
|
||||
SetNodeCount sets NodeCount field to given value.
|
||||
|
||||
### HasNodeCount
|
||||
|
||||
`func (o *V0037Reservation) HasNodeCount() bool`
|
||||
|
||||
HasNodeCount returns a boolean if a field has been set.
|
||||
|
||||
### GetNodeList
|
||||
|
||||
`func (o *V0037Reservation) GetNodeList() string`
|
||||
|
||||
GetNodeList returns the NodeList field if non-nil, zero value otherwise.
|
||||
|
||||
### GetNodeListOk
|
||||
|
||||
`func (o *V0037Reservation) GetNodeListOk() (*string, bool)`
|
||||
|
||||
GetNodeListOk returns a tuple with the NodeList field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetNodeList
|
||||
|
||||
`func (o *V0037Reservation) SetNodeList(v string)`
|
||||
|
||||
SetNodeList sets NodeList field to given value.
|
||||
|
||||
### HasNodeList
|
||||
|
||||
`func (o *V0037Reservation) HasNodeList() bool`
|
||||
|
||||
HasNodeList returns a boolean if a field has been set.
|
||||
|
||||
### GetPartition
|
||||
|
||||
`func (o *V0037Reservation) GetPartition() string`
|
||||
|
||||
GetPartition returns the Partition field if non-nil, zero value otherwise.
|
||||
|
||||
### GetPartitionOk
|
||||
|
||||
`func (o *V0037Reservation) GetPartitionOk() (*string, bool)`
|
||||
|
||||
GetPartitionOk returns a tuple with the Partition field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetPartition
|
||||
|
||||
`func (o *V0037Reservation) SetPartition(v string)`
|
||||
|
||||
SetPartition sets Partition field to given value.
|
||||
|
||||
### HasPartition
|
||||
|
||||
`func (o *V0037Reservation) HasPartition() bool`
|
||||
|
||||
HasPartition returns a boolean if a field has been set.
|
||||
|
||||
### GetPurgeCompleted
|
||||
|
||||
`func (o *V0037Reservation) GetPurgeCompleted() V0037ReservationPurgeCompleted`
|
||||
|
||||
GetPurgeCompleted returns the PurgeCompleted field if non-nil, zero value otherwise.
|
||||
|
||||
### GetPurgeCompletedOk
|
||||
|
||||
`func (o *V0037Reservation) GetPurgeCompletedOk() (*V0037ReservationPurgeCompleted, bool)`
|
||||
|
||||
GetPurgeCompletedOk returns a tuple with the PurgeCompleted field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetPurgeCompleted
|
||||
|
||||
`func (o *V0037Reservation) SetPurgeCompleted(v V0037ReservationPurgeCompleted)`
|
||||
|
||||
SetPurgeCompleted sets PurgeCompleted field to given value.
|
||||
|
||||
### HasPurgeCompleted
|
||||
|
||||
`func (o *V0037Reservation) HasPurgeCompleted() bool`
|
||||
|
||||
HasPurgeCompleted returns a boolean if a field has been set.
|
||||
|
||||
### GetStartTime
|
||||
|
||||
`func (o *V0037Reservation) GetStartTime() int32`
|
||||
|
||||
GetStartTime returns the StartTime field if non-nil, zero value otherwise.
|
||||
|
||||
### GetStartTimeOk
|
||||
|
||||
`func (o *V0037Reservation) GetStartTimeOk() (*int32, bool)`
|
||||
|
||||
GetStartTimeOk returns a tuple with the StartTime field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetStartTime
|
||||
|
||||
`func (o *V0037Reservation) SetStartTime(v int32)`
|
||||
|
||||
SetStartTime sets StartTime field to given value.
|
||||
|
||||
### HasStartTime
|
||||
|
||||
`func (o *V0037Reservation) HasStartTime() bool`
|
||||
|
||||
HasStartTime returns a boolean if a field has been set.
|
||||
|
||||
### GetWatts
|
||||
|
||||
`func (o *V0037Reservation) GetWatts() int32`
|
||||
|
||||
GetWatts returns the Watts field if non-nil, zero value otherwise.
|
||||
|
||||
### GetWattsOk
|
||||
|
||||
`func (o *V0037Reservation) GetWattsOk() (*int32, bool)`
|
||||
|
||||
GetWattsOk returns a tuple with the Watts field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetWatts
|
||||
|
||||
`func (o *V0037Reservation) SetWatts(v int32)`
|
||||
|
||||
SetWatts sets Watts field to given value.
|
||||
|
||||
### HasWatts
|
||||
|
||||
`func (o *V0037Reservation) HasWatts() bool`
|
||||
|
||||
HasWatts returns a boolean if a field has been set.
|
||||
|
||||
### GetTres
|
||||
|
||||
`func (o *V0037Reservation) GetTres() string`
|
||||
|
||||
GetTres returns the Tres field if non-nil, zero value otherwise.
|
||||
|
||||
### GetTresOk
|
||||
|
||||
`func (o *V0037Reservation) GetTresOk() (*string, bool)`
|
||||
|
||||
GetTresOk returns a tuple with the Tres field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetTres
|
||||
|
||||
`func (o *V0037Reservation) SetTres(v string)`
|
||||
|
||||
SetTres sets Tres field to given value.
|
||||
|
||||
### HasTres
|
||||
|
||||
`func (o *V0037Reservation) HasTres() bool`
|
||||
|
||||
HasTres returns a boolean if a field has been set.
|
||||
|
||||
### GetUsers
|
||||
|
||||
`func (o *V0037Reservation) GetUsers() string`
|
||||
|
||||
GetUsers returns the Users field if non-nil, zero value otherwise.
|
||||
|
||||
### GetUsersOk
|
||||
|
||||
`func (o *V0037Reservation) GetUsersOk() (*string, bool)`
|
||||
|
||||
GetUsersOk returns a tuple with the Users field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetUsers
|
||||
|
||||
`func (o *V0037Reservation) SetUsers(v string)`
|
||||
|
||||
SetUsers sets Users field to given value.
|
||||
|
||||
### HasUsers
|
||||
|
||||
`func (o *V0037Reservation) HasUsers() bool`
|
||||
|
||||
HasUsers returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
# V0037ReservationPurgeCompleted
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Time** | Pointer to **int32** | amount of seconds this reservation will sit idle until it is revoked | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037ReservationPurgeCompleted
|
||||
|
||||
`func NewV0037ReservationPurgeCompleted() *V0037ReservationPurgeCompleted`
|
||||
|
||||
NewV0037ReservationPurgeCompleted instantiates a new V0037ReservationPurgeCompleted object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037ReservationPurgeCompletedWithDefaults
|
||||
|
||||
`func NewV0037ReservationPurgeCompletedWithDefaults() *V0037ReservationPurgeCompleted`
|
||||
|
||||
NewV0037ReservationPurgeCompletedWithDefaults instantiates a new V0037ReservationPurgeCompleted object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetTime
|
||||
|
||||
`func (o *V0037ReservationPurgeCompleted) GetTime() int32`
|
||||
|
||||
GetTime returns the Time field if non-nil, zero value otherwise.
|
||||
|
||||
### GetTimeOk
|
||||
|
||||
`func (o *V0037ReservationPurgeCompleted) GetTimeOk() (*int32, bool)`
|
||||
|
||||
GetTimeOk returns a tuple with the Time field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetTime
|
||||
|
||||
`func (o *V0037ReservationPurgeCompleted) SetTime(v int32)`
|
||||
|
||||
SetTime sets Time field to given value.
|
||||
|
||||
### HasTime
|
||||
|
||||
`func (o *V0037ReservationPurgeCompleted) HasTime() bool`
|
||||
|
||||
HasTime returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
# V0037ReservationsResponse
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Errors** | Pointer to [**[]V0037Error**](V0037Error.md) | slurm errors | [optional]
|
||||
**Reservations** | Pointer to [**[]V0037Reservation**](V0037Reservation.md) | reservation info | [optional]
|
||||
|
||||
## Methods
|
||||
|
||||
### NewV0037ReservationsResponse
|
||||
|
||||
`func NewV0037ReservationsResponse() *V0037ReservationsResponse`
|
||||
|
||||
NewV0037ReservationsResponse instantiates a new V0037ReservationsResponse object
|
||||
This constructor will assign default values to properties that have it defined,
|
||||
and makes sure properties required by API are set, but the set of arguments
|
||||
will change when the set of required properties is changed
|
||||
|
||||
### NewV0037ReservationsResponseWithDefaults
|
||||
|
||||
`func NewV0037ReservationsResponseWithDefaults() *V0037ReservationsResponse`
|
||||
|
||||
NewV0037ReservationsResponseWithDefaults instantiates a new V0037ReservationsResponse object
|
||||
This constructor will only assign default values to properties that have it defined,
|
||||
but it doesn't guarantee that properties required by API are set
|
||||
|
||||
### GetErrors
|
||||
|
||||
`func (o *V0037ReservationsResponse) GetErrors() []V0037Error`
|
||||
|
||||
GetErrors returns the Errors field if non-nil, zero value otherwise.
|
||||
|
||||
### GetErrorsOk
|
||||
|
||||
`func (o *V0037ReservationsResponse) GetErrorsOk() (*[]V0037Error, bool)`
|
||||
|
||||
GetErrorsOk returns a tuple with the Errors field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetErrors
|
||||
|
||||
`func (o *V0037ReservationsResponse) SetErrors(v []V0037Error)`
|
||||
|
||||
SetErrors sets Errors field to given value.
|
||||
|
||||
### HasErrors
|
||||
|
||||
`func (o *V0037ReservationsResponse) HasErrors() bool`
|
||||
|
||||
HasErrors returns a boolean if a field has been set.
|
||||
|
||||
### GetReservations
|
||||
|
||||
`func (o *V0037ReservationsResponse) GetReservations() []V0037Reservation`
|
||||
|
||||
GetReservations returns the Reservations field if non-nil, zero value otherwise.
|
||||
|
||||
### GetReservationsOk
|
||||
|
||||
`func (o *V0037ReservationsResponse) GetReservationsOk() (*[]V0037Reservation, bool)`
|
||||
|
||||
GetReservationsOk returns a tuple with the Reservations field if it's non-nil, zero value otherwise
|
||||
and a boolean to check if the value has been set.
|
||||
|
||||
### SetReservations
|
||||
|
||||
`func (o *V0037ReservationsResponse) SetReservations(v []V0037Reservation)`
|
||||
|
||||
SetReservations sets Reservations field to given value.
|
||||
|
||||
### HasReservations
|
||||
|
||||
`func (o *V0037ReservationsResponse) HasReservations() bool`
|
||||
|
||||
HasReservations returns a boolean if a field has been set.
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
# V0037Signal
|
||||
|
||||
## Enum
|
||||
|
||||
|
||||
* `HUP` (value: `"HUP"`)
|
||||
|
||||
* `INT` (value: `"INT"`)
|
||||
|
||||
* `QUIT` (value: `"QUIT"`)
|
||||
|
||||
* `ABRT` (value: `"ABRT"`)
|
||||
|
||||
* `KILL` (value: `"KILL"`)
|
||||
|
||||
* `ALRM` (value: `"ALRM"`)
|
||||
|
||||
* `TERM` (value: `"TERM"`)
|
||||
|
||||
* `USR1` (value: `"USR1"`)
|
||||
|
||||
* `USR2` (value: `"USR2"`)
|
||||
|
||||
* `URG` (value: `"URG"`)
|
||||
|
||||
* `CONT` (value: `"CONT"`)
|
||||
|
||||
* `STOP` (value: `"STOP"`)
|
||||
|
||||
* `TSTP` (value: `"TSTP"`)
|
||||
|
||||
* `TTIN` (value: `"TTIN"`)
|
||||
|
||||
* `TTOU` (value: `"TTOU"`)
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="github.com"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=$(git remote)
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
@@ -1,6 +0,0 @@
|
||||
module github.com/GIT_USER_ID/GIT_REPO_ID
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
)
|
||||
@@ -1,11 +0,0 @@
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037Diag type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037Diag{}
|
||||
|
||||
// V0037Diag struct for V0037Diag
|
||||
type V0037Diag struct {
|
||||
// slurm errors
|
||||
Errors []V0037Error `json:"errors,omitempty"`
|
||||
Statistics *V0037DiagStatistics `json:"statistics,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037Diag instantiates a new V0037Diag object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037Diag() *V0037Diag {
|
||||
this := V0037Diag{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037DiagWithDefaults instantiates a new V0037Diag object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037DiagWithDefaults() *V0037Diag {
|
||||
this := V0037Diag{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetErrors returns the Errors field value if set, zero value otherwise.
|
||||
func (o *V0037Diag) GetErrors() []V0037Error {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
var ret []V0037Error
|
||||
return ret
|
||||
}
|
||||
return o.Errors
|
||||
}
|
||||
|
||||
// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Diag) GetErrorsOk() ([]V0037Error, bool) {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Errors, true
|
||||
}
|
||||
|
||||
// HasErrors returns a boolean if a field has been set.
|
||||
func (o *V0037Diag) HasErrors() bool {
|
||||
if o != nil && !IsNil(o.Errors) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetErrors gets a reference to the given []V0037Error and assigns it to the Errors field.
|
||||
func (o *V0037Diag) SetErrors(v []V0037Error) {
|
||||
o.Errors = v
|
||||
}
|
||||
|
||||
// GetStatistics returns the Statistics field value if set, zero value otherwise.
|
||||
func (o *V0037Diag) GetStatistics() V0037DiagStatistics {
|
||||
if o == nil || IsNil(o.Statistics) {
|
||||
var ret V0037DiagStatistics
|
||||
return ret
|
||||
}
|
||||
return *o.Statistics
|
||||
}
|
||||
|
||||
// GetStatisticsOk returns a tuple with the Statistics field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Diag) GetStatisticsOk() (*V0037DiagStatistics, bool) {
|
||||
if o == nil || IsNil(o.Statistics) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Statistics, true
|
||||
}
|
||||
|
||||
// HasStatistics returns a boolean if a field has been set.
|
||||
func (o *V0037Diag) HasStatistics() bool {
|
||||
if o != nil && !IsNil(o.Statistics) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetStatistics gets a reference to the given V0037DiagStatistics and assigns it to the Statistics field.
|
||||
func (o *V0037Diag) SetStatistics(v V0037DiagStatistics) {
|
||||
o.Statistics = &v
|
||||
}
|
||||
|
||||
func (o V0037Diag) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037Diag) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Errors) {
|
||||
toSerialize["errors"] = o.Errors
|
||||
}
|
||||
if !IsNil(o.Statistics) {
|
||||
toSerialize["statistics"] = o.Statistics
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037Diag struct {
|
||||
value *V0037Diag
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037Diag) Get() *V0037Diag {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037Diag) Set(val *V0037Diag) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037Diag) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037Diag) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037Diag(val *V0037Diag) *NullableV0037Diag {
|
||||
return &NullableV0037Diag{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037Diag) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037Diag) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,165 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037Error type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037Error{}
|
||||
|
||||
// V0037Error struct for V0037Error
|
||||
type V0037Error struct {
|
||||
// error message
|
||||
Error *string `json:"error,omitempty"`
|
||||
// error number
|
||||
Errno *int32 `json:"errno,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037Error instantiates a new V0037Error object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037Error() *V0037Error {
|
||||
this := V0037Error{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037ErrorWithDefaults instantiates a new V0037Error object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037ErrorWithDefaults() *V0037Error {
|
||||
this := V0037Error{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetError returns the Error field value if set, zero value otherwise.
|
||||
func (o *V0037Error) GetError() string {
|
||||
if o == nil || IsNil(o.Error) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Error
|
||||
}
|
||||
|
||||
// GetErrorOk returns a tuple with the Error field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Error) GetErrorOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Error) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Error, true
|
||||
}
|
||||
|
||||
// HasError returns a boolean if a field has been set.
|
||||
func (o *V0037Error) HasError() bool {
|
||||
if o != nil && !IsNil(o.Error) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetError gets a reference to the given string and assigns it to the Error field.
|
||||
func (o *V0037Error) SetError(v string) {
|
||||
o.Error = &v
|
||||
}
|
||||
|
||||
// GetErrno returns the Errno field value if set, zero value otherwise.
|
||||
func (o *V0037Error) GetErrno() int32 {
|
||||
if o == nil || IsNil(o.Errno) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.Errno
|
||||
}
|
||||
|
||||
// GetErrnoOk returns a tuple with the Errno field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Error) GetErrnoOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.Errno) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Errno, true
|
||||
}
|
||||
|
||||
// HasErrno returns a boolean if a field has been set.
|
||||
func (o *V0037Error) HasErrno() bool {
|
||||
if o != nil && !IsNil(o.Errno) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetErrno gets a reference to the given int32 and assigns it to the Errno field.
|
||||
func (o *V0037Error) SetErrno(v int32) {
|
||||
o.Errno = &v
|
||||
}
|
||||
|
||||
func (o V0037Error) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037Error) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Error) {
|
||||
toSerialize["error"] = o.Error
|
||||
}
|
||||
if !IsNil(o.Errno) {
|
||||
toSerialize["errno"] = o.Errno
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037Error struct {
|
||||
value *V0037Error
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037Error) Get() *V0037Error {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037Error) Set(val *V0037Error) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037Error) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037Error) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037Error(val *V0037Error) *NullableV0037Error {
|
||||
return &NullableV0037Error{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037Error) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037Error) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,239 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037JobResources type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037JobResources{}
|
||||
|
||||
// V0037JobResources struct for V0037JobResources
|
||||
type V0037JobResources struct {
|
||||
// list of assigned job nodes
|
||||
Nodes *string `json:"nodes,omitempty"`
|
||||
// number of assigned job cpus
|
||||
AllocatedCpus *int32 `json:"allocated_cpus,omitempty"`
|
||||
// number of assigned job hosts
|
||||
AllocatedHosts *int32 `json:"allocated_hosts,omitempty"`
|
||||
// node allocations
|
||||
AllocatedNodes []V0037NodeAllocation `json:"allocated_nodes,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037JobResources instantiates a new V0037JobResources object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037JobResources() *V0037JobResources {
|
||||
this := V0037JobResources{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037JobResourcesWithDefaults instantiates a new V0037JobResources object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037JobResourcesWithDefaults() *V0037JobResources {
|
||||
this := V0037JobResources{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetNodes returns the Nodes field value if set, zero value otherwise.
|
||||
func (o *V0037JobResources) GetNodes() string {
|
||||
if o == nil || IsNil(o.Nodes) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Nodes
|
||||
}
|
||||
|
||||
// GetNodesOk returns a tuple with the Nodes field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037JobResources) GetNodesOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Nodes) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Nodes, true
|
||||
}
|
||||
|
||||
// HasNodes returns a boolean if a field has been set.
|
||||
func (o *V0037JobResources) HasNodes() bool {
|
||||
if o != nil && !IsNil(o.Nodes) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetNodes gets a reference to the given string and assigns it to the Nodes field.
|
||||
func (o *V0037JobResources) SetNodes(v string) {
|
||||
o.Nodes = &v
|
||||
}
|
||||
|
||||
// GetAllocatedCpus returns the AllocatedCpus field value if set, zero value otherwise.
|
||||
func (o *V0037JobResources) GetAllocatedCpus() int32 {
|
||||
if o == nil || IsNil(o.AllocatedCpus) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.AllocatedCpus
|
||||
}
|
||||
|
||||
// GetAllocatedCpusOk returns a tuple with the AllocatedCpus field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037JobResources) GetAllocatedCpusOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.AllocatedCpus) {
|
||||
return nil, false
|
||||
}
|
||||
return o.AllocatedCpus, true
|
||||
}
|
||||
|
||||
// HasAllocatedCpus returns a boolean if a field has been set.
|
||||
func (o *V0037JobResources) HasAllocatedCpus() bool {
|
||||
if o != nil && !IsNil(o.AllocatedCpus) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetAllocatedCpus gets a reference to the given int32 and assigns it to the AllocatedCpus field.
|
||||
func (o *V0037JobResources) SetAllocatedCpus(v int32) {
|
||||
o.AllocatedCpus = &v
|
||||
}
|
||||
|
||||
// GetAllocatedHosts returns the AllocatedHosts field value if set, zero value otherwise.
|
||||
func (o *V0037JobResources) GetAllocatedHosts() int32 {
|
||||
if o == nil || IsNil(o.AllocatedHosts) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.AllocatedHosts
|
||||
}
|
||||
|
||||
// GetAllocatedHostsOk returns a tuple with the AllocatedHosts field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037JobResources) GetAllocatedHostsOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.AllocatedHosts) {
|
||||
return nil, false
|
||||
}
|
||||
return o.AllocatedHosts, true
|
||||
}
|
||||
|
||||
// HasAllocatedHosts returns a boolean if a field has been set.
|
||||
func (o *V0037JobResources) HasAllocatedHosts() bool {
|
||||
if o != nil && !IsNil(o.AllocatedHosts) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetAllocatedHosts gets a reference to the given int32 and assigns it to the AllocatedHosts field.
|
||||
func (o *V0037JobResources) SetAllocatedHosts(v int32) {
|
||||
o.AllocatedHosts = &v
|
||||
}
|
||||
|
||||
// GetAllocatedNodes returns the AllocatedNodes field value if set, zero value otherwise.
|
||||
func (o *V0037JobResources) GetAllocatedNodes() []V0037NodeAllocation {
|
||||
if o == nil || IsNil(o.AllocatedNodes) {
|
||||
var ret []V0037NodeAllocation
|
||||
return ret
|
||||
}
|
||||
return o.AllocatedNodes
|
||||
}
|
||||
|
||||
// GetAllocatedNodesOk returns a tuple with the AllocatedNodes field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037JobResources) GetAllocatedNodesOk() ([]V0037NodeAllocation, bool) {
|
||||
if o == nil || IsNil(o.AllocatedNodes) {
|
||||
return nil, false
|
||||
}
|
||||
return o.AllocatedNodes, true
|
||||
}
|
||||
|
||||
// HasAllocatedNodes returns a boolean if a field has been set.
|
||||
func (o *V0037JobResources) HasAllocatedNodes() bool {
|
||||
if o != nil && !IsNil(o.AllocatedNodes) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetAllocatedNodes gets a reference to the given []V0037NodeAllocation and assigns it to the AllocatedNodes field.
|
||||
func (o *V0037JobResources) SetAllocatedNodes(v []V0037NodeAllocation) {
|
||||
o.AllocatedNodes = v
|
||||
}
|
||||
|
||||
func (o V0037JobResources) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037JobResources) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Nodes) {
|
||||
toSerialize["nodes"] = o.Nodes
|
||||
}
|
||||
if !IsNil(o.AllocatedCpus) {
|
||||
toSerialize["allocated_cpus"] = o.AllocatedCpus
|
||||
}
|
||||
if !IsNil(o.AllocatedHosts) {
|
||||
toSerialize["allocated_hosts"] = o.AllocatedHosts
|
||||
}
|
||||
if !IsNil(o.AllocatedNodes) {
|
||||
toSerialize["allocated_nodes"] = o.AllocatedNodes
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037JobResources struct {
|
||||
value *V0037JobResources
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037JobResources) Get() *V0037JobResources {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037JobResources) Set(val *V0037JobResources) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037JobResources) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037JobResources) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037JobResources(val *V0037JobResources) *NullableV0037JobResources {
|
||||
return &NullableV0037JobResources{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037JobResources) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037JobResources) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,192 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037JobSubmission type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037JobSubmission{}
|
||||
|
||||
// V0037JobSubmission struct for V0037JobSubmission
|
||||
type V0037JobSubmission struct {
|
||||
// Executable script (full contents) to run in batch step
|
||||
Script string `json:"script"`
|
||||
Job *V0037JobProperties `json:"job,omitempty"`
|
||||
// Properties of an HetJob
|
||||
Jobs []V0037JobProperties `json:"jobs,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037JobSubmission instantiates a new V0037JobSubmission object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037JobSubmission(script string) *V0037JobSubmission {
|
||||
this := V0037JobSubmission{}
|
||||
this.Script = script
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037JobSubmissionWithDefaults instantiates a new V0037JobSubmission object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037JobSubmissionWithDefaults() *V0037JobSubmission {
|
||||
this := V0037JobSubmission{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetScript returns the Script field value
|
||||
func (o *V0037JobSubmission) GetScript() string {
|
||||
if o == nil {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
|
||||
return o.Script
|
||||
}
|
||||
|
||||
// GetScriptOk returns a tuple with the Script field value
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037JobSubmission) GetScriptOk() (*string, bool) {
|
||||
if o == nil {
|
||||
return nil, false
|
||||
}
|
||||
return &o.Script, true
|
||||
}
|
||||
|
||||
// SetScript sets field value
|
||||
func (o *V0037JobSubmission) SetScript(v string) {
|
||||
o.Script = v
|
||||
}
|
||||
|
||||
// GetJob returns the Job field value if set, zero value otherwise.
|
||||
func (o *V0037JobSubmission) GetJob() V0037JobProperties {
|
||||
if o == nil || IsNil(o.Job) {
|
||||
var ret V0037JobProperties
|
||||
return ret
|
||||
}
|
||||
return *o.Job
|
||||
}
|
||||
|
||||
// GetJobOk returns a tuple with the Job field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037JobSubmission) GetJobOk() (*V0037JobProperties, bool) {
|
||||
if o == nil || IsNil(o.Job) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Job, true
|
||||
}
|
||||
|
||||
// HasJob returns a boolean if a field has been set.
|
||||
func (o *V0037JobSubmission) HasJob() bool {
|
||||
if o != nil && !IsNil(o.Job) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetJob gets a reference to the given V0037JobProperties and assigns it to the Job field.
|
||||
func (o *V0037JobSubmission) SetJob(v V0037JobProperties) {
|
||||
o.Job = &v
|
||||
}
|
||||
|
||||
// GetJobs returns the Jobs field value if set, zero value otherwise.
|
||||
func (o *V0037JobSubmission) GetJobs() []V0037JobProperties {
|
||||
if o == nil || IsNil(o.Jobs) {
|
||||
var ret []V0037JobProperties
|
||||
return ret
|
||||
}
|
||||
return o.Jobs
|
||||
}
|
||||
|
||||
// GetJobsOk returns a tuple with the Jobs field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037JobSubmission) GetJobsOk() ([]V0037JobProperties, bool) {
|
||||
if o == nil || IsNil(o.Jobs) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Jobs, true
|
||||
}
|
||||
|
||||
// HasJobs returns a boolean if a field has been set.
|
||||
func (o *V0037JobSubmission) HasJobs() bool {
|
||||
if o != nil && !IsNil(o.Jobs) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetJobs gets a reference to the given []V0037JobProperties and assigns it to the Jobs field.
|
||||
func (o *V0037JobSubmission) SetJobs(v []V0037JobProperties) {
|
||||
o.Jobs = v
|
||||
}
|
||||
|
||||
func (o V0037JobSubmission) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037JobSubmission) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
toSerialize["script"] = o.Script
|
||||
if !IsNil(o.Job) {
|
||||
toSerialize["job"] = o.Job
|
||||
}
|
||||
if !IsNil(o.Jobs) {
|
||||
toSerialize["jobs"] = o.Jobs
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037JobSubmission struct {
|
||||
value *V0037JobSubmission
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037JobSubmission) Get() *V0037JobSubmission {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037JobSubmission) Set(val *V0037JobSubmission) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037JobSubmission) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037JobSubmission) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037JobSubmission(val *V0037JobSubmission) *NullableV0037JobSubmission {
|
||||
return &NullableV0037JobSubmission{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037JobSubmission) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037JobSubmission) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,239 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037JobSubmissionResponse type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037JobSubmissionResponse{}
|
||||
|
||||
// V0037JobSubmissionResponse struct for V0037JobSubmissionResponse
|
||||
type V0037JobSubmissionResponse struct {
|
||||
// slurm errors
|
||||
Errors []V0037Error `json:"errors,omitempty"`
|
||||
// new job ID
|
||||
JobId *int32 `json:"job_id,omitempty"`
|
||||
// new job step ID
|
||||
StepId *string `json:"step_id,omitempty"`
|
||||
// Message to user from job_submit plugin
|
||||
JobSubmitUserMsg *string `json:"job_submit_user_msg,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037JobSubmissionResponse instantiates a new V0037JobSubmissionResponse object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037JobSubmissionResponse() *V0037JobSubmissionResponse {
|
||||
this := V0037JobSubmissionResponse{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037JobSubmissionResponseWithDefaults instantiates a new V0037JobSubmissionResponse object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037JobSubmissionResponseWithDefaults() *V0037JobSubmissionResponse {
|
||||
this := V0037JobSubmissionResponse{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetErrors returns the Errors field value if set, zero value otherwise.
|
||||
func (o *V0037JobSubmissionResponse) GetErrors() []V0037Error {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
var ret []V0037Error
|
||||
return ret
|
||||
}
|
||||
return o.Errors
|
||||
}
|
||||
|
||||
// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037JobSubmissionResponse) GetErrorsOk() ([]V0037Error, bool) {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Errors, true
|
||||
}
|
||||
|
||||
// HasErrors returns a boolean if a field has been set.
|
||||
func (o *V0037JobSubmissionResponse) HasErrors() bool {
|
||||
if o != nil && !IsNil(o.Errors) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetErrors gets a reference to the given []V0037Error and assigns it to the Errors field.
|
||||
func (o *V0037JobSubmissionResponse) SetErrors(v []V0037Error) {
|
||||
o.Errors = v
|
||||
}
|
||||
|
||||
// GetJobId returns the JobId field value if set, zero value otherwise.
|
||||
func (o *V0037JobSubmissionResponse) GetJobId() int32 {
|
||||
if o == nil || IsNil(o.JobId) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.JobId
|
||||
}
|
||||
|
||||
// GetJobIdOk returns a tuple with the JobId field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037JobSubmissionResponse) GetJobIdOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.JobId) {
|
||||
return nil, false
|
||||
}
|
||||
return o.JobId, true
|
||||
}
|
||||
|
||||
// HasJobId returns a boolean if a field has been set.
|
||||
func (o *V0037JobSubmissionResponse) HasJobId() bool {
|
||||
if o != nil && !IsNil(o.JobId) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetJobId gets a reference to the given int32 and assigns it to the JobId field.
|
||||
func (o *V0037JobSubmissionResponse) SetJobId(v int32) {
|
||||
o.JobId = &v
|
||||
}
|
||||
|
||||
// GetStepId returns the StepId field value if set, zero value otherwise.
|
||||
func (o *V0037JobSubmissionResponse) GetStepId() string {
|
||||
if o == nil || IsNil(o.StepId) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.StepId
|
||||
}
|
||||
|
||||
// GetStepIdOk returns a tuple with the StepId field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037JobSubmissionResponse) GetStepIdOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.StepId) {
|
||||
return nil, false
|
||||
}
|
||||
return o.StepId, true
|
||||
}
|
||||
|
||||
// HasStepId returns a boolean if a field has been set.
|
||||
func (o *V0037JobSubmissionResponse) HasStepId() bool {
|
||||
if o != nil && !IsNil(o.StepId) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetStepId gets a reference to the given string and assigns it to the StepId field.
|
||||
func (o *V0037JobSubmissionResponse) SetStepId(v string) {
|
||||
o.StepId = &v
|
||||
}
|
||||
|
||||
// GetJobSubmitUserMsg returns the JobSubmitUserMsg field value if set, zero value otherwise.
|
||||
func (o *V0037JobSubmissionResponse) GetJobSubmitUserMsg() string {
|
||||
if o == nil || IsNil(o.JobSubmitUserMsg) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.JobSubmitUserMsg
|
||||
}
|
||||
|
||||
// GetJobSubmitUserMsgOk returns a tuple with the JobSubmitUserMsg field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037JobSubmissionResponse) GetJobSubmitUserMsgOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.JobSubmitUserMsg) {
|
||||
return nil, false
|
||||
}
|
||||
return o.JobSubmitUserMsg, true
|
||||
}
|
||||
|
||||
// HasJobSubmitUserMsg returns a boolean if a field has been set.
|
||||
func (o *V0037JobSubmissionResponse) HasJobSubmitUserMsg() bool {
|
||||
if o != nil && !IsNil(o.JobSubmitUserMsg) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetJobSubmitUserMsg gets a reference to the given string and assigns it to the JobSubmitUserMsg field.
|
||||
func (o *V0037JobSubmissionResponse) SetJobSubmitUserMsg(v string) {
|
||||
o.JobSubmitUserMsg = &v
|
||||
}
|
||||
|
||||
func (o V0037JobSubmissionResponse) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037JobSubmissionResponse) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Errors) {
|
||||
toSerialize["errors"] = o.Errors
|
||||
}
|
||||
if !IsNil(o.JobId) {
|
||||
toSerialize["job_id"] = o.JobId
|
||||
}
|
||||
if !IsNil(o.StepId) {
|
||||
toSerialize["step_id"] = o.StepId
|
||||
}
|
||||
if !IsNil(o.JobSubmitUserMsg) {
|
||||
toSerialize["job_submit_user_msg"] = o.JobSubmitUserMsg
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037JobSubmissionResponse struct {
|
||||
value *V0037JobSubmissionResponse
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037JobSubmissionResponse) Get() *V0037JobSubmissionResponse {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037JobSubmissionResponse) Set(val *V0037JobSubmissionResponse) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037JobSubmissionResponse) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037JobSubmissionResponse) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037JobSubmissionResponse(val *V0037JobSubmissionResponse) *NullableV0037JobSubmissionResponse {
|
||||
return &NullableV0037JobSubmissionResponse{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037JobSubmissionResponse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037JobSubmissionResponse) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037JobsResponse type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037JobsResponse{}
|
||||
|
||||
// V0037JobsResponse struct for V0037JobsResponse
|
||||
type V0037JobsResponse struct {
|
||||
// slurm errors
|
||||
Errors []V0037Error `json:"errors,omitempty"`
|
||||
// job descriptions
|
||||
Jobs []V0037JobResponseProperties `json:"jobs,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037JobsResponse instantiates a new V0037JobsResponse object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037JobsResponse() *V0037JobsResponse {
|
||||
this := V0037JobsResponse{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037JobsResponseWithDefaults instantiates a new V0037JobsResponse object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037JobsResponseWithDefaults() *V0037JobsResponse {
|
||||
this := V0037JobsResponse{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetErrors returns the Errors field value if set, zero value otherwise.
|
||||
func (o *V0037JobsResponse) GetErrors() []V0037Error {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
var ret []V0037Error
|
||||
return ret
|
||||
}
|
||||
return o.Errors
|
||||
}
|
||||
|
||||
// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037JobsResponse) GetErrorsOk() ([]V0037Error, bool) {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Errors, true
|
||||
}
|
||||
|
||||
// HasErrors returns a boolean if a field has been set.
|
||||
func (o *V0037JobsResponse) HasErrors() bool {
|
||||
if o != nil && !IsNil(o.Errors) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetErrors gets a reference to the given []V0037Error and assigns it to the Errors field.
|
||||
func (o *V0037JobsResponse) SetErrors(v []V0037Error) {
|
||||
o.Errors = v
|
||||
}
|
||||
|
||||
// GetJobs returns the Jobs field value if set, zero value otherwise.
|
||||
func (o *V0037JobsResponse) GetJobs() []V0037JobResponseProperties {
|
||||
if o == nil || IsNil(o.Jobs) {
|
||||
var ret []V0037JobResponseProperties
|
||||
return ret
|
||||
}
|
||||
return o.Jobs
|
||||
}
|
||||
|
||||
// GetJobsOk returns a tuple with the Jobs field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037JobsResponse) GetJobsOk() ([]V0037JobResponseProperties, bool) {
|
||||
if o == nil || IsNil(o.Jobs) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Jobs, true
|
||||
}
|
||||
|
||||
// HasJobs returns a boolean if a field has been set.
|
||||
func (o *V0037JobsResponse) HasJobs() bool {
|
||||
if o != nil && !IsNil(o.Jobs) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetJobs gets a reference to the given []V0037JobResponseProperties and assigns it to the Jobs field.
|
||||
func (o *V0037JobsResponse) SetJobs(v []V0037JobResponseProperties) {
|
||||
o.Jobs = v
|
||||
}
|
||||
|
||||
func (o V0037JobsResponse) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037JobsResponse) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Errors) {
|
||||
toSerialize["errors"] = o.Errors
|
||||
}
|
||||
if !IsNil(o.Jobs) {
|
||||
toSerialize["jobs"] = o.Jobs
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037JobsResponse struct {
|
||||
value *V0037JobsResponse
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037JobsResponse) Get() *V0037JobsResponse {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037JobsResponse) Set(val *V0037JobsResponse) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037JobsResponse) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037JobsResponse) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037JobsResponse(val *V0037JobsResponse) *NullableV0037JobsResponse {
|
||||
return &NullableV0037JobsResponse{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037JobsResponse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037JobsResponse) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,239 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037NodeAllocation type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037NodeAllocation{}
|
||||
|
||||
// V0037NodeAllocation struct for V0037NodeAllocation
|
||||
type V0037NodeAllocation struct {
|
||||
// amount of assigned job memory
|
||||
Memory *int32 `json:"memory,omitempty"`
|
||||
// amount of assigned job CPUs
|
||||
Cpus map[string]interface{} `json:"cpus,omitempty"`
|
||||
// assignment status of each socket by socket id
|
||||
Sockets map[string]interface{} `json:"sockets,omitempty"`
|
||||
// assignment status of each core by core id
|
||||
Cores map[string]interface{} `json:"cores,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037NodeAllocation instantiates a new V0037NodeAllocation object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037NodeAllocation() *V0037NodeAllocation {
|
||||
this := V0037NodeAllocation{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037NodeAllocationWithDefaults instantiates a new V0037NodeAllocation object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037NodeAllocationWithDefaults() *V0037NodeAllocation {
|
||||
this := V0037NodeAllocation{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetMemory returns the Memory field value if set, zero value otherwise.
|
||||
func (o *V0037NodeAllocation) GetMemory() int32 {
|
||||
if o == nil || IsNil(o.Memory) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.Memory
|
||||
}
|
||||
|
||||
// GetMemoryOk returns a tuple with the Memory field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037NodeAllocation) GetMemoryOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.Memory) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Memory, true
|
||||
}
|
||||
|
||||
// HasMemory returns a boolean if a field has been set.
|
||||
func (o *V0037NodeAllocation) HasMemory() bool {
|
||||
if o != nil && !IsNil(o.Memory) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetMemory gets a reference to the given int32 and assigns it to the Memory field.
|
||||
func (o *V0037NodeAllocation) SetMemory(v int32) {
|
||||
o.Memory = &v
|
||||
}
|
||||
|
||||
// GetCpus returns the Cpus field value if set, zero value otherwise.
|
||||
func (o *V0037NodeAllocation) GetCpus() map[string]interface{} {
|
||||
if o == nil || IsNil(o.Cpus) {
|
||||
var ret map[string]interface{}
|
||||
return ret
|
||||
}
|
||||
return o.Cpus
|
||||
}
|
||||
|
||||
// GetCpusOk returns a tuple with the Cpus field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037NodeAllocation) GetCpusOk() (map[string]interface{}, bool) {
|
||||
if o == nil || IsNil(o.Cpus) {
|
||||
return map[string]interface{}{}, false
|
||||
}
|
||||
return o.Cpus, true
|
||||
}
|
||||
|
||||
// HasCpus returns a boolean if a field has been set.
|
||||
func (o *V0037NodeAllocation) HasCpus() bool {
|
||||
if o != nil && !IsNil(o.Cpus) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetCpus gets a reference to the given map[string]interface{} and assigns it to the Cpus field.
|
||||
func (o *V0037NodeAllocation) SetCpus(v map[string]interface{}) {
|
||||
o.Cpus = v
|
||||
}
|
||||
|
||||
// GetSockets returns the Sockets field value if set, zero value otherwise.
|
||||
func (o *V0037NodeAllocation) GetSockets() map[string]interface{} {
|
||||
if o == nil || IsNil(o.Sockets) {
|
||||
var ret map[string]interface{}
|
||||
return ret
|
||||
}
|
||||
return o.Sockets
|
||||
}
|
||||
|
||||
// GetSocketsOk returns a tuple with the Sockets field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037NodeAllocation) GetSocketsOk() (map[string]interface{}, bool) {
|
||||
if o == nil || IsNil(o.Sockets) {
|
||||
return map[string]interface{}{}, false
|
||||
}
|
||||
return o.Sockets, true
|
||||
}
|
||||
|
||||
// HasSockets returns a boolean if a field has been set.
|
||||
func (o *V0037NodeAllocation) HasSockets() bool {
|
||||
if o != nil && !IsNil(o.Sockets) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetSockets gets a reference to the given map[string]interface{} and assigns it to the Sockets field.
|
||||
func (o *V0037NodeAllocation) SetSockets(v map[string]interface{}) {
|
||||
o.Sockets = v
|
||||
}
|
||||
|
||||
// GetCores returns the Cores field value if set, zero value otherwise.
|
||||
func (o *V0037NodeAllocation) GetCores() map[string]interface{} {
|
||||
if o == nil || IsNil(o.Cores) {
|
||||
var ret map[string]interface{}
|
||||
return ret
|
||||
}
|
||||
return o.Cores
|
||||
}
|
||||
|
||||
// GetCoresOk returns a tuple with the Cores field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037NodeAllocation) GetCoresOk() (map[string]interface{}, bool) {
|
||||
if o == nil || IsNil(o.Cores) {
|
||||
return map[string]interface{}{}, false
|
||||
}
|
||||
return o.Cores, true
|
||||
}
|
||||
|
||||
// HasCores returns a boolean if a field has been set.
|
||||
func (o *V0037NodeAllocation) HasCores() bool {
|
||||
if o != nil && !IsNil(o.Cores) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetCores gets a reference to the given map[string]interface{} and assigns it to the Cores field.
|
||||
func (o *V0037NodeAllocation) SetCores(v map[string]interface{}) {
|
||||
o.Cores = v
|
||||
}
|
||||
|
||||
func (o V0037NodeAllocation) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037NodeAllocation) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Memory) {
|
||||
toSerialize["memory"] = o.Memory
|
||||
}
|
||||
if !IsNil(o.Cpus) {
|
||||
toSerialize["cpus"] = o.Cpus
|
||||
}
|
||||
if !IsNil(o.Sockets) {
|
||||
toSerialize["sockets"] = o.Sockets
|
||||
}
|
||||
if !IsNil(o.Cores) {
|
||||
toSerialize["cores"] = o.Cores
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037NodeAllocation struct {
|
||||
value *V0037NodeAllocation
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037NodeAllocation) Get() *V0037NodeAllocation {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037NodeAllocation) Set(val *V0037NodeAllocation) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037NodeAllocation) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037NodeAllocation) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037NodeAllocation(val *V0037NodeAllocation) *NullableV0037NodeAllocation {
|
||||
return &NullableV0037NodeAllocation{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037NodeAllocation) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037NodeAllocation) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037NodesResponse type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037NodesResponse{}
|
||||
|
||||
// V0037NodesResponse struct for V0037NodesResponse
|
||||
type V0037NodesResponse struct {
|
||||
// slurm errors
|
||||
Errors []V0037Error `json:"errors,omitempty"`
|
||||
// nodes info
|
||||
Nodes []V0037Node `json:"nodes,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037NodesResponse instantiates a new V0037NodesResponse object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037NodesResponse() *V0037NodesResponse {
|
||||
this := V0037NodesResponse{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037NodesResponseWithDefaults instantiates a new V0037NodesResponse object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037NodesResponseWithDefaults() *V0037NodesResponse {
|
||||
this := V0037NodesResponse{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetErrors returns the Errors field value if set, zero value otherwise.
|
||||
func (o *V0037NodesResponse) GetErrors() []V0037Error {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
var ret []V0037Error
|
||||
return ret
|
||||
}
|
||||
return o.Errors
|
||||
}
|
||||
|
||||
// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037NodesResponse) GetErrorsOk() ([]V0037Error, bool) {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Errors, true
|
||||
}
|
||||
|
||||
// HasErrors returns a boolean if a field has been set.
|
||||
func (o *V0037NodesResponse) HasErrors() bool {
|
||||
if o != nil && !IsNil(o.Errors) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetErrors gets a reference to the given []V0037Error and assigns it to the Errors field.
|
||||
func (o *V0037NodesResponse) SetErrors(v []V0037Error) {
|
||||
o.Errors = v
|
||||
}
|
||||
|
||||
// GetNodes returns the Nodes field value if set, zero value otherwise.
|
||||
func (o *V0037NodesResponse) GetNodes() []V0037Node {
|
||||
if o == nil || IsNil(o.Nodes) {
|
||||
var ret []V0037Node
|
||||
return ret
|
||||
}
|
||||
return o.Nodes
|
||||
}
|
||||
|
||||
// GetNodesOk returns a tuple with the Nodes field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037NodesResponse) GetNodesOk() ([]V0037Node, bool) {
|
||||
if o == nil || IsNil(o.Nodes) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Nodes, true
|
||||
}
|
||||
|
||||
// HasNodes returns a boolean if a field has been set.
|
||||
func (o *V0037NodesResponse) HasNodes() bool {
|
||||
if o != nil && !IsNil(o.Nodes) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetNodes gets a reference to the given []V0037Node and assigns it to the Nodes field.
|
||||
func (o *V0037NodesResponse) SetNodes(v []V0037Node) {
|
||||
o.Nodes = v
|
||||
}
|
||||
|
||||
func (o V0037NodesResponse) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037NodesResponse) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Errors) {
|
||||
toSerialize["errors"] = o.Errors
|
||||
}
|
||||
if !IsNil(o.Nodes) {
|
||||
toSerialize["nodes"] = o.Nodes
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037NodesResponse struct {
|
||||
value *V0037NodesResponse
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037NodesResponse) Get() *V0037NodesResponse {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037NodesResponse) Set(val *V0037NodesResponse) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037NodesResponse) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037NodesResponse) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037NodesResponse(val *V0037NodesResponse) *NullableV0037NodesResponse {
|
||||
return &NullableV0037NodesResponse{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037NodesResponse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037NodesResponse) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,165 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037PartitionsResponse type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037PartitionsResponse{}
|
||||
|
||||
// V0037PartitionsResponse struct for V0037PartitionsResponse
|
||||
type V0037PartitionsResponse struct {
|
||||
// slurm errors
|
||||
Errors []V0037Error `json:"errors,omitempty"`
|
||||
// partition info
|
||||
Partitions []V0037Partition `json:"partitions,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037PartitionsResponse instantiates a new V0037PartitionsResponse object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037PartitionsResponse() *V0037PartitionsResponse {
|
||||
this := V0037PartitionsResponse{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037PartitionsResponseWithDefaults instantiates a new V0037PartitionsResponse object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037PartitionsResponseWithDefaults() *V0037PartitionsResponse {
|
||||
this := V0037PartitionsResponse{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetErrors returns the Errors field value if set, zero value otherwise.
|
||||
func (o *V0037PartitionsResponse) GetErrors() []V0037Error {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
var ret []V0037Error
|
||||
return ret
|
||||
}
|
||||
return o.Errors
|
||||
}
|
||||
|
||||
// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037PartitionsResponse) GetErrorsOk() ([]V0037Error, bool) {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Errors, true
|
||||
}
|
||||
|
||||
// HasErrors returns a boolean if a field has been set.
|
||||
func (o *V0037PartitionsResponse) HasErrors() bool {
|
||||
if o != nil && !IsNil(o.Errors) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetErrors gets a reference to the given []V0037Error and assigns it to the Errors field.
|
||||
func (o *V0037PartitionsResponse) SetErrors(v []V0037Error) {
|
||||
o.Errors = v
|
||||
}
|
||||
|
||||
// GetPartitions returns the Partitions field value if set, zero value otherwise.
|
||||
func (o *V0037PartitionsResponse) GetPartitions() []V0037Partition {
|
||||
if o == nil || IsNil(o.Partitions) {
|
||||
var ret []V0037Partition
|
||||
return ret
|
||||
}
|
||||
return o.Partitions
|
||||
}
|
||||
|
||||
// GetPartitionsOk returns a tuple with the Partitions field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037PartitionsResponse) GetPartitionsOk() ([]V0037Partition, bool) {
|
||||
if o == nil || IsNil(o.Partitions) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Partitions, true
|
||||
}
|
||||
|
||||
// HasPartitions returns a boolean if a field has been set.
|
||||
func (o *V0037PartitionsResponse) HasPartitions() bool {
|
||||
if o != nil && !IsNil(o.Partitions) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetPartitions gets a reference to the given []V0037Partition and assigns it to the Partitions field.
|
||||
func (o *V0037PartitionsResponse) SetPartitions(v []V0037Partition) {
|
||||
o.Partitions = v
|
||||
}
|
||||
|
||||
func (o V0037PartitionsResponse) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037PartitionsResponse) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Errors) {
|
||||
toSerialize["errors"] = o.Errors
|
||||
}
|
||||
if !IsNil(o.Partitions) {
|
||||
toSerialize["partitions"] = o.Partitions
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037PartitionsResponse struct {
|
||||
value *V0037PartitionsResponse
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037PartitionsResponse) Get() *V0037PartitionsResponse {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037PartitionsResponse) Set(val *V0037PartitionsResponse) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037PartitionsResponse) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037PartitionsResponse) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037PartitionsResponse(val *V0037PartitionsResponse) *NullableV0037PartitionsResponse {
|
||||
return &NullableV0037PartitionsResponse{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037PartitionsResponse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037PartitionsResponse) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,239 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037Ping type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037Ping{}
|
||||
|
||||
// V0037Ping struct for V0037Ping
|
||||
type V0037Ping struct {
|
||||
// slurm controller hostname
|
||||
Hostname *string `json:"hostname,omitempty"`
|
||||
// slurm controller host up
|
||||
Ping *string `json:"ping,omitempty"`
|
||||
// slurm controller mode
|
||||
Mode *string `json:"mode,omitempty"`
|
||||
// slurm controller status
|
||||
Status *int32 `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037Ping instantiates a new V0037Ping object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037Ping() *V0037Ping {
|
||||
this := V0037Ping{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037PingWithDefaults instantiates a new V0037Ping object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037PingWithDefaults() *V0037Ping {
|
||||
this := V0037Ping{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetHostname returns the Hostname field value if set, zero value otherwise.
|
||||
func (o *V0037Ping) GetHostname() string {
|
||||
if o == nil || IsNil(o.Hostname) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Hostname
|
||||
}
|
||||
|
||||
// GetHostnameOk returns a tuple with the Hostname field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Ping) GetHostnameOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Hostname) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Hostname, true
|
||||
}
|
||||
|
||||
// HasHostname returns a boolean if a field has been set.
|
||||
func (o *V0037Ping) HasHostname() bool {
|
||||
if o != nil && !IsNil(o.Hostname) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetHostname gets a reference to the given string and assigns it to the Hostname field.
|
||||
func (o *V0037Ping) SetHostname(v string) {
|
||||
o.Hostname = &v
|
||||
}
|
||||
|
||||
// GetPing returns the Ping field value if set, zero value otherwise.
|
||||
func (o *V0037Ping) GetPing() string {
|
||||
if o == nil || IsNil(o.Ping) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Ping
|
||||
}
|
||||
|
||||
// GetPingOk returns a tuple with the Ping field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Ping) GetPingOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Ping) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Ping, true
|
||||
}
|
||||
|
||||
// HasPing returns a boolean if a field has been set.
|
||||
func (o *V0037Ping) HasPing() bool {
|
||||
if o != nil && !IsNil(o.Ping) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetPing gets a reference to the given string and assigns it to the Ping field.
|
||||
func (o *V0037Ping) SetPing(v string) {
|
||||
o.Ping = &v
|
||||
}
|
||||
|
||||
// GetMode returns the Mode field value if set, zero value otherwise.
|
||||
func (o *V0037Ping) GetMode() string {
|
||||
if o == nil || IsNil(o.Mode) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Mode
|
||||
}
|
||||
|
||||
// GetModeOk returns a tuple with the Mode field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Ping) GetModeOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Mode) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Mode, true
|
||||
}
|
||||
|
||||
// HasMode returns a boolean if a field has been set.
|
||||
func (o *V0037Ping) HasMode() bool {
|
||||
if o != nil && !IsNil(o.Mode) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetMode gets a reference to the given string and assigns it to the Mode field.
|
||||
func (o *V0037Ping) SetMode(v string) {
|
||||
o.Mode = &v
|
||||
}
|
||||
|
||||
// GetStatus returns the Status field value if set, zero value otherwise.
|
||||
func (o *V0037Ping) GetStatus() int32 {
|
||||
if o == nil || IsNil(o.Status) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.Status
|
||||
}
|
||||
|
||||
// GetStatusOk returns a tuple with the Status field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Ping) GetStatusOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.Status) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Status, true
|
||||
}
|
||||
|
||||
// HasStatus returns a boolean if a field has been set.
|
||||
func (o *V0037Ping) HasStatus() bool {
|
||||
if o != nil && !IsNil(o.Status) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetStatus gets a reference to the given int32 and assigns it to the Status field.
|
||||
func (o *V0037Ping) SetStatus(v int32) {
|
||||
o.Status = &v
|
||||
}
|
||||
|
||||
func (o V0037Ping) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037Ping) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Hostname) {
|
||||
toSerialize["hostname"] = o.Hostname
|
||||
}
|
||||
if !IsNil(o.Ping) {
|
||||
toSerialize["ping"] = o.Ping
|
||||
}
|
||||
if !IsNil(o.Mode) {
|
||||
toSerialize["mode"] = o.Mode
|
||||
}
|
||||
if !IsNil(o.Status) {
|
||||
toSerialize["status"] = o.Status
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037Ping struct {
|
||||
value *V0037Ping
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037Ping) Get() *V0037Ping {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037Ping) Set(val *V0037Ping) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037Ping) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037Ping) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037Ping(val *V0037Ping) *NullableV0037Ping {
|
||||
return &NullableV0037Ping{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037Ping) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037Ping) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037Pings type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037Pings{}
|
||||
|
||||
// V0037Pings struct for V0037Pings
|
||||
type V0037Pings struct {
|
||||
// slurm errors
|
||||
Errors []V0037Error `json:"errors,omitempty"`
|
||||
// slurm controller pings
|
||||
Pings []V0037Ping `json:"pings,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037Pings instantiates a new V0037Pings object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037Pings() *V0037Pings {
|
||||
this := V0037Pings{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037PingsWithDefaults instantiates a new V0037Pings object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037PingsWithDefaults() *V0037Pings {
|
||||
this := V0037Pings{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetErrors returns the Errors field value if set, zero value otherwise.
|
||||
func (o *V0037Pings) GetErrors() []V0037Error {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
var ret []V0037Error
|
||||
return ret
|
||||
}
|
||||
return o.Errors
|
||||
}
|
||||
|
||||
// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Pings) GetErrorsOk() ([]V0037Error, bool) {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Errors, true
|
||||
}
|
||||
|
||||
// HasErrors returns a boolean if a field has been set.
|
||||
func (o *V0037Pings) HasErrors() bool {
|
||||
if o != nil && !IsNil(o.Errors) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetErrors gets a reference to the given []V0037Error and assigns it to the Errors field.
|
||||
func (o *V0037Pings) SetErrors(v []V0037Error) {
|
||||
o.Errors = v
|
||||
}
|
||||
|
||||
// GetPings returns the Pings field value if set, zero value otherwise.
|
||||
func (o *V0037Pings) GetPings() []V0037Ping {
|
||||
if o == nil || IsNil(o.Pings) {
|
||||
var ret []V0037Ping
|
||||
return ret
|
||||
}
|
||||
return o.Pings
|
||||
}
|
||||
|
||||
// GetPingsOk returns a tuple with the Pings field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Pings) GetPingsOk() ([]V0037Ping, bool) {
|
||||
if o == nil || IsNil(o.Pings) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Pings, true
|
||||
}
|
||||
|
||||
// HasPings returns a boolean if a field has been set.
|
||||
func (o *V0037Pings) HasPings() bool {
|
||||
if o != nil && !IsNil(o.Pings) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetPings gets a reference to the given []V0037Ping and assigns it to the Pings field.
|
||||
func (o *V0037Pings) SetPings(v []V0037Ping) {
|
||||
o.Pings = v
|
||||
}
|
||||
|
||||
func (o V0037Pings) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037Pings) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Errors) {
|
||||
toSerialize["errors"] = o.Errors
|
||||
}
|
||||
if !IsNil(o.Pings) {
|
||||
toSerialize["pings"] = o.Pings
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037Pings struct {
|
||||
value *V0037Pings
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037Pings) Get() *V0037Pings {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037Pings) Set(val *V0037Pings) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037Pings) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037Pings) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037Pings(val *V0037Pings) *NullableV0037Pings {
|
||||
return &NullableV0037Pings{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037Pings) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037Pings) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,793 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037Reservation type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037Reservation{}
|
||||
|
||||
// V0037Reservation struct for V0037Reservation
|
||||
type V0037Reservation struct {
|
||||
// Allowed accounts
|
||||
Accounts *string `json:"accounts,omitempty"`
|
||||
// Reserved burst buffer
|
||||
BurstBuffer *string `json:"burst_buffer,omitempty"`
|
||||
// Number of reserved cores
|
||||
CoreCount *int32 `json:"core_count,omitempty"`
|
||||
// Number of reserved specialized cores
|
||||
CoreSpecCnt *int32 `json:"core_spec_cnt,omitempty"`
|
||||
// End time of the reservation
|
||||
EndTime *int32 `json:"end_time,omitempty"`
|
||||
// List of features
|
||||
Features *string `json:"features,omitempty"`
|
||||
// Reservation options
|
||||
Flags []string `json:"flags,omitempty"`
|
||||
// List of groups permitted to use the reserved nodes
|
||||
Groups *string `json:"groups,omitempty"`
|
||||
// List of licenses
|
||||
Licenses *string `json:"licenses,omitempty"`
|
||||
// Maximum delay in which jobs outside of the reservation will be permitted to overlap once any jobs are queued for the reservation
|
||||
MaxStartDelay *int32 `json:"max_start_delay,omitempty"`
|
||||
// Reservationn name
|
||||
Name *string `json:"name,omitempty"`
|
||||
// Count of nodes reserved
|
||||
NodeCount *int32 `json:"node_count,omitempty"`
|
||||
// List of reserved nodes
|
||||
NodeList *string `json:"node_list,omitempty"`
|
||||
// Partition
|
||||
Partition *string `json:"partition,omitempty"`
|
||||
PurgeCompleted *V0037ReservationPurgeCompleted `json:"purge_completed,omitempty"`
|
||||
// Start time of reservation
|
||||
StartTime *int32 `json:"start_time,omitempty"`
|
||||
// amount of power to reserve in watts
|
||||
Watts *int32 `json:"watts,omitempty"`
|
||||
// List of TRES
|
||||
Tres *string `json:"tres,omitempty"`
|
||||
// List of users
|
||||
Users *string `json:"users,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037Reservation instantiates a new V0037Reservation object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037Reservation() *V0037Reservation {
|
||||
this := V0037Reservation{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037ReservationWithDefaults instantiates a new V0037Reservation object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037ReservationWithDefaults() *V0037Reservation {
|
||||
this := V0037Reservation{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetAccounts returns the Accounts field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetAccounts() string {
|
||||
if o == nil || IsNil(o.Accounts) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Accounts
|
||||
}
|
||||
|
||||
// GetAccountsOk returns a tuple with the Accounts field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetAccountsOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Accounts) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Accounts, true
|
||||
}
|
||||
|
||||
// HasAccounts returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasAccounts() bool {
|
||||
if o != nil && !IsNil(o.Accounts) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetAccounts gets a reference to the given string and assigns it to the Accounts field.
|
||||
func (o *V0037Reservation) SetAccounts(v string) {
|
||||
o.Accounts = &v
|
||||
}
|
||||
|
||||
// GetBurstBuffer returns the BurstBuffer field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetBurstBuffer() string {
|
||||
if o == nil || IsNil(o.BurstBuffer) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.BurstBuffer
|
||||
}
|
||||
|
||||
// GetBurstBufferOk returns a tuple with the BurstBuffer field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetBurstBufferOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.BurstBuffer) {
|
||||
return nil, false
|
||||
}
|
||||
return o.BurstBuffer, true
|
||||
}
|
||||
|
||||
// HasBurstBuffer returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasBurstBuffer() bool {
|
||||
if o != nil && !IsNil(o.BurstBuffer) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetBurstBuffer gets a reference to the given string and assigns it to the BurstBuffer field.
|
||||
func (o *V0037Reservation) SetBurstBuffer(v string) {
|
||||
o.BurstBuffer = &v
|
||||
}
|
||||
|
||||
// GetCoreCount returns the CoreCount field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetCoreCount() int32 {
|
||||
if o == nil || IsNil(o.CoreCount) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.CoreCount
|
||||
}
|
||||
|
||||
// GetCoreCountOk returns a tuple with the CoreCount field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetCoreCountOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.CoreCount) {
|
||||
return nil, false
|
||||
}
|
||||
return o.CoreCount, true
|
||||
}
|
||||
|
||||
// HasCoreCount returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasCoreCount() bool {
|
||||
if o != nil && !IsNil(o.CoreCount) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetCoreCount gets a reference to the given int32 and assigns it to the CoreCount field.
|
||||
func (o *V0037Reservation) SetCoreCount(v int32) {
|
||||
o.CoreCount = &v
|
||||
}
|
||||
|
||||
// GetCoreSpecCnt returns the CoreSpecCnt field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetCoreSpecCnt() int32 {
|
||||
if o == nil || IsNil(o.CoreSpecCnt) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.CoreSpecCnt
|
||||
}
|
||||
|
||||
// GetCoreSpecCntOk returns a tuple with the CoreSpecCnt field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetCoreSpecCntOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.CoreSpecCnt) {
|
||||
return nil, false
|
||||
}
|
||||
return o.CoreSpecCnt, true
|
||||
}
|
||||
|
||||
// HasCoreSpecCnt returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasCoreSpecCnt() bool {
|
||||
if o != nil && !IsNil(o.CoreSpecCnt) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetCoreSpecCnt gets a reference to the given int32 and assigns it to the CoreSpecCnt field.
|
||||
func (o *V0037Reservation) SetCoreSpecCnt(v int32) {
|
||||
o.CoreSpecCnt = &v
|
||||
}
|
||||
|
||||
// GetEndTime returns the EndTime field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetEndTime() int32 {
|
||||
if o == nil || IsNil(o.EndTime) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.EndTime
|
||||
}
|
||||
|
||||
// GetEndTimeOk returns a tuple with the EndTime field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetEndTimeOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.EndTime) {
|
||||
return nil, false
|
||||
}
|
||||
return o.EndTime, true
|
||||
}
|
||||
|
||||
// HasEndTime returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasEndTime() bool {
|
||||
if o != nil && !IsNil(o.EndTime) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetEndTime gets a reference to the given int32 and assigns it to the EndTime field.
|
||||
func (o *V0037Reservation) SetEndTime(v int32) {
|
||||
o.EndTime = &v
|
||||
}
|
||||
|
||||
// GetFeatures returns the Features field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetFeatures() string {
|
||||
if o == nil || IsNil(o.Features) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Features
|
||||
}
|
||||
|
||||
// GetFeaturesOk returns a tuple with the Features field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetFeaturesOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Features) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Features, true
|
||||
}
|
||||
|
||||
// HasFeatures returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasFeatures() bool {
|
||||
if o != nil && !IsNil(o.Features) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetFeatures gets a reference to the given string and assigns it to the Features field.
|
||||
func (o *V0037Reservation) SetFeatures(v string) {
|
||||
o.Features = &v
|
||||
}
|
||||
|
||||
// GetFlags returns the Flags field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetFlags() []string {
|
||||
if o == nil || IsNil(o.Flags) {
|
||||
var ret []string
|
||||
return ret
|
||||
}
|
||||
return o.Flags
|
||||
}
|
||||
|
||||
// GetFlagsOk returns a tuple with the Flags field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetFlagsOk() ([]string, bool) {
|
||||
if o == nil || IsNil(o.Flags) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Flags, true
|
||||
}
|
||||
|
||||
// HasFlags returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasFlags() bool {
|
||||
if o != nil && !IsNil(o.Flags) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetFlags gets a reference to the given []string and assigns it to the Flags field.
|
||||
func (o *V0037Reservation) SetFlags(v []string) {
|
||||
o.Flags = v
|
||||
}
|
||||
|
||||
// GetGroups returns the Groups field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetGroups() string {
|
||||
if o == nil || IsNil(o.Groups) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Groups
|
||||
}
|
||||
|
||||
// GetGroupsOk returns a tuple with the Groups field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetGroupsOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Groups) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Groups, true
|
||||
}
|
||||
|
||||
// HasGroups returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasGroups() bool {
|
||||
if o != nil && !IsNil(o.Groups) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetGroups gets a reference to the given string and assigns it to the Groups field.
|
||||
func (o *V0037Reservation) SetGroups(v string) {
|
||||
o.Groups = &v
|
||||
}
|
||||
|
||||
// GetLicenses returns the Licenses field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetLicenses() string {
|
||||
if o == nil || IsNil(o.Licenses) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Licenses
|
||||
}
|
||||
|
||||
// GetLicensesOk returns a tuple with the Licenses field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetLicensesOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Licenses) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Licenses, true
|
||||
}
|
||||
|
||||
// HasLicenses returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasLicenses() bool {
|
||||
if o != nil && !IsNil(o.Licenses) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetLicenses gets a reference to the given string and assigns it to the Licenses field.
|
||||
func (o *V0037Reservation) SetLicenses(v string) {
|
||||
o.Licenses = &v
|
||||
}
|
||||
|
||||
// GetMaxStartDelay returns the MaxStartDelay field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetMaxStartDelay() int32 {
|
||||
if o == nil || IsNil(o.MaxStartDelay) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.MaxStartDelay
|
||||
}
|
||||
|
||||
// GetMaxStartDelayOk returns a tuple with the MaxStartDelay field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetMaxStartDelayOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.MaxStartDelay) {
|
||||
return nil, false
|
||||
}
|
||||
return o.MaxStartDelay, true
|
||||
}
|
||||
|
||||
// HasMaxStartDelay returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasMaxStartDelay() bool {
|
||||
if o != nil && !IsNil(o.MaxStartDelay) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetMaxStartDelay gets a reference to the given int32 and assigns it to the MaxStartDelay field.
|
||||
func (o *V0037Reservation) SetMaxStartDelay(v int32) {
|
||||
o.MaxStartDelay = &v
|
||||
}
|
||||
|
||||
// GetName returns the Name field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetName() string {
|
||||
if o == nil || IsNil(o.Name) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Name
|
||||
}
|
||||
|
||||
// GetNameOk returns a tuple with the Name field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetNameOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Name) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Name, true
|
||||
}
|
||||
|
||||
// HasName returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasName() bool {
|
||||
if o != nil && !IsNil(o.Name) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetName gets a reference to the given string and assigns it to the Name field.
|
||||
func (o *V0037Reservation) SetName(v string) {
|
||||
o.Name = &v
|
||||
}
|
||||
|
||||
// GetNodeCount returns the NodeCount field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetNodeCount() int32 {
|
||||
if o == nil || IsNil(o.NodeCount) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.NodeCount
|
||||
}
|
||||
|
||||
// GetNodeCountOk returns a tuple with the NodeCount field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetNodeCountOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.NodeCount) {
|
||||
return nil, false
|
||||
}
|
||||
return o.NodeCount, true
|
||||
}
|
||||
|
||||
// HasNodeCount returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasNodeCount() bool {
|
||||
if o != nil && !IsNil(o.NodeCount) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetNodeCount gets a reference to the given int32 and assigns it to the NodeCount field.
|
||||
func (o *V0037Reservation) SetNodeCount(v int32) {
|
||||
o.NodeCount = &v
|
||||
}
|
||||
|
||||
// GetNodeList returns the NodeList field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetNodeList() string {
|
||||
if o == nil || IsNil(o.NodeList) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.NodeList
|
||||
}
|
||||
|
||||
// GetNodeListOk returns a tuple with the NodeList field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetNodeListOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.NodeList) {
|
||||
return nil, false
|
||||
}
|
||||
return o.NodeList, true
|
||||
}
|
||||
|
||||
// HasNodeList returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasNodeList() bool {
|
||||
if o != nil && !IsNil(o.NodeList) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetNodeList gets a reference to the given string and assigns it to the NodeList field.
|
||||
func (o *V0037Reservation) SetNodeList(v string) {
|
||||
o.NodeList = &v
|
||||
}
|
||||
|
||||
// GetPartition returns the Partition field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetPartition() string {
|
||||
if o == nil || IsNil(o.Partition) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Partition
|
||||
}
|
||||
|
||||
// GetPartitionOk returns a tuple with the Partition field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetPartitionOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Partition) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Partition, true
|
||||
}
|
||||
|
||||
// HasPartition returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasPartition() bool {
|
||||
if o != nil && !IsNil(o.Partition) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetPartition gets a reference to the given string and assigns it to the Partition field.
|
||||
func (o *V0037Reservation) SetPartition(v string) {
|
||||
o.Partition = &v
|
||||
}
|
||||
|
||||
// GetPurgeCompleted returns the PurgeCompleted field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetPurgeCompleted() V0037ReservationPurgeCompleted {
|
||||
if o == nil || IsNil(o.PurgeCompleted) {
|
||||
var ret V0037ReservationPurgeCompleted
|
||||
return ret
|
||||
}
|
||||
return *o.PurgeCompleted
|
||||
}
|
||||
|
||||
// GetPurgeCompletedOk returns a tuple with the PurgeCompleted field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetPurgeCompletedOk() (*V0037ReservationPurgeCompleted, bool) {
|
||||
if o == nil || IsNil(o.PurgeCompleted) {
|
||||
return nil, false
|
||||
}
|
||||
return o.PurgeCompleted, true
|
||||
}
|
||||
|
||||
// HasPurgeCompleted returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasPurgeCompleted() bool {
|
||||
if o != nil && !IsNil(o.PurgeCompleted) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetPurgeCompleted gets a reference to the given V0037ReservationPurgeCompleted and assigns it to the PurgeCompleted field.
|
||||
func (o *V0037Reservation) SetPurgeCompleted(v V0037ReservationPurgeCompleted) {
|
||||
o.PurgeCompleted = &v
|
||||
}
|
||||
|
||||
// GetStartTime returns the StartTime field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetStartTime() int32 {
|
||||
if o == nil || IsNil(o.StartTime) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.StartTime
|
||||
}
|
||||
|
||||
// GetStartTimeOk returns a tuple with the StartTime field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetStartTimeOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.StartTime) {
|
||||
return nil, false
|
||||
}
|
||||
return o.StartTime, true
|
||||
}
|
||||
|
||||
// HasStartTime returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasStartTime() bool {
|
||||
if o != nil && !IsNil(o.StartTime) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetStartTime gets a reference to the given int32 and assigns it to the StartTime field.
|
||||
func (o *V0037Reservation) SetStartTime(v int32) {
|
||||
o.StartTime = &v
|
||||
}
|
||||
|
||||
// GetWatts returns the Watts field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetWatts() int32 {
|
||||
if o == nil || IsNil(o.Watts) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.Watts
|
||||
}
|
||||
|
||||
// GetWattsOk returns a tuple with the Watts field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetWattsOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.Watts) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Watts, true
|
||||
}
|
||||
|
||||
// HasWatts returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasWatts() bool {
|
||||
if o != nil && !IsNil(o.Watts) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetWatts gets a reference to the given int32 and assigns it to the Watts field.
|
||||
func (o *V0037Reservation) SetWatts(v int32) {
|
||||
o.Watts = &v
|
||||
}
|
||||
|
||||
// GetTres returns the Tres field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetTres() string {
|
||||
if o == nil || IsNil(o.Tres) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Tres
|
||||
}
|
||||
|
||||
// GetTresOk returns a tuple with the Tres field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetTresOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Tres) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Tres, true
|
||||
}
|
||||
|
||||
// HasTres returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasTres() bool {
|
||||
if o != nil && !IsNil(o.Tres) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetTres gets a reference to the given string and assigns it to the Tres field.
|
||||
func (o *V0037Reservation) SetTres(v string) {
|
||||
o.Tres = &v
|
||||
}
|
||||
|
||||
// GetUsers returns the Users field value if set, zero value otherwise.
|
||||
func (o *V0037Reservation) GetUsers() string {
|
||||
if o == nil || IsNil(o.Users) {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
return *o.Users
|
||||
}
|
||||
|
||||
// GetUsersOk returns a tuple with the Users field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037Reservation) GetUsersOk() (*string, bool) {
|
||||
if o == nil || IsNil(o.Users) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Users, true
|
||||
}
|
||||
|
||||
// HasUsers returns a boolean if a field has been set.
|
||||
func (o *V0037Reservation) HasUsers() bool {
|
||||
if o != nil && !IsNil(o.Users) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetUsers gets a reference to the given string and assigns it to the Users field.
|
||||
func (o *V0037Reservation) SetUsers(v string) {
|
||||
o.Users = &v
|
||||
}
|
||||
|
||||
func (o V0037Reservation) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037Reservation) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Accounts) {
|
||||
toSerialize["accounts"] = o.Accounts
|
||||
}
|
||||
if !IsNil(o.BurstBuffer) {
|
||||
toSerialize["burst_buffer"] = o.BurstBuffer
|
||||
}
|
||||
if !IsNil(o.CoreCount) {
|
||||
toSerialize["core_count"] = o.CoreCount
|
||||
}
|
||||
if !IsNil(o.CoreSpecCnt) {
|
||||
toSerialize["core_spec_cnt"] = o.CoreSpecCnt
|
||||
}
|
||||
if !IsNil(o.EndTime) {
|
||||
toSerialize["end_time"] = o.EndTime
|
||||
}
|
||||
if !IsNil(o.Features) {
|
||||
toSerialize["features"] = o.Features
|
||||
}
|
||||
if !IsNil(o.Flags) {
|
||||
toSerialize["flags"] = o.Flags
|
||||
}
|
||||
if !IsNil(o.Groups) {
|
||||
toSerialize["groups"] = o.Groups
|
||||
}
|
||||
if !IsNil(o.Licenses) {
|
||||
toSerialize["licenses"] = o.Licenses
|
||||
}
|
||||
if !IsNil(o.MaxStartDelay) {
|
||||
toSerialize["max_start_delay"] = o.MaxStartDelay
|
||||
}
|
||||
if !IsNil(o.Name) {
|
||||
toSerialize["name"] = o.Name
|
||||
}
|
||||
if !IsNil(o.NodeCount) {
|
||||
toSerialize["node_count"] = o.NodeCount
|
||||
}
|
||||
if !IsNil(o.NodeList) {
|
||||
toSerialize["node_list"] = o.NodeList
|
||||
}
|
||||
if !IsNil(o.Partition) {
|
||||
toSerialize["partition"] = o.Partition
|
||||
}
|
||||
if !IsNil(o.PurgeCompleted) {
|
||||
toSerialize["purge_completed"] = o.PurgeCompleted
|
||||
}
|
||||
if !IsNil(o.StartTime) {
|
||||
toSerialize["start_time"] = o.StartTime
|
||||
}
|
||||
if !IsNil(o.Watts) {
|
||||
toSerialize["watts"] = o.Watts
|
||||
}
|
||||
if !IsNil(o.Tres) {
|
||||
toSerialize["tres"] = o.Tres
|
||||
}
|
||||
if !IsNil(o.Users) {
|
||||
toSerialize["users"] = o.Users
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037Reservation struct {
|
||||
value *V0037Reservation
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037Reservation) Get() *V0037Reservation {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037Reservation) Set(val *V0037Reservation) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037Reservation) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037Reservation) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037Reservation(val *V0037Reservation) *NullableV0037Reservation {
|
||||
return &NullableV0037Reservation{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037Reservation) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037Reservation) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037ReservationPurgeCompleted type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037ReservationPurgeCompleted{}
|
||||
|
||||
// V0037ReservationPurgeCompleted If PURGE_COMP flag is set the amount of seconds this reservation will sit idle until it is revoked
|
||||
type V0037ReservationPurgeCompleted struct {
|
||||
// amount of seconds this reservation will sit idle until it is revoked
|
||||
Time *int32 `json:"time,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037ReservationPurgeCompleted instantiates a new V0037ReservationPurgeCompleted object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037ReservationPurgeCompleted() *V0037ReservationPurgeCompleted {
|
||||
this := V0037ReservationPurgeCompleted{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037ReservationPurgeCompletedWithDefaults instantiates a new V0037ReservationPurgeCompleted object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037ReservationPurgeCompletedWithDefaults() *V0037ReservationPurgeCompleted {
|
||||
this := V0037ReservationPurgeCompleted{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetTime returns the Time field value if set, zero value otherwise.
|
||||
func (o *V0037ReservationPurgeCompleted) GetTime() int32 {
|
||||
if o == nil || IsNil(o.Time) {
|
||||
var ret int32
|
||||
return ret
|
||||
}
|
||||
return *o.Time
|
||||
}
|
||||
|
||||
// GetTimeOk returns a tuple with the Time field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037ReservationPurgeCompleted) GetTimeOk() (*int32, bool) {
|
||||
if o == nil || IsNil(o.Time) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Time, true
|
||||
}
|
||||
|
||||
// HasTime returns a boolean if a field has been set.
|
||||
func (o *V0037ReservationPurgeCompleted) HasTime() bool {
|
||||
if o != nil && !IsNil(o.Time) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetTime gets a reference to the given int32 and assigns it to the Time field.
|
||||
func (o *V0037ReservationPurgeCompleted) SetTime(v int32) {
|
||||
o.Time = &v
|
||||
}
|
||||
|
||||
func (o V0037ReservationPurgeCompleted) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037ReservationPurgeCompleted) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Time) {
|
||||
toSerialize["time"] = o.Time
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037ReservationPurgeCompleted struct {
|
||||
value *V0037ReservationPurgeCompleted
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037ReservationPurgeCompleted) Get() *V0037ReservationPurgeCompleted {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037ReservationPurgeCompleted) Set(val *V0037ReservationPurgeCompleted) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037ReservationPurgeCompleted) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037ReservationPurgeCompleted) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037ReservationPurgeCompleted(val *V0037ReservationPurgeCompleted) *NullableV0037ReservationPurgeCompleted {
|
||||
return &NullableV0037ReservationPurgeCompleted{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037ReservationPurgeCompleted) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037ReservationPurgeCompleted) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// checks if the V0037ReservationsResponse type satisfies the MappedNullable interface at compile time
|
||||
var _ MappedNullable = &V0037ReservationsResponse{}
|
||||
|
||||
// V0037ReservationsResponse struct for V0037ReservationsResponse
|
||||
type V0037ReservationsResponse struct {
|
||||
// slurm errors
|
||||
Errors []V0037Error `json:"errors,omitempty"`
|
||||
// reservation info
|
||||
Reservations []V0037Reservation `json:"reservations,omitempty"`
|
||||
}
|
||||
|
||||
// NewV0037ReservationsResponse instantiates a new V0037ReservationsResponse object
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewV0037ReservationsResponse() *V0037ReservationsResponse {
|
||||
this := V0037ReservationsResponse{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// NewV0037ReservationsResponseWithDefaults instantiates a new V0037ReservationsResponse object
|
||||
// This constructor will only assign default values to properties that have it defined,
|
||||
// but it doesn't guarantee that properties required by API are set
|
||||
func NewV0037ReservationsResponseWithDefaults() *V0037ReservationsResponse {
|
||||
this := V0037ReservationsResponse{}
|
||||
return &this
|
||||
}
|
||||
|
||||
// GetErrors returns the Errors field value if set, zero value otherwise.
|
||||
func (o *V0037ReservationsResponse) GetErrors() []V0037Error {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
var ret []V0037Error
|
||||
return ret
|
||||
}
|
||||
return o.Errors
|
||||
}
|
||||
|
||||
// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037ReservationsResponse) GetErrorsOk() ([]V0037Error, bool) {
|
||||
if o == nil || IsNil(o.Errors) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Errors, true
|
||||
}
|
||||
|
||||
// HasErrors returns a boolean if a field has been set.
|
||||
func (o *V0037ReservationsResponse) HasErrors() bool {
|
||||
if o != nil && !IsNil(o.Errors) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetErrors gets a reference to the given []V0037Error and assigns it to the Errors field.
|
||||
func (o *V0037ReservationsResponse) SetErrors(v []V0037Error) {
|
||||
o.Errors = v
|
||||
}
|
||||
|
||||
// GetReservations returns the Reservations field value if set, zero value otherwise.
|
||||
func (o *V0037ReservationsResponse) GetReservations() []V0037Reservation {
|
||||
if o == nil || IsNil(o.Reservations) {
|
||||
var ret []V0037Reservation
|
||||
return ret
|
||||
}
|
||||
return o.Reservations
|
||||
}
|
||||
|
||||
// GetReservationsOk returns a tuple with the Reservations field value if set, nil otherwise
|
||||
// and a boolean to check if the value has been set.
|
||||
func (o *V0037ReservationsResponse) GetReservationsOk() ([]V0037Reservation, bool) {
|
||||
if o == nil || IsNil(o.Reservations) {
|
||||
return nil, false
|
||||
}
|
||||
return o.Reservations, true
|
||||
}
|
||||
|
||||
// HasReservations returns a boolean if a field has been set.
|
||||
func (o *V0037ReservationsResponse) HasReservations() bool {
|
||||
if o != nil && !IsNil(o.Reservations) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// SetReservations gets a reference to the given []V0037Reservation and assigns it to the Reservations field.
|
||||
func (o *V0037ReservationsResponse) SetReservations(v []V0037Reservation) {
|
||||
o.Reservations = v
|
||||
}
|
||||
|
||||
func (o V0037ReservationsResponse) MarshalJSON() ([]byte, error) {
|
||||
toSerialize,err := o.ToMap()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
return json.Marshal(toSerialize)
|
||||
}
|
||||
|
||||
func (o V0037ReservationsResponse) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
if !IsNil(o.Errors) {
|
||||
toSerialize["errors"] = o.Errors
|
||||
}
|
||||
if !IsNil(o.Reservations) {
|
||||
toSerialize["reservations"] = o.Reservations
|
||||
}
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
type NullableV0037ReservationsResponse struct {
|
||||
value *V0037ReservationsResponse
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037ReservationsResponse) Get() *V0037ReservationsResponse {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037ReservationsResponse) Set(val *V0037ReservationsResponse) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037ReservationsResponse) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037ReservationsResponse) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037ReservationsResponse(val *V0037ReservationsResponse) *NullableV0037ReservationsResponse {
|
||||
return &NullableV0037ReservationsResponse{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037ReservationsResponse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037ReservationsResponse) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// V0037Signal POSIX signal name
|
||||
type V0037Signal int32
|
||||
|
||||
// List of v0.0.37_signal
|
||||
const (
|
||||
HUP V0037Signal = "HUP"
|
||||
INT V0037Signal = "INT"
|
||||
QUIT V0037Signal = "QUIT"
|
||||
ABRT V0037Signal = "ABRT"
|
||||
KILL V0037Signal = "KILL"
|
||||
ALRM V0037Signal = "ALRM"
|
||||
TERM V0037Signal = "TERM"
|
||||
USR1 V0037Signal = "USR1"
|
||||
USR2 V0037Signal = "USR2"
|
||||
URG V0037Signal = "URG"
|
||||
CONT V0037Signal = "CONT"
|
||||
STOP V0037Signal = "STOP"
|
||||
TSTP V0037Signal = "TSTP"
|
||||
TTIN V0037Signal = "TTIN"
|
||||
TTOU V0037Signal = "TTOU"
|
||||
)
|
||||
|
||||
// All allowed values of V0037Signal enum
|
||||
var AllowedV0037SignalEnumValues = []V0037Signal{
|
||||
"HUP",
|
||||
"INT",
|
||||
"QUIT",
|
||||
"ABRT",
|
||||
"KILL",
|
||||
"ALRM",
|
||||
"TERM",
|
||||
"USR1",
|
||||
"USR2",
|
||||
"URG",
|
||||
"CONT",
|
||||
"STOP",
|
||||
"TSTP",
|
||||
"TTIN",
|
||||
"TTOU",
|
||||
}
|
||||
|
||||
func (v *V0037Signal) UnmarshalJSON(src []byte) error {
|
||||
var value int32
|
||||
err := json.Unmarshal(src, &value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
enumTypeValue := V0037Signal(value)
|
||||
for _, existing := range AllowedV0037SignalEnumValues {
|
||||
if existing == enumTypeValue {
|
||||
*v = enumTypeValue
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("%+v is not a valid V0037Signal", value)
|
||||
}
|
||||
|
||||
// NewV0037SignalFromValue returns a pointer to a valid V0037Signal
|
||||
// for the value passed as argument, or an error if the value passed is not allowed by the enum
|
||||
func NewV0037SignalFromValue(v int32) (*V0037Signal, error) {
|
||||
ev := V0037Signal(v)
|
||||
if ev.IsValid() {
|
||||
return &ev, nil
|
||||
} else {
|
||||
return nil, fmt.Errorf("invalid value '%v' for V0037Signal: valid values are %v", v, AllowedV0037SignalEnumValues)
|
||||
}
|
||||
}
|
||||
|
||||
// IsValid return true if the value is valid for the enum, false otherwise
|
||||
func (v V0037Signal) IsValid() bool {
|
||||
for _, existing := range AllowedV0037SignalEnumValues {
|
||||
if existing == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Ptr returns reference to v0.0.37_signal value
|
||||
func (v V0037Signal) Ptr() *V0037Signal {
|
||||
return &v
|
||||
}
|
||||
|
||||
type NullableV0037Signal struct {
|
||||
value *V0037Signal
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableV0037Signal) Get() *V0037Signal {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableV0037Signal) Set(val *V0037Signal) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableV0037Signal) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableV0037Signal) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableV0037Signal(val *V0037Signal) *NullableV0037Signal {
|
||||
return &NullableV0037Signal{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableV0037Signal) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableV0037Signal) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// APIResponse stores the API response returned by the server.
|
||||
type APIResponse struct {
|
||||
*http.Response `json:"-"`
|
||||
Message string `json:"message,omitempty"`
|
||||
// Operation is the name of the OpenAPI operation.
|
||||
Operation string `json:"operation,omitempty"`
|
||||
// RequestURL is the request URL. This value is always available, even if the
|
||||
// embedded *http.Response is nil.
|
||||
RequestURL string `json:"url,omitempty"`
|
||||
// Method is the HTTP method used for the request. This value is always
|
||||
// available, even if the embedded *http.Response is nil.
|
||||
Method string `json:"method,omitempty"`
|
||||
// Payload holds the contents of the response body (which may be nil or empty).
|
||||
// This is provided here as the raw response.Body() reader will have already
|
||||
// been drained.
|
||||
Payload []byte `json:"-"`
|
||||
}
|
||||
|
||||
// NewAPIResponse returns a new APIResponse object.
|
||||
func NewAPIResponse(r *http.Response) *APIResponse {
|
||||
|
||||
response := &APIResponse{Response: r}
|
||||
return response
|
||||
}
|
||||
|
||||
// NewAPIResponseWithError returns a new APIResponse object with the provided error message.
|
||||
func NewAPIResponseWithError(errorMessage string) *APIResponse {
|
||||
|
||||
response := &APIResponse{Message: errorMessage}
|
||||
return response
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
Testing OpenapiAPIService
|
||||
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech);
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func Test_openapi_OpenapiAPIService(t *testing.T) {
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
|
||||
t.Run("Test OpenapiAPIService OpenapiGet", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
httpRes, err := apiClient.OpenapiAPI.OpenapiGet(context.Background()).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test OpenapiAPIService OpenapiJsonGet", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
httpRes, err := apiClient.OpenapiAPI.OpenapiJsonGet(context.Background()).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test OpenapiAPIService OpenapiV3Get", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
httpRes, err := apiClient.OpenapiAPI.OpenapiV3Get(context.Background()).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test OpenapiAPIService OpenapiYamlGet", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
httpRes, err := apiClient.OpenapiAPI.OpenapiYamlGet(context.Background()).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
Testing SlurmAPIService
|
||||
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech);
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
|
||||
)
|
||||
|
||||
func Test_openapi_SlurmAPIService(t *testing.T) {
|
||||
|
||||
configuration := openapiclient.NewConfiguration()
|
||||
apiClient := openapiclient.NewAPIClient(configuration)
|
||||
|
||||
t.Run("Test SlurmAPIService SlurmctldCancelJob", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
var jobId string
|
||||
|
||||
httpRes, err := apiClient.SlurmAPI.SlurmctldCancelJob(context.Background(), jobId).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test SlurmAPIService SlurmctldDiag", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
resp, httpRes, err := apiClient.SlurmAPI.SlurmctldDiag(context.Background()).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test SlurmAPIService SlurmctldGetJob", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
var jobId string
|
||||
|
||||
resp, httpRes, err := apiClient.SlurmAPI.SlurmctldGetJob(context.Background(), jobId).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test SlurmAPIService SlurmctldGetJobs", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
resp, httpRes, err := apiClient.SlurmAPI.SlurmctldGetJobs(context.Background()).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test SlurmAPIService SlurmctldGetNode", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
var nodeName string
|
||||
|
||||
resp, httpRes, err := apiClient.SlurmAPI.SlurmctldGetNode(context.Background(), nodeName).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test SlurmAPIService SlurmctldGetNodes", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
resp, httpRes, err := apiClient.SlurmAPI.SlurmctldGetNodes(context.Background()).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test SlurmAPIService SlurmctldGetPartition", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
var partitionName string
|
||||
|
||||
resp, httpRes, err := apiClient.SlurmAPI.SlurmctldGetPartition(context.Background(), partitionName).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test SlurmAPIService SlurmctldGetPartitions", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
resp, httpRes, err := apiClient.SlurmAPI.SlurmctldGetPartitions(context.Background()).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test SlurmAPIService SlurmctldGetReservation", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
var reservationName string
|
||||
|
||||
resp, httpRes, err := apiClient.SlurmAPI.SlurmctldGetReservation(context.Background(), reservationName).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test SlurmAPIService SlurmctldGetReservations", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
resp, httpRes, err := apiClient.SlurmAPI.SlurmctldGetReservations(context.Background()).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test SlurmAPIService SlurmctldPing", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
resp, httpRes, err := apiClient.SlurmAPI.SlurmctldPing(context.Background()).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test SlurmAPIService SlurmctldSubmitJob", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
resp, httpRes, err := apiClient.SlurmAPI.SlurmctldSubmitJob(context.Background()).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
require.NotNil(t, resp)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
t.Run("Test SlurmAPIService SlurmctldUpdateJob", func(t *testing.T) {
|
||||
|
||||
t.Skip("skip test") // remove to run test
|
||||
|
||||
var jobId string
|
||||
|
||||
httpRes, err := apiClient.SlurmAPI.SlurmctldUpdateJob(context.Background(), jobId).Execute()
|
||||
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, 200, httpRes.StatusCode)
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
@@ -1,348 +0,0 @@
|
||||
/*
|
||||
Slurm Rest API
|
||||
|
||||
API to access and control Slurm.
|
||||
|
||||
API version: 0.0.37
|
||||
Contact: sales@schedmd.com
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package openapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
// PtrBool is a helper routine that returns a pointer to given boolean value.
|
||||
func PtrBool(v bool) *bool { return &v }
|
||||
|
||||
// PtrInt is a helper routine that returns a pointer to given integer value.
|
||||
func PtrInt(v int) *int { return &v }
|
||||
|
||||
// PtrInt32 is a helper routine that returns a pointer to given integer value.
|
||||
func PtrInt32(v int32) *int32 { return &v }
|
||||
|
||||
// PtrInt64 is a helper routine that returns a pointer to given integer value.
|
||||
func PtrInt64(v int64) *int64 { return &v }
|
||||
|
||||
// PtrFloat32 is a helper routine that returns a pointer to given float value.
|
||||
func PtrFloat32(v float32) *float32 { return &v }
|
||||
|
||||
// PtrFloat64 is a helper routine that returns a pointer to given float value.
|
||||
func PtrFloat64(v float64) *float64 { return &v }
|
||||
|
||||
// PtrString is a helper routine that returns a pointer to given string value.
|
||||
func PtrString(v string) *string { return &v }
|
||||
|
||||
// PtrTime is helper routine that returns a pointer to given Time value.
|
||||
func PtrTime(v time.Time) *time.Time { return &v }
|
||||
|
||||
type NullableBool struct {
|
||||
value *bool
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableBool) Get() *bool {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableBool) Set(val *bool) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableBool) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableBool) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableBool(val *bool) *NullableBool {
|
||||
return &NullableBool{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableBool) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableBool) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
type NullableInt struct {
|
||||
value *int
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableInt) Get() *int {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableInt) Set(val *int) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableInt) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableInt) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableInt(val *int) *NullableInt {
|
||||
return &NullableInt{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableInt) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableInt) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
type NullableInt32 struct {
|
||||
value *int32
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableInt32) Get() *int32 {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableInt32) Set(val *int32) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableInt32) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableInt32) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableInt32(val *int32) *NullableInt32 {
|
||||
return &NullableInt32{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableInt32) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableInt32) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
type NullableInt64 struct {
|
||||
value *int64
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableInt64) Get() *int64 {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableInt64) Set(val *int64) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableInt64) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableInt64) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableInt64(val *int64) *NullableInt64 {
|
||||
return &NullableInt64{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableInt64) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableInt64) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
type NullableFloat32 struct {
|
||||
value *float32
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableFloat32) Get() *float32 {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableFloat32) Set(val *float32) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableFloat32) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableFloat32) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableFloat32(val *float32) *NullableFloat32 {
|
||||
return &NullableFloat32{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableFloat32) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableFloat32) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
type NullableFloat64 struct {
|
||||
value *float64
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableFloat64) Get() *float64 {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableFloat64) Set(val *float64) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableFloat64) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableFloat64) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableFloat64(val *float64) *NullableFloat64 {
|
||||
return &NullableFloat64{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableFloat64) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableFloat64) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
type NullableString struct {
|
||||
value *string
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableString) Get() *string {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableString) Set(val *string) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableString) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableString) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableString(val *string) *NullableString {
|
||||
return &NullableString{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableString) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(v.value)
|
||||
}
|
||||
|
||||
func (v *NullableString) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
type NullableTime struct {
|
||||
value *time.Time
|
||||
isSet bool
|
||||
}
|
||||
|
||||
func (v NullableTime) Get() *time.Time {
|
||||
return v.value
|
||||
}
|
||||
|
||||
func (v *NullableTime) Set(val *time.Time) {
|
||||
v.value = val
|
||||
v.isSet = true
|
||||
}
|
||||
|
||||
func (v NullableTime) IsSet() bool {
|
||||
return v.isSet
|
||||
}
|
||||
|
||||
func (v *NullableTime) Unset() {
|
||||
v.value = nil
|
||||
v.isSet = false
|
||||
}
|
||||
|
||||
func NewNullableTime(val *time.Time) *NullableTime {
|
||||
return &NullableTime{value: val, isSet: true}
|
||||
}
|
||||
|
||||
func (v NullableTime) MarshalJSON() ([]byte, error) {
|
||||
return v.value.MarshalJSON()
|
||||
}
|
||||
|
||||
func (v *NullableTime) UnmarshalJSON(src []byte) error {
|
||||
v.isSet = true
|
||||
return json.Unmarshal(src, &v.value)
|
||||
}
|
||||
|
||||
// IsNil checks if an input is nil
|
||||
func IsNil(i interface{}) bool {
|
||||
if i == nil {
|
||||
return true
|
||||
}
|
||||
switch reflect.TypeOf(i).Kind() {
|
||||
case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice:
|
||||
return reflect.ValueOf(i).IsNil()
|
||||
case reflect.Array:
|
||||
return reflect.ValueOf(i).IsZero()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type MappedNullable interface {
|
||||
ToMap() (map[string]interface{}, error)
|
||||
}
|
||||
@@ -39,6 +39,9 @@ func setup(t *testing.T) *api.RestApi {
|
||||
"kind": "file",
|
||||
"path": "./var/job-archive"
|
||||
},
|
||||
"jwts": {
|
||||
"max-age": "2m"
|
||||
},
|
||||
"clusters": [
|
||||
{
|
||||
"name": "testcluster",
|
||||
|
||||
@@ -713,9 +713,367 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/{id}": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Modifies user defined by username (id) in one of four possible ways.\nIf more than one formValue is set then only the highest priority field is used.",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
],
|
||||
"produces": [
|
||||
"text/plain"
|
||||
],
|
||||
"tags": [
|
||||
"add and modify"
|
||||
],
|
||||
"summary": "Updates an existing user",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Database ID of User",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
"admin",
|
||||
"support",
|
||||
"manager",
|
||||
"user",
|
||||
"api"
|
||||
],
|
||||
"type": "string",
|
||||
"description": "Priority 1: Role to add",
|
||||
"name": "add-role",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
"admin",
|
||||
"support",
|
||||
"manager",
|
||||
"user",
|
||||
"api"
|
||||
],
|
||||
"type": "string",
|
||||
"description": "Priority 2: Role to remove",
|
||||
"name": "remove-role",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Priority 3: Project to add",
|
||||
"name": "add-project",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Priority 4: Project to remove",
|
||||
"name": "remove-project",
|
||||
"in": "formData"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success Response Message",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Unprocessable Entity: The user could not be updated",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns a JSON-encoded list of users.\nRequired query-parameter defines if all users or only users with additional special roles are returned.",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"query"
|
||||
],
|
||||
"summary": "Returns a list of users",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "If returned list should contain all users or only users with additional special roles",
|
||||
"name": "not-just-user",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "List of users returned successfully",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/api.ApiReturnedUser"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "User specified in form data will be saved to database.",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
],
|
||||
"produces": [
|
||||
"text/plain"
|
||||
],
|
||||
"tags": [
|
||||
"add and modify"
|
||||
],
|
||||
"summary": "Adds a new user",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Unique user ID",
|
||||
"name": "username",
|
||||
"in": "formData",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "User password",
|
||||
"name": "password",
|
||||
"in": "formData",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
"admin",
|
||||
"support",
|
||||
"manager",
|
||||
"user",
|
||||
"api"
|
||||
],
|
||||
"type": "string",
|
||||
"description": "User role",
|
||||
"name": "role",
|
||||
"in": "formData",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Managed project, required for new manager role user",
|
||||
"name": "project",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Users name",
|
||||
"name": "name",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Users email",
|
||||
"name": "email",
|
||||
"in": "formData"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success Response",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Unprocessable Entity: creating user failed",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "User defined by username in form data will be deleted from database.",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
],
|
||||
"produces": [
|
||||
"text/plain"
|
||||
],
|
||||
"tags": [
|
||||
"remove"
|
||||
],
|
||||
"summary": "Deletes a user",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "User ID to delete",
|
||||
"name": "username",
|
||||
"in": "formData",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "User deleted successfully"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Unprocessable Entity: deleting user failed",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"api.ApiReturnedUser": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"projects": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"roles": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"api.ApiTag": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1372,7 +1730,7 @@ const docTemplate = `{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "The unique DB identifier of a tag\nThe unique DB identifier of a tag",
|
||||
"description": "The unique DB identifier of a tag",
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
@@ -1415,7 +1773,7 @@ const docTemplate = `{
|
||||
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "1",
|
||||
Version: "1.0.0",
|
||||
Host: "localhost:8080",
|
||||
BasePath: "/api",
|
||||
Schemes: []string{},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// Copyright (C) 2023 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
@@ -20,11 +20,13 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/auth"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/config"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/graph"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/importer"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/metricdata"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/repository"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/util"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/archive"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
@@ -76,6 +78,11 @@ func (api *RestApi) MountRoutes(r *mux.Router) {
|
||||
r.HandleFunc("/jobs/delete_job/{id}", api.deleteJobById).Methods(http.MethodDelete)
|
||||
r.HandleFunc("/jobs/delete_job_before/{ts}", api.deleteJobBefore).Methods(http.MethodDelete)
|
||||
|
||||
if api.MachineStateDir != "" {
|
||||
r.HandleFunc("/machine_state/{cluster}/{host}", api.getMachineState).Methods(http.MethodGet)
|
||||
r.HandleFunc("/machine_state/{cluster}/{host}", api.putMachineState).Methods(http.MethodPut, http.MethodPost)
|
||||
}
|
||||
|
||||
if api.Authentication != nil {
|
||||
r.HandleFunc("/jwt/", api.getJWT).Methods(http.MethodGet)
|
||||
r.HandleFunc("/roles/", api.getRoles).Methods(http.MethodGet)
|
||||
@@ -85,11 +92,6 @@ func (api *RestApi) MountRoutes(r *mux.Router) {
|
||||
r.HandleFunc("/user/{id}", api.updateUser).Methods(http.MethodPost)
|
||||
r.HandleFunc("/configuration/", api.updateConfiguration).Methods(http.MethodPost)
|
||||
}
|
||||
|
||||
if api.MachineStateDir != "" {
|
||||
r.HandleFunc("/machine_state/{cluster}/{host}", api.getMachineState).Methods(http.MethodGet)
|
||||
r.HandleFunc("/machine_state/{cluster}/{host}", api.putMachineState).Methods(http.MethodPut, http.MethodPost)
|
||||
}
|
||||
}
|
||||
|
||||
// StartJobApiResponse model
|
||||
@@ -103,6 +105,11 @@ type DeleteJobApiResponse struct {
|
||||
Message string `json:"msg"`
|
||||
}
|
||||
|
||||
// UpdateUserApiResponse model
|
||||
type UpdateUserApiResponse struct {
|
||||
Message string `json:"msg"`
|
||||
}
|
||||
|
||||
// StopJobApiRequest model
|
||||
type StopJobApiRequest struct {
|
||||
// Stop Time of job as epoch
|
||||
@@ -156,6 +163,14 @@ type JobMetricWithName struct {
|
||||
Metric *schema.JobMetric `json:"metric"`
|
||||
}
|
||||
|
||||
type ApiReturnedUser struct {
|
||||
Username string `json:"username"`
|
||||
Name string `json:"name"`
|
||||
Roles []string `json:"roles"`
|
||||
Email string `json:"email"`
|
||||
Projects []string `json:"projects"`
|
||||
}
|
||||
|
||||
func handleError(err error, statusCode int, rw http.ResponseWriter) {
|
||||
log.Warnf("REST ERROR : %s", err.Error())
|
||||
rw.Header().Add("Content-Type", "application/json")
|
||||
@@ -172,6 +187,40 @@ func decode(r io.Reader, val interface{}) error {
|
||||
return dec.Decode(val)
|
||||
}
|
||||
|
||||
func securedCheck(r *http.Request) error {
|
||||
user := repository.GetUserFromContext(r.Context())
|
||||
if user == nil {
|
||||
return fmt.Errorf("no user in context")
|
||||
}
|
||||
|
||||
if user.AuthType == schema.AuthToken {
|
||||
// If nothing declared in config: deny all request to this endpoint
|
||||
if config.Keys.ApiAllowedIPs == nil || len(config.Keys.ApiAllowedIPs) == 0 {
|
||||
return fmt.Errorf("missing configuration key ApiAllowedIPs")
|
||||
}
|
||||
|
||||
if config.Keys.ApiAllowedIPs[0] == "*" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// extract IP address
|
||||
IPAddress := r.Header.Get("X-Real-Ip")
|
||||
if IPAddress == "" {
|
||||
IPAddress = r.Header.Get("X-Forwarded-For")
|
||||
}
|
||||
if IPAddress == "" {
|
||||
IPAddress = r.RemoteAddr
|
||||
}
|
||||
|
||||
// check if IP is allowed
|
||||
if !util.Contains(config.Keys.ApiAllowedIPs, IPAddress) {
|
||||
return fmt.Errorf("unknown ip: %v", IPAddress)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// getJobs godoc
|
||||
// @summary Lists all jobs
|
||||
// @tags query
|
||||
@@ -193,8 +242,10 @@ func decode(r io.Reader, val interface{}) error {
|
||||
// @router /jobs/ [get]
|
||||
func (api *RestApi) getJobs(rw http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if user := auth.GetUser(r.Context()); user != nil && !user.HasRole(auth.RoleApi) {
|
||||
handleError(fmt.Errorf("missing role: %v", auth.GetRoleString(auth.RoleApi)), http.StatusForbidden, rw)
|
||||
if user := repository.GetUserFromContext(r.Context()); user != nil &&
|
||||
!user.HasRole(schema.RoleApi) {
|
||||
|
||||
handleError(fmt.Errorf("missing role: %v", schema.GetRoleString(schema.RoleApi)), http.StatusForbidden, rw)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -335,9 +386,11 @@ func (api *RestApi) getJobs(rw http.ResponseWriter, r *http.Request) {
|
||||
// @security ApiKeyAuth
|
||||
// @router /jobs/{id} [post]
|
||||
func (api *RestApi) getJobById(rw http.ResponseWriter, r *http.Request) {
|
||||
if user := auth.GetUser(r.Context()); user != nil && !user.HasRole(auth.RoleApi) {
|
||||
if user := repository.GetUserFromContext(r.Context()); user != nil &&
|
||||
!user.HasRole(schema.RoleApi) {
|
||||
|
||||
handleError(fmt.Errorf("missing role: %v",
|
||||
auth.GetRoleString(auth.RoleApi)), http.StatusForbidden, rw)
|
||||
schema.GetRoleString(schema.RoleApi)), http.StatusForbidden, rw)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -426,8 +479,10 @@ func (api *RestApi) getJobById(rw http.ResponseWriter, r *http.Request) {
|
||||
// @security ApiKeyAuth
|
||||
// @router /jobs/tag_job/{id} [post]
|
||||
func (api *RestApi) tagJob(rw http.ResponseWriter, r *http.Request) {
|
||||
if user := auth.GetUser(r.Context()); user != nil && !user.HasRole(auth.RoleApi) {
|
||||
handleError(fmt.Errorf("missing role: %v", auth.GetRoleString(auth.RoleApi)), http.StatusForbidden, rw)
|
||||
if user := repository.GetUserFromContext(r.Context()); user != nil &&
|
||||
!user.HasRole(schema.RoleApi) {
|
||||
|
||||
handleError(fmt.Errorf("missing role: %v", schema.GetRoleString(schema.RoleApi)), http.StatusForbidden, rw)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -491,8 +546,10 @@ func (api *RestApi) tagJob(rw http.ResponseWriter, r *http.Request) {
|
||||
// @security ApiKeyAuth
|
||||
// @router /jobs/start_job/ [post]
|
||||
func (api *RestApi) startJob(rw http.ResponseWriter, r *http.Request) {
|
||||
if user := auth.GetUser(r.Context()); user != nil && !user.HasRole(auth.RoleApi) {
|
||||
handleError(fmt.Errorf("missing role: %v", auth.GetRoleString(auth.RoleApi)), http.StatusForbidden, rw)
|
||||
if user := repository.GetUserFromContext(r.Context()); user != nil &&
|
||||
!user.HasRole(schema.RoleApi) {
|
||||
|
||||
handleError(fmt.Errorf("missing role: %v", schema.GetRoleString(schema.RoleApi)), http.StatusForbidden, rw)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -572,8 +629,10 @@ func (api *RestApi) startJob(rw http.ResponseWriter, r *http.Request) {
|
||||
// @security ApiKeyAuth
|
||||
// @router /jobs/stop_job/{id} [post]
|
||||
func (api *RestApi) stopJobById(rw http.ResponseWriter, r *http.Request) {
|
||||
if user := auth.GetUser(r.Context()); user != nil && !user.HasRole(auth.RoleApi) {
|
||||
handleError(fmt.Errorf("missing role: %v", auth.GetRoleString(auth.RoleApi)), http.StatusForbidden, rw)
|
||||
if user := repository.GetUserFromContext(r.Context()); user != nil &&
|
||||
!user.HasRole(schema.RoleApi) {
|
||||
|
||||
handleError(fmt.Errorf("missing role: %v", schema.GetRoleString(schema.RoleApi)), http.StatusForbidden, rw)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -625,8 +684,10 @@ func (api *RestApi) stopJobById(rw http.ResponseWriter, r *http.Request) {
|
||||
// @security ApiKeyAuth
|
||||
// @router /jobs/stop_job/ [post]
|
||||
func (api *RestApi) stopJobByRequest(rw http.ResponseWriter, r *http.Request) {
|
||||
if user := auth.GetUser(r.Context()); user != nil && !user.HasRole(auth.RoleApi) {
|
||||
handleError(fmt.Errorf("missing role: %v", auth.GetRoleString(auth.RoleApi)), http.StatusForbidden, rw)
|
||||
if user := repository.GetUserFromContext(r.Context()); user != nil &&
|
||||
!user.HasRole(schema.RoleApi) {
|
||||
|
||||
handleError(fmt.Errorf("missing role: %v", schema.GetRoleString(schema.RoleApi)), http.StatusForbidden, rw)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -671,8 +732,8 @@ func (api *RestApi) stopJobByRequest(rw http.ResponseWriter, r *http.Request) {
|
||||
// @security ApiKeyAuth
|
||||
// @router /jobs/delete_job/{id} [delete]
|
||||
func (api *RestApi) deleteJobById(rw http.ResponseWriter, r *http.Request) {
|
||||
if user := auth.GetUser(r.Context()); user != nil && !user.HasRole(auth.RoleApi) {
|
||||
handleError(fmt.Errorf("missing role: %v", auth.GetRoleString(auth.RoleApi)), http.StatusForbidden, rw)
|
||||
if user := repository.GetUserFromContext(r.Context()); user != nil && !user.HasRole(schema.RoleApi) {
|
||||
handleError(fmt.Errorf("missing role: %v", schema.GetRoleString(schema.RoleApi)), http.StatusForbidden, rw)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -719,8 +780,9 @@ func (api *RestApi) deleteJobById(rw http.ResponseWriter, r *http.Request) {
|
||||
// @security ApiKeyAuth
|
||||
// @router /jobs/delete_job/ [delete]
|
||||
func (api *RestApi) deleteJobByRequest(rw http.ResponseWriter, r *http.Request) {
|
||||
if user := auth.GetUser(r.Context()); user != nil && !user.HasRole(auth.RoleApi) {
|
||||
handleError(fmt.Errorf("missing role: %v", auth.GetRoleString(auth.RoleApi)), http.StatusForbidden, rw)
|
||||
if user := repository.GetUserFromContext(r.Context()); user != nil &&
|
||||
!user.HasRole(schema.RoleApi) {
|
||||
handleError(fmt.Errorf("missing role: %v", schema.GetRoleString(schema.RoleApi)), http.StatusForbidden, rw)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -775,8 +837,8 @@ func (api *RestApi) deleteJobByRequest(rw http.ResponseWriter, r *http.Request)
|
||||
// @security ApiKeyAuth
|
||||
// @router /jobs/delete_job_before/{ts} [delete]
|
||||
func (api *RestApi) deleteJobBefore(rw http.ResponseWriter, r *http.Request) {
|
||||
if user := auth.GetUser(r.Context()); user != nil && !user.HasRole(auth.RoleApi) {
|
||||
handleError(fmt.Errorf("missing role: %v", auth.GetRoleString(auth.RoleApi)), http.StatusForbidden, rw)
|
||||
if user := repository.GetUserFromContext(r.Context()); user != nil && !user.HasRole(schema.RoleApi) {
|
||||
handleError(fmt.Errorf("missing role: %v", schema.GetRoleString(schema.RoleApi)), http.StatusForbidden, rw)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -891,11 +953,223 @@ func (api *RestApi) getJobMetrics(rw http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
// createUser godoc
|
||||
// @summary Adds a new user
|
||||
// @tags add and modify
|
||||
// @description User specified in form data will be saved to database.
|
||||
// @accept mpfd
|
||||
// @produce plain
|
||||
// @param username formData string true "Unique user ID"
|
||||
// @param password formData string true "User password"
|
||||
// @param role formData string true "User role" Enums(admin, support, manager, user, api)
|
||||
// @param project formData string false "Managed project, required for new manager role user"
|
||||
// @param name formData string false "Users name"
|
||||
// @param email formData string false "Users email"
|
||||
// @success 200 {string} string "Success Response"
|
||||
// @failure 400 {string} string "Bad Request"
|
||||
// @failure 401 {string} string "Unauthorized"
|
||||
// @failure 403 {string} string "Forbidden"
|
||||
// @failure 422 {string} string "Unprocessable Entity: creating user failed"
|
||||
// @failure 500 {string} string "Internal Server Error"
|
||||
// @security ApiKeyAuth
|
||||
// @router /users/ [post]
|
||||
func (api *RestApi) createUser(rw http.ResponseWriter, r *http.Request) {
|
||||
err := securedCheck(r)
|
||||
if err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
rw.Header().Set("Content-Type", "text/plain")
|
||||
me := repository.GetUserFromContext(r.Context())
|
||||
if !me.HasRole(schema.RoleAdmin) {
|
||||
http.Error(rw, "Only admins are allowed to create new users", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
username, password, role, name, email, project := r.FormValue("username"),
|
||||
r.FormValue("password"), r.FormValue("role"), r.FormValue("name"),
|
||||
r.FormValue("email"), r.FormValue("project")
|
||||
|
||||
if len(password) == 0 && role != schema.GetRoleString(schema.RoleApi) {
|
||||
http.Error(rw, "Only API users are allowed to have a blank password (login will be impossible)", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if len(project) != 0 && role != schema.GetRoleString(schema.RoleManager) {
|
||||
http.Error(rw, "only managers require a project (can be changed later)",
|
||||
http.StatusBadRequest)
|
||||
return
|
||||
} else if len(project) == 0 && role == schema.GetRoleString(schema.RoleManager) {
|
||||
http.Error(rw, "managers require a project to manage (can be changed later)",
|
||||
http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if err := repository.GetUserRepository().AddUser(&schema.User{
|
||||
Username: username,
|
||||
Name: name,
|
||||
Password: password,
|
||||
Email: email,
|
||||
Projects: []string{project},
|
||||
Roles: []string{role}}); err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
|
||||
rw.Write([]byte(fmt.Sprintf("User %v successfully created!\n", username)))
|
||||
}
|
||||
|
||||
// deleteUser godoc
|
||||
// @summary Deletes a user
|
||||
// @tags remove
|
||||
// @description User defined by username in form data will be deleted from database.
|
||||
// @accept mpfd
|
||||
// @produce plain
|
||||
// @param username formData string true "User ID to delete"
|
||||
// @success 200 "User deleted successfully"
|
||||
// @failure 400 {string} string "Bad Request"
|
||||
// @failure 401 {string} string "Unauthorized"
|
||||
// @failure 403 {string} string "Forbidden"
|
||||
// @failure 422 {string} string "Unprocessable Entity: deleting user failed"
|
||||
// @failure 500 {string} string "Internal Server Error"
|
||||
// @security ApiKeyAuth
|
||||
// @router /users/ [delete]
|
||||
func (api *RestApi) deleteUser(rw http.ResponseWriter, r *http.Request) {
|
||||
err := securedCheck(r)
|
||||
if err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
if user := repository.GetUserFromContext(r.Context()); !user.HasRole(schema.RoleAdmin) {
|
||||
http.Error(rw, "Only admins are allowed to delete a user", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
username := r.FormValue("username")
|
||||
if err := repository.GetUserRepository().DelUser(username); err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
|
||||
rw.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
// getUsers godoc
|
||||
// @summary Returns a list of users
|
||||
// @tags query
|
||||
// @description Returns a JSON-encoded list of users.
|
||||
// @description Required query-parameter defines if all users or only users with additional special roles are returned.
|
||||
// @produce json
|
||||
// @param not-just-user query bool true "If returned list should contain all users or only users with additional special roles"
|
||||
// @success 200 {array} api.ApiReturnedUser "List of users returned successfully"
|
||||
// @failure 400 {string} string "Bad Request"
|
||||
// @failure 401 {string} string "Unauthorized"
|
||||
// @failure 403 {string} string "Forbidden"
|
||||
// @failure 500 {string} string "Internal Server Error"
|
||||
// @security ApiKeyAuth
|
||||
// @router /users/ [get]
|
||||
func (api *RestApi) getUsers(rw http.ResponseWriter, r *http.Request) {
|
||||
err := securedCheck(r)
|
||||
if err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
if user := repository.GetUserFromContext(r.Context()); !user.HasRole(schema.RoleAdmin) {
|
||||
http.Error(rw, "Only admins are allowed to fetch a list of users", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
users, err := repository.GetUserRepository().ListUsers(r.URL.Query().Get("not-just-user") == "true")
|
||||
if err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
json.NewEncoder(rw).Encode(users)
|
||||
}
|
||||
|
||||
// updateUser godoc
|
||||
// @summary Updates an existing user
|
||||
// @tags add and modify
|
||||
// @description Modifies user defined by username (id) in one of four possible ways.
|
||||
// @description If more than one formValue is set then only the highest priority field is used.
|
||||
// @accept mpfd
|
||||
// @produce plain
|
||||
// @param id path string true "Database ID of User"
|
||||
// @param add-role formData string false "Priority 1: Role to add" Enums(admin, support, manager, user, api)
|
||||
// @param remove-role formData string false "Priority 2: Role to remove" Enums(admin, support, manager, user, api)
|
||||
// @param add-project formData string false "Priority 3: Project to add"
|
||||
// @param remove-project formData string false "Priority 4: Project to remove"
|
||||
// @success 200 {string} string "Success Response Message"
|
||||
// @failure 400 {string} string "Bad Request"
|
||||
// @failure 401 {string} string "Unauthorized"
|
||||
// @failure 403 {string} string "Forbidden"
|
||||
// @failure 422 {string} string "Unprocessable Entity: The user could not be updated"
|
||||
// @failure 500 {string} string "Internal Server Error"
|
||||
// @security ApiKeyAuth
|
||||
// @router /user/{id} [post]
|
||||
func (api *RestApi) updateUser(rw http.ResponseWriter, r *http.Request) {
|
||||
err := securedCheck(r)
|
||||
if err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
if user := repository.GetUserFromContext(r.Context()); !user.HasRole(schema.RoleAdmin) {
|
||||
http.Error(rw, "Only admins are allowed to update a user", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
// Get Values
|
||||
newrole := r.FormValue("add-role")
|
||||
delrole := r.FormValue("remove-role")
|
||||
newproj := r.FormValue("add-project")
|
||||
delproj := r.FormValue("remove-project")
|
||||
|
||||
// TODO: Handle anything but roles...
|
||||
if newrole != "" {
|
||||
if err := repository.GetUserRepository().AddRole(r.Context(), mux.Vars(r)["id"], newrole); err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
rw.Write([]byte("Add Role Success"))
|
||||
} else if delrole != "" {
|
||||
if err := repository.GetUserRepository().RemoveRole(r.Context(), mux.Vars(r)["id"], delrole); err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
rw.Write([]byte("Remove Role Success"))
|
||||
} else if newproj != "" {
|
||||
if err := repository.GetUserRepository().AddProject(r.Context(), mux.Vars(r)["id"], newproj); err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
rw.Write([]byte("Add Project Success"))
|
||||
} else if delproj != "" {
|
||||
if err := repository.GetUserRepository().RemoveProject(r.Context(), mux.Vars(r)["id"], delproj); err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
rw.Write([]byte("Remove Project Success"))
|
||||
} else {
|
||||
http.Error(rw, "Not Add or Del [role|project]?", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
func (api *RestApi) getJWT(rw http.ResponseWriter, r *http.Request) {
|
||||
err := securedCheck(r)
|
||||
if err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
rw.Header().Set("Content-Type", "text/plain")
|
||||
username := r.FormValue("username")
|
||||
me := auth.GetUser(r.Context())
|
||||
if !me.HasRole(auth.RoleAdmin) {
|
||||
me := repository.GetUserFromContext(r.Context())
|
||||
if !me.HasRole(schema.RoleAdmin) {
|
||||
if username != me.Username {
|
||||
http.Error(rw, "Only admins are allowed to sign JWTs not for themselves",
|
||||
http.StatusForbidden)
|
||||
@@ -903,7 +1177,7 @@ func (api *RestApi) getJWT(rw http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
user, err := api.Authentication.GetUser(username)
|
||||
user, err := repository.GetUserRepository().GetUser(username)
|
||||
if err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
@@ -919,80 +1193,20 @@ func (api *RestApi) getJWT(rw http.ResponseWriter, r *http.Request) {
|
||||
rw.Write([]byte(jwt))
|
||||
}
|
||||
|
||||
func (api *RestApi) createUser(rw http.ResponseWriter, r *http.Request) {
|
||||
rw.Header().Set("Content-Type", "text/plain")
|
||||
me := auth.GetUser(r.Context())
|
||||
if !me.HasRole(auth.RoleAdmin) {
|
||||
http.Error(rw, "Only admins are allowed to create new users", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
username, password, role, name, email, project := r.FormValue("username"), r.FormValue("password"), r.FormValue("role"), r.FormValue("name"), r.FormValue("email"), r.FormValue("project")
|
||||
if len(password) == 0 && role != auth.GetRoleString(auth.RoleApi) {
|
||||
http.Error(rw, "Only API users are allowed to have a blank password (login will be impossible)", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if len(project) != 0 && role != auth.GetRoleString(auth.RoleManager) {
|
||||
http.Error(rw, "only managers require a project (can be changed later)", http.StatusBadRequest)
|
||||
return
|
||||
} else if len(project) == 0 && role == auth.GetRoleString(auth.RoleManager) {
|
||||
http.Error(rw, "managers require a project to manage (can be changed later)", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if err := api.Authentication.AddUser(&auth.User{
|
||||
Username: username,
|
||||
Name: name,
|
||||
Password: password,
|
||||
Email: email,
|
||||
Projects: []string{project},
|
||||
Roles: []string{role}}); err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
|
||||
rw.Write([]byte(fmt.Sprintf("User %v successfully created!\n", username)))
|
||||
}
|
||||
|
||||
func (api *RestApi) deleteUser(rw http.ResponseWriter, r *http.Request) {
|
||||
if user := auth.GetUser(r.Context()); !user.HasRole(auth.RoleAdmin) {
|
||||
http.Error(rw, "Only admins are allowed to delete a user", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
username := r.FormValue("username")
|
||||
if err := api.Authentication.DelUser(username); err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
|
||||
rw.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
func (api *RestApi) getUsers(rw http.ResponseWriter, r *http.Request) {
|
||||
if user := auth.GetUser(r.Context()); !user.HasRole(auth.RoleAdmin) {
|
||||
http.Error(rw, "Only admins are allowed to fetch a list of users", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
users, err := api.Authentication.ListUsers(r.URL.Query().Get("not-just-user") == "true")
|
||||
if err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
json.NewEncoder(rw).Encode(users)
|
||||
}
|
||||
|
||||
func (api *RestApi) getRoles(rw http.ResponseWriter, r *http.Request) {
|
||||
user := auth.GetUser(r.Context())
|
||||
if !user.HasRole(auth.RoleAdmin) {
|
||||
err := securedCheck(r)
|
||||
if err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
user := repository.GetUserFromContext(r.Context())
|
||||
if !user.HasRole(schema.RoleAdmin) {
|
||||
http.Error(rw, "only admins are allowed to fetch a list of roles", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
roles, err := auth.GetValidRoles(user)
|
||||
roles, err := schema.GetValidRoles(user)
|
||||
if err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@@ -1001,55 +1215,13 @@ func (api *RestApi) getRoles(rw http.ResponseWriter, r *http.Request) {
|
||||
json.NewEncoder(rw).Encode(roles)
|
||||
}
|
||||
|
||||
func (api *RestApi) updateUser(rw http.ResponseWriter, r *http.Request) {
|
||||
if user := auth.GetUser(r.Context()); !user.HasRole(auth.RoleAdmin) {
|
||||
http.Error(rw, "Only admins are allowed to update a user", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
// Get Values
|
||||
newrole := r.FormValue("add-role")
|
||||
delrole := r.FormValue("remove-role")
|
||||
newproj := r.FormValue("add-project")
|
||||
delproj := r.FormValue("remove-project")
|
||||
|
||||
// TODO: Handle anything but roles...
|
||||
if newrole != "" {
|
||||
if err := api.Authentication.AddRole(r.Context(), mux.Vars(r)["id"], newrole); err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
rw.Write([]byte("Add Role Success"))
|
||||
} else if delrole != "" {
|
||||
if err := api.Authentication.RemoveRole(r.Context(), mux.Vars(r)["id"], delrole); err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
rw.Write([]byte("Remove Role Success"))
|
||||
} else if newproj != "" {
|
||||
if err := api.Authentication.AddProject(r.Context(), mux.Vars(r)["id"], newproj); err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
rw.Write([]byte("Add Project Success"))
|
||||
} else if delproj != "" {
|
||||
if err := api.Authentication.RemoveProject(r.Context(), mux.Vars(r)["id"], delproj); err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
rw.Write([]byte("Remove Project Success"))
|
||||
} else {
|
||||
http.Error(rw, "Not Add or Del [role|project]?", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
func (api *RestApi) updateConfiguration(rw http.ResponseWriter, r *http.Request) {
|
||||
rw.Header().Set("Content-Type", "text/plain")
|
||||
key, value := r.FormValue("key"), r.FormValue("value")
|
||||
|
||||
fmt.Printf("REST > KEY: %#v\nVALUE: %#v\n", key, value)
|
||||
|
||||
if err := repository.GetUserCfgRepo().UpdateConfig(key, value, auth.GetUser(r.Context())); err != nil {
|
||||
if err := repository.GetUserCfgRepo().UpdateConfig(key, value, repository.GetUserFromContext(r.Context())); err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// Copyright (C) 2023 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
@@ -7,224 +7,26 @@ package auth
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"database/sql"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/config"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/repository"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
type AuthSource int
|
||||
|
||||
const (
|
||||
AuthViaLocalPassword AuthSource = iota
|
||||
AuthViaLDAP
|
||||
AuthViaToken
|
||||
)
|
||||
|
||||
type User struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"-"`
|
||||
Name string `json:"name"`
|
||||
Roles []string `json:"roles"`
|
||||
AuthSource AuthSource `json:"via"`
|
||||
Email string `json:"email"`
|
||||
Projects []string `json:"projects"`
|
||||
Expiration time.Time
|
||||
}
|
||||
|
||||
type Role int
|
||||
|
||||
const (
|
||||
RoleAnonymous Role = iota
|
||||
RoleApi
|
||||
RoleUser
|
||||
RoleManager
|
||||
RoleSupport
|
||||
RoleAdmin
|
||||
RoleError
|
||||
)
|
||||
|
||||
func GetRoleString(roleInt Role) string {
|
||||
return [6]string{"anonymous", "api", "user", "manager", "support", "admin"}[roleInt]
|
||||
}
|
||||
|
||||
func getRoleEnum(roleStr string) Role {
|
||||
switch strings.ToLower(roleStr) {
|
||||
case "admin":
|
||||
return RoleAdmin
|
||||
case "support":
|
||||
return RoleSupport
|
||||
case "manager":
|
||||
return RoleManager
|
||||
case "user":
|
||||
return RoleUser
|
||||
case "api":
|
||||
return RoleApi
|
||||
case "anonymous":
|
||||
return RoleAnonymous
|
||||
default:
|
||||
return RoleError
|
||||
}
|
||||
}
|
||||
|
||||
func isValidRole(role string) bool {
|
||||
return getRoleEnum(role) != RoleError
|
||||
}
|
||||
|
||||
func (u *User) HasValidRole(role string) (hasRole bool, isValid bool) {
|
||||
if isValidRole(role) {
|
||||
for _, r := range u.Roles {
|
||||
if r == role {
|
||||
return true, true
|
||||
}
|
||||
}
|
||||
return false, true
|
||||
}
|
||||
return false, false
|
||||
}
|
||||
|
||||
func (u *User) HasRole(role Role) bool {
|
||||
for _, r := range u.Roles {
|
||||
if r == GetRoleString(role) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Role-Arrays are short: performance not impacted by nested loop
|
||||
func (u *User) HasAnyRole(queryroles []Role) bool {
|
||||
for _, ur := range u.Roles {
|
||||
for _, qr := range queryroles {
|
||||
if ur == GetRoleString(qr) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Role-Arrays are short: performance not impacted by nested loop
|
||||
func (u *User) HasAllRoles(queryroles []Role) bool {
|
||||
target := len(queryroles)
|
||||
matches := 0
|
||||
for _, ur := range u.Roles {
|
||||
for _, qr := range queryroles {
|
||||
if ur == GetRoleString(qr) {
|
||||
matches += 1
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if matches == target {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Role-Arrays are short: performance not impacted by nested loop
|
||||
func (u *User) HasNotRoles(queryroles []Role) bool {
|
||||
matches := 0
|
||||
for _, ur := range u.Roles {
|
||||
for _, qr := range queryroles {
|
||||
if ur == GetRoleString(qr) {
|
||||
matches += 1
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if matches == 0 {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Called by API endpoint '/roles/' from frontend: Only required for admin config -> Check Admin Role
|
||||
func GetValidRoles(user *User) ([]string, error) {
|
||||
var vals []string
|
||||
if user.HasRole(RoleAdmin) {
|
||||
for i := RoleApi; i < RoleError; i++ {
|
||||
vals = append(vals, GetRoleString(i))
|
||||
}
|
||||
return vals, nil
|
||||
}
|
||||
|
||||
return vals, fmt.Errorf("%s: only admins are allowed to fetch a list of roles", user.Username)
|
||||
}
|
||||
|
||||
// Called by routerConfig web.page setup in backend: Only requires known user
|
||||
func GetValidRolesMap(user *User) (map[string]Role, error) {
|
||||
named := make(map[string]Role)
|
||||
if user.HasNotRoles([]Role{RoleAnonymous}) {
|
||||
for i := RoleApi; i < RoleError; i++ {
|
||||
named[GetRoleString(i)] = i
|
||||
}
|
||||
return named, nil
|
||||
}
|
||||
return named, fmt.Errorf("only known users are allowed to fetch a list of roles")
|
||||
}
|
||||
|
||||
// Find highest role
|
||||
func (u *User) GetAuthLevel() Role {
|
||||
if u.HasRole(RoleAdmin) {
|
||||
return RoleAdmin
|
||||
} else if u.HasRole(RoleSupport) {
|
||||
return RoleSupport
|
||||
} else if u.HasRole(RoleManager) {
|
||||
return RoleManager
|
||||
} else if u.HasRole(RoleUser) {
|
||||
return RoleUser
|
||||
} else if u.HasRole(RoleApi) {
|
||||
return RoleApi
|
||||
} else if u.HasRole(RoleAnonymous) {
|
||||
return RoleAnonymous
|
||||
} else {
|
||||
return RoleError
|
||||
}
|
||||
}
|
||||
|
||||
func (u *User) HasProject(project string) bool {
|
||||
for _, p := range u.Projects {
|
||||
if p == project {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func GetUser(ctx context.Context) *User {
|
||||
x := ctx.Value(ContextUserKey)
|
||||
if x == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return x.(*User)
|
||||
}
|
||||
|
||||
type Authenticator interface {
|
||||
Init(auth *Authentication, config interface{}) error
|
||||
CanLogin(user *User, rw http.ResponseWriter, r *http.Request) bool
|
||||
Login(user *User, rw http.ResponseWriter, r *http.Request) (*User, error)
|
||||
Auth(rw http.ResponseWriter, r *http.Request) (*User, error)
|
||||
CanLogin(user *schema.User, username string, rw http.ResponseWriter, r *http.Request) (*schema.User, bool)
|
||||
Login(user *schema.User, rw http.ResponseWriter, r *http.Request) (*schema.User, error)
|
||||
}
|
||||
|
||||
type ContextKey string
|
||||
|
||||
const ContextUserKey ContextKey = "user"
|
||||
|
||||
type Authentication struct {
|
||||
db *sqlx.DB
|
||||
sessionStore *sessions.CookieStore
|
||||
SessionMaxAge time.Duration
|
||||
|
||||
@@ -234,10 +36,34 @@ type Authentication struct {
|
||||
LocalAuth *LocalAuthenticator
|
||||
}
|
||||
|
||||
func Init(db *sqlx.DB,
|
||||
configs map[string]interface{}) (*Authentication, error) {
|
||||
func (auth *Authentication) AuthViaSession(
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) (*schema.User, error) {
|
||||
session, err := auth.sessionStore.Get(r, "session")
|
||||
if err != nil {
|
||||
log.Error("Error while getting session store")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if session.IsNew {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// TODO: Check if session keys exist
|
||||
username, _ := session.Values["username"].(string)
|
||||
projects, _ := session.Values["projects"].([]string)
|
||||
roles, _ := session.Values["roles"].([]string)
|
||||
return &schema.User{
|
||||
Username: username,
|
||||
Projects: projects,
|
||||
Roles: roles,
|
||||
AuthType: schema.AuthSession,
|
||||
AuthSource: -1,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func Init() (*Authentication, error) {
|
||||
auth := &Authentication{}
|
||||
auth.db = db
|
||||
|
||||
sessKey := os.Getenv("SESSION_KEY")
|
||||
if sessKey == "" {
|
||||
@@ -257,78 +83,78 @@ func Init(db *sqlx.DB,
|
||||
auth.sessionStore = sessions.NewCookieStore(bytes)
|
||||
}
|
||||
|
||||
if config.Keys.LdapConfig != nil {
|
||||
ldapAuth := &LdapAuthenticator{}
|
||||
if err := ldapAuth.Init(); err != nil {
|
||||
log.Warn("Error while initializing authentication -> ldapAuth init failed")
|
||||
} else {
|
||||
auth.LdapAuth = ldapAuth
|
||||
auth.authenticators = append(auth.authenticators, auth.LdapAuth)
|
||||
}
|
||||
} else {
|
||||
log.Info("Missing LDAP configuration: No LDAP support!")
|
||||
}
|
||||
|
||||
if config.Keys.JwtConfig != nil {
|
||||
auth.JwtAuth = &JWTAuthenticator{}
|
||||
if err := auth.JwtAuth.Init(); err != nil {
|
||||
log.Error("Error while initializing authentication -> jwtAuth init failed")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
jwtSessionAuth := &JWTSessionAuthenticator{}
|
||||
if err := jwtSessionAuth.Init(); err != nil {
|
||||
log.Info("jwtSessionAuth init failed: No JWT login support!")
|
||||
} else {
|
||||
auth.authenticators = append(auth.authenticators, jwtSessionAuth)
|
||||
}
|
||||
|
||||
jwtCookieSessionAuth := &JWTCookieSessionAuthenticator{}
|
||||
if err := jwtCookieSessionAuth.Init(); err != nil {
|
||||
log.Info("jwtCookieSessionAuth init failed: No JWT cookie login support!")
|
||||
} else {
|
||||
auth.authenticators = append(auth.authenticators, jwtCookieSessionAuth)
|
||||
}
|
||||
} else {
|
||||
log.Info("Missing JWT configuration: No JWT token support!")
|
||||
}
|
||||
|
||||
auth.LocalAuth = &LocalAuthenticator{}
|
||||
if err := auth.LocalAuth.Init(auth, nil); err != nil {
|
||||
if err := auth.LocalAuth.Init(); err != nil {
|
||||
log.Error("Error while initializing authentication -> localAuth init failed")
|
||||
return nil, err
|
||||
}
|
||||
auth.authenticators = append(auth.authenticators, auth.LocalAuth)
|
||||
|
||||
auth.JwtAuth = &JWTAuthenticator{}
|
||||
if err := auth.JwtAuth.Init(auth, configs["jwt"]); err != nil {
|
||||
log.Error("Error while initializing authentication -> jwtAuth init failed")
|
||||
return nil, err
|
||||
}
|
||||
auth.authenticators = append(auth.authenticators, auth.JwtAuth)
|
||||
|
||||
if config, ok := configs["ldap"]; ok {
|
||||
auth.LdapAuth = &LdapAuthenticator{}
|
||||
if err := auth.LdapAuth.Init(auth, config); err != nil {
|
||||
log.Error("Error while initializing authentication -> ldapAuth init failed")
|
||||
return nil, err
|
||||
}
|
||||
auth.authenticators = append(auth.authenticators, auth.LdapAuth)
|
||||
}
|
||||
|
||||
return auth, nil
|
||||
}
|
||||
|
||||
func (auth *Authentication) AuthViaSession(
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) (*User, error) {
|
||||
|
||||
session, err := auth.sessionStore.Get(r, "session")
|
||||
if err != nil {
|
||||
log.Error("Error while getting session store")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if session.IsNew {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// TODO Check if keys are present in session?
|
||||
username, _ := session.Values["username"].(string)
|
||||
projects, _ := session.Values["projects"].([]string)
|
||||
roles, _ := session.Values["roles"].([]string)
|
||||
return &User{
|
||||
Username: username,
|
||||
Projects: projects,
|
||||
Roles: roles,
|
||||
AuthSource: -1,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Handle a POST request that should log the user in, starting a new session.
|
||||
func (auth *Authentication) Login(
|
||||
onsuccess http.Handler,
|
||||
onfailure func(rw http.ResponseWriter, r *http.Request, loginErr error)) http.Handler {
|
||||
|
||||
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
err := errors.New("no authenticator applied")
|
||||
username := r.FormValue("username")
|
||||
user := (*User)(nil)
|
||||
var dbUser *schema.User
|
||||
|
||||
if username != "" {
|
||||
user, _ = auth.GetUser(username)
|
||||
var err error
|
||||
dbUser, err = repository.GetUserRepository().GetUser(username)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
log.Errorf("Error while loading user '%v'", username)
|
||||
}
|
||||
}
|
||||
|
||||
for _, authenticator := range auth.authenticators {
|
||||
if !authenticator.CanLogin(user, rw, r) {
|
||||
var ok bool
|
||||
var user *schema.User
|
||||
if user, ok = authenticator.CanLogin(dbUser, username, rw, r); !ok {
|
||||
continue
|
||||
} else {
|
||||
log.Debugf("Can login with user %v", user)
|
||||
}
|
||||
|
||||
user, err = authenticator.Login(user, rw, r)
|
||||
user, err := authenticator.Login(user, rw, r)
|
||||
if err != nil {
|
||||
log.Warnf("user login failed: %s", err.Error())
|
||||
onfailure(rw, r, err)
|
||||
@@ -355,49 +181,50 @@ func (auth *Authentication) Login(
|
||||
}
|
||||
|
||||
log.Infof("login successfull: user: %#v (roles: %v, projects: %v)", user.Username, user.Roles, user.Projects)
|
||||
ctx := context.WithValue(r.Context(), ContextUserKey, user)
|
||||
ctx := context.WithValue(r.Context(), repository.ContextUserKey, user)
|
||||
onsuccess.ServeHTTP(rw, r.WithContext(ctx))
|
||||
return
|
||||
}
|
||||
|
||||
log.Debugf("login failed: no authenticator applied")
|
||||
onfailure(rw, r, err)
|
||||
onfailure(rw, r, errors.New("no authenticator applied"))
|
||||
})
|
||||
}
|
||||
|
||||
// Authenticate the user and put a User object in the
|
||||
// context of the request. If authentication fails,
|
||||
// do not continue but send client to the login screen.
|
||||
func (auth *Authentication) Auth(
|
||||
onsuccess http.Handler,
|
||||
onfailure func(rw http.ResponseWriter, r *http.Request, authErr error)) http.Handler {
|
||||
|
||||
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
for _, authenticator := range auth.authenticators {
|
||||
user, err := authenticator.Auth(rw, r)
|
||||
|
||||
user, err := auth.JwtAuth.AuthViaJWT(rw, r)
|
||||
if err != nil {
|
||||
log.Infof("authentication failed: %s", err.Error())
|
||||
http.Error(rw, err.Error(), http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
if user == nil {
|
||||
user, err = auth.AuthViaSession(rw, r)
|
||||
if err != nil {
|
||||
log.Infof("authentication failed: %s", err.Error())
|
||||
http.Error(rw, err.Error(), http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
if user == nil {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
ctx := context.WithValue(r.Context(), ContextUserKey, user)
|
||||
if user != nil {
|
||||
ctx := context.WithValue(r.Context(), repository.ContextUserKey, user)
|
||||
onsuccess.ServeHTTP(rw, r.WithContext(ctx))
|
||||
return
|
||||
}
|
||||
|
||||
log.Debugf("authentication failed: %s", "no authenticator applied")
|
||||
// http.Error(rw, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
|
||||
onfailure(rw, r, errors.New("unauthorized (login first or use a token)"))
|
||||
log.Debug("authentication failed")
|
||||
onfailure(rw, r, errors.New("unauthorized (please login first)"))
|
||||
})
|
||||
}
|
||||
|
||||
// Clears the session cookie
|
||||
func (auth *Authentication) Logout(onsuccess http.Handler) http.Handler {
|
||||
|
||||
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
session, err := auth.sessionStore.Get(r, "session")
|
||||
if err != nil {
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
// Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
package auth
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHasValidRole(t *testing.T) {
|
||||
u := User{Username: "testuser", Roles: []string{"user"}}
|
||||
|
||||
exists, _ := u.HasValidRole("user")
|
||||
|
||||
if !exists {
|
||||
t.Fatalf(`User{Roles: ["user"]} -> HasValidRole("user"): EXISTS = %v, expected 'true'.`, exists)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasNotValidRole(t *testing.T) {
|
||||
u := User{Username: "testuser", Roles: []string{"user"}}
|
||||
|
||||
exists, _ := u.HasValidRole("manager")
|
||||
|
||||
if exists {
|
||||
t.Fatalf(`User{Roles: ["user"]} -> HasValidRole("manager"): EXISTS = %v, expected 'false'.`, exists)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasInvalidRole(t *testing.T) {
|
||||
u := User{Username: "testuser", Roles: []string{"user"}}
|
||||
|
||||
_, valid := u.HasValidRole("invalid")
|
||||
|
||||
if valid {
|
||||
t.Fatalf(`User{Roles: ["user"]} -> HasValidRole("invalid"): VALID = %v, expected 'false'.`, valid)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasNotInvalidRole(t *testing.T) {
|
||||
u := User{Username: "testuser", Roles: []string{"user"}}
|
||||
|
||||
_, valid := u.HasValidRole("user")
|
||||
|
||||
if !valid {
|
||||
t.Fatalf(`User{Roles: ["user"]} -> HasValidRole("user"): VALID = %v, expected 'true'.`, valid)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasRole(t *testing.T) {
|
||||
u := User{Username: "testuser", Roles: []string{"user"}}
|
||||
|
||||
exists := u.HasRole(RoleUser)
|
||||
|
||||
if !exists {
|
||||
t.Fatalf(`User{Roles: ["user"]} -> HasRole(RoleUser): EXISTS = %v, expected 'true'.`, exists)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasNotRole(t *testing.T) {
|
||||
u := User{Username: "testuser", Roles: []string{"user"}}
|
||||
|
||||
exists := u.HasRole(RoleManager)
|
||||
|
||||
if exists {
|
||||
t.Fatalf(`User{Roles: ["user"]} -> HasRole(RoleManager): EXISTS = %v, expected 'false'.`, exists)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasAnyRole(t *testing.T) {
|
||||
u := User{Username: "testuser", Roles: []string{"user", "manager"}}
|
||||
|
||||
result := u.HasAnyRole([]Role{RoleManager, RoleSupport, RoleAdmin})
|
||||
|
||||
if !result {
|
||||
t.Fatalf(`User{Roles: ["user", "manager"]} -> HasAnyRole([]Role{RoleManager, RoleSupport, RoleAdmin}): RESULT = %v, expected 'true'.`, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasNotAnyRole(t *testing.T) {
|
||||
u := User{Username: "testuser", Roles: []string{"user", "manager"}}
|
||||
|
||||
result := u.HasAnyRole([]Role{RoleSupport, RoleAdmin})
|
||||
|
||||
if result {
|
||||
t.Fatalf(`User{Roles: ["user", "manager"]} -> HasAllRoles([]Role{RoleSupport, RoleAdmin}): RESULT = %v, expected 'false'.`, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasAllRoles(t *testing.T) {
|
||||
u := User{Username: "testuser", Roles: []string{"user", "manager", "support"}}
|
||||
|
||||
result := u.HasAllRoles([]Role{RoleUser, RoleManager, RoleSupport})
|
||||
|
||||
if !result {
|
||||
t.Fatalf(`User{Roles: ["user", "manager", "support"]} -> HasAllRoles([]Role{RoleUser, RoleManager, RoleSupport}): RESULT = %v, expected 'true'.`, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasNotAllRoles(t *testing.T) {
|
||||
u := User{Username: "testuser", Roles: []string{"user", "manager"}}
|
||||
|
||||
result := u.HasAllRoles([]Role{RoleUser, RoleManager, RoleSupport})
|
||||
|
||||
if result {
|
||||
t.Fatalf(`User{Roles: ["user", "manager"]} -> HasAllRoles([]Role{RoleUser, RoleManager, RoleSupport}): RESULT = %v, expected 'false'.`, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasNotRoles(t *testing.T) {
|
||||
u := User{Username: "testuser", Roles: []string{"user", "manager"}}
|
||||
|
||||
result := u.HasNotRoles([]Role{RoleSupport, RoleAdmin})
|
||||
|
||||
if !result {
|
||||
t.Fatalf(`User{Roles: ["user", "manager"]} -> HasNotRoles([]Role{RoleSupport, RoleAdmin}): RESULT = %v, expected 'true'.`, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasAllNotRoles(t *testing.T) {
|
||||
u := User{Username: "testuser", Roles: []string{"user", "manager"}}
|
||||
|
||||
result := u.HasNotRoles([]Role{RoleUser, RoleManager})
|
||||
|
||||
if result {
|
||||
t.Fatalf(`User{Roles: ["user", "manager"]} -> HasNotRoles([]Role{RoleUser, RoleManager}): RESULT = %v, expected 'false'.`, result)
|
||||
}
|
||||
}
|
||||
@@ -6,39 +6,26 @@ package auth
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"database/sql"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/config"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/repository"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
)
|
||||
|
||||
type JWTAuthenticator struct {
|
||||
auth *Authentication
|
||||
|
||||
publicKey ed25519.PublicKey
|
||||
privateKey ed25519.PrivateKey
|
||||
publicKeyCrossLogin ed25519.PublicKey // For accepting externally generated JWTs
|
||||
|
||||
loginTokenKey []byte // HS256 key
|
||||
|
||||
config *schema.JWTAuthConfig
|
||||
publicKey ed25519.PublicKey
|
||||
privateKey ed25519.PrivateKey
|
||||
}
|
||||
|
||||
var _ Authenticator = (*JWTAuthenticator)(nil)
|
||||
|
||||
func (ja *JWTAuthenticator) Init(auth *Authentication, conf interface{}) error {
|
||||
|
||||
ja.auth = auth
|
||||
ja.config = conf.(*schema.JWTAuthConfig)
|
||||
|
||||
func (ja *JWTAuthenticator) Init() error {
|
||||
pubKey, privKey := os.Getenv("JWT_PUBLIC_KEY"), os.Getenv("JWT_PRIVATE_KEY")
|
||||
if pubKey == "" || privKey == "" {
|
||||
log.Warn("environment variables 'JWT_PUBLIC_KEY' or 'JWT_PRIVATE_KEY' not set (token based authentication will not work)")
|
||||
@@ -57,130 +44,12 @@ func (ja *JWTAuthenticator) Init(auth *Authentication, conf interface{}) error {
|
||||
ja.privateKey = ed25519.PrivateKey(bytes)
|
||||
}
|
||||
|
||||
if pubKey = os.Getenv("CROSS_LOGIN_JWT_HS512_KEY"); pubKey != "" {
|
||||
bytes, err := base64.StdEncoding.DecodeString(pubKey)
|
||||
if err != nil {
|
||||
log.Warn("Could not decode cross login JWT HS512 key")
|
||||
return err
|
||||
}
|
||||
ja.loginTokenKey = bytes
|
||||
}
|
||||
|
||||
// Look for external public keys
|
||||
pubKeyCrossLogin, keyFound := os.LookupEnv("CROSS_LOGIN_JWT_PUBLIC_KEY")
|
||||
if keyFound && pubKeyCrossLogin != "" {
|
||||
bytes, err := base64.StdEncoding.DecodeString(pubKeyCrossLogin)
|
||||
if err != nil {
|
||||
log.Warn("Could not decode cross login JWT public key")
|
||||
return err
|
||||
}
|
||||
ja.publicKeyCrossLogin = ed25519.PublicKey(bytes)
|
||||
|
||||
// Warn if other necessary settings are not configured
|
||||
if ja.config != nil {
|
||||
if ja.config.CookieName == "" {
|
||||
log.Warn("cookieName for JWTs not configured (cross login via JWT cookie will fail)")
|
||||
}
|
||||
if !ja.config.ForceJWTValidationViaDatabase {
|
||||
log.Warn("forceJWTValidationViaDatabase not set to true: CC will accept users and roles defined in JWTs regardless of its own database!")
|
||||
}
|
||||
if ja.config.TrustedExternalIssuer == "" {
|
||||
log.Warn("trustedExternalIssuer for JWTs not configured (cross login via JWT cookie will fail)")
|
||||
}
|
||||
} else {
|
||||
log.Warn("cookieName and trustedExternalIssuer for JWTs not configured (cross login via JWT cookie will fail)")
|
||||
}
|
||||
} else {
|
||||
ja.publicKeyCrossLogin = nil
|
||||
log.Debug("environment variable 'CROSS_LOGIN_JWT_PUBLIC_KEY' not set (cross login token based authentication will not work)")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ja *JWTAuthenticator) CanLogin(
|
||||
user *User,
|
||||
func (ja *JWTAuthenticator) AuthViaJWT(
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) bool {
|
||||
|
||||
return (user != nil && user.AuthSource == AuthViaToken) ||
|
||||
r.Header.Get("Authorization") != "" ||
|
||||
r.URL.Query().Get("login-token") != ""
|
||||
}
|
||||
|
||||
func (ja *JWTAuthenticator) Login(
|
||||
user *User,
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) (*User, error) {
|
||||
|
||||
rawtoken := strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ")
|
||||
if rawtoken == "" {
|
||||
rawtoken = r.URL.Query().Get("login-token")
|
||||
}
|
||||
|
||||
token, err := jwt.Parse(rawtoken, func(t *jwt.Token) (interface{}, error) {
|
||||
if t.Method == jwt.SigningMethodEdDSA {
|
||||
return ja.publicKey, nil
|
||||
}
|
||||
if t.Method == jwt.SigningMethodHS256 || t.Method == jwt.SigningMethodHS512 {
|
||||
return ja.loginTokenKey, nil
|
||||
}
|
||||
return nil, fmt.Errorf("AUTH/JWT > unkown signing method for login token: %s (known: HS256, HS512, EdDSA)", t.Method.Alg())
|
||||
})
|
||||
if err != nil {
|
||||
log.Warn("Error while parsing jwt token")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = token.Claims.Valid(); err != nil {
|
||||
log.Warn("jwt token claims are not valid")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
claims := token.Claims.(jwt.MapClaims)
|
||||
sub, _ := claims["sub"].(string)
|
||||
exp, _ := claims["exp"].(float64)
|
||||
var roles []string
|
||||
if rawroles, ok := claims["roles"].([]interface{}); ok {
|
||||
for _, rr := range rawroles {
|
||||
if r, ok := rr.(string); ok {
|
||||
if isValidRole(r) {
|
||||
roles = append(roles, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if rawrole, ok := claims["roles"].(string); ok {
|
||||
if isValidRole(rawrole) {
|
||||
roles = append(roles, rawrole)
|
||||
}
|
||||
}
|
||||
|
||||
if user == nil {
|
||||
user, err = ja.auth.GetUser(sub)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
log.Errorf("Error while loading user '%v'", sub)
|
||||
return nil, err
|
||||
} else if user == nil {
|
||||
user = &User{
|
||||
Username: sub,
|
||||
Roles: roles,
|
||||
AuthSource: AuthViaToken,
|
||||
}
|
||||
if err := ja.auth.AddUser(user); err != nil {
|
||||
log.Errorf("Error while adding user '%v' to auth from token", user.Username)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
user.Expiration = time.Unix(int64(exp), 0)
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (ja *JWTAuthenticator) Auth(
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) (*User, error) {
|
||||
r *http.Request) (*schema.User, error) {
|
||||
|
||||
rawtoken := r.Header.Get("X-Auth-Token")
|
||||
if rawtoken == "" {
|
||||
@@ -188,59 +57,22 @@ func (ja *JWTAuthenticator) Auth(
|
||||
rawtoken = strings.TrimPrefix(rawtoken, "Bearer ")
|
||||
}
|
||||
|
||||
// If no auth header was found, check for a certain cookie containing a JWT
|
||||
cookieName := ""
|
||||
cookieFound := false
|
||||
if ja.config != nil && ja.config.CookieName != "" {
|
||||
cookieName = ja.config.CookieName
|
||||
}
|
||||
|
||||
// Try to read the JWT cookie
|
||||
if rawtoken == "" && cookieName != "" {
|
||||
jwtCookie, err := r.Cookie(cookieName)
|
||||
|
||||
if err == nil && jwtCookie.Value != "" {
|
||||
rawtoken = jwtCookie.Value
|
||||
cookieFound = true
|
||||
}
|
||||
}
|
||||
|
||||
// Because a user can also log in via a token, the
|
||||
// session cookie must be checked here as well:
|
||||
// there is no token
|
||||
if rawtoken == "" {
|
||||
return ja.auth.AuthViaSession(rw, r)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Try to parse JWT
|
||||
token, err := jwt.Parse(rawtoken, func(t *jwt.Token) (interface{}, error) {
|
||||
if t.Method != jwt.SigningMethodEdDSA {
|
||||
return nil, errors.New("only Ed25519/EdDSA supported")
|
||||
}
|
||||
|
||||
// Is there more than one public key?
|
||||
if ja.publicKeyCrossLogin != nil &&
|
||||
ja.config != nil &&
|
||||
ja.config.TrustedExternalIssuer != "" {
|
||||
|
||||
// Determine whether to use the external public key
|
||||
unvalidatedIssuer, success := t.Claims.(jwt.MapClaims)["iss"].(string)
|
||||
if success && unvalidatedIssuer == ja.config.TrustedExternalIssuer {
|
||||
// The (unvalidated) issuer seems to be the expected one,
|
||||
// use public cross login key from config
|
||||
return ja.publicKeyCrossLogin, nil
|
||||
}
|
||||
}
|
||||
|
||||
// No cross login key configured or issuer not expected
|
||||
// Try own key
|
||||
return ja.publicKey, nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Warn("Error while parsing token")
|
||||
log.Warn("Error while parsing JWT token")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Check token validity
|
||||
if err := token.Claims.Valid(); err != nil {
|
||||
log.Warn("jwt token claims are not valid")
|
||||
return nil, err
|
||||
@@ -253,15 +85,15 @@ func (ja *JWTAuthenticator) Auth(
|
||||
var roles []string
|
||||
|
||||
// Validate user + roles from JWT against database?
|
||||
if ja.config != nil && ja.config.ForceJWTValidationViaDatabase {
|
||||
user, err := ja.auth.GetUser(sub)
|
||||
if config.Keys.JwtConfig.ValidateUser {
|
||||
ur := repository.GetUserRepository()
|
||||
user, err := ur.GetUser(sub)
|
||||
|
||||
// Deny any logins for unknown usernames
|
||||
if err != nil {
|
||||
log.Warn("Could not find user from JWT in internal database.")
|
||||
return nil, errors.New("unknown user")
|
||||
}
|
||||
|
||||
// Take user roles from database instead of trusting the JWT
|
||||
roles = user.Roles
|
||||
} else {
|
||||
@@ -275,47 +107,16 @@ func (ja *JWTAuthenticator) Auth(
|
||||
}
|
||||
}
|
||||
|
||||
if cookieFound {
|
||||
// Create a session so that we no longer need the JTW Cookie
|
||||
session, err := ja.auth.sessionStore.New(r, "session")
|
||||
if err != nil {
|
||||
log.Errorf("session creation failed: %s", err.Error())
|
||||
http.Error(rw, err.Error(), http.StatusInternalServerError)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if ja.auth.SessionMaxAge != 0 {
|
||||
session.Options.MaxAge = int(ja.auth.SessionMaxAge.Seconds())
|
||||
}
|
||||
session.Values["username"] = sub
|
||||
session.Values["roles"] = roles
|
||||
|
||||
if err := ja.auth.sessionStore.Save(r, rw, session); err != nil {
|
||||
log.Warnf("session save failed: %s", err.Error())
|
||||
http.Error(rw, err.Error(), http.StatusInternalServerError)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// (Ask browser to) Delete JWT cookie
|
||||
deletedCookie := &http.Cookie{
|
||||
Name: cookieName,
|
||||
Value: "",
|
||||
Path: "/",
|
||||
MaxAge: -1,
|
||||
HttpOnly: true,
|
||||
}
|
||||
http.SetCookie(rw, deletedCookie)
|
||||
}
|
||||
|
||||
return &User{
|
||||
return &schema.User{
|
||||
Username: sub,
|
||||
Roles: roles,
|
||||
AuthSource: AuthViaToken,
|
||||
AuthType: schema.AuthToken,
|
||||
AuthSource: -1,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Generate a new JWT that can be used for authentication
|
||||
func (ja *JWTAuthenticator) ProvideJWT(user *User) (string, error) {
|
||||
func (ja *JWTAuthenticator) ProvideJWT(user *schema.User) (string, error) {
|
||||
|
||||
if ja.privateKey == nil {
|
||||
return "", errors.New("environment variable 'JWT_PRIVATE_KEY' not set")
|
||||
@@ -327,8 +128,12 @@ func (ja *JWTAuthenticator) ProvideJWT(user *User) (string, error) {
|
||||
"roles": user.Roles,
|
||||
"iat": now.Unix(),
|
||||
}
|
||||
if ja.config != nil && ja.config.MaxAge != 0 {
|
||||
claims["exp"] = now.Add(time.Duration(ja.config.MaxAge)).Unix()
|
||||
if config.Keys.JwtConfig.MaxAge != "" {
|
||||
d, err := time.ParseDuration(config.Keys.JwtConfig.MaxAge)
|
||||
if err != nil {
|
||||
return "", errors.New("cannot parse max-age config key")
|
||||
}
|
||||
claims["exp"] = now.Add(d).Unix()
|
||||
}
|
||||
|
||||
return jwt.NewWithClaims(jwt.SigningMethodEdDSA, claims).SignedString(ja.privateKey)
|
||||
|
||||
219
internal/auth/jwtCookieSession.go
Normal file
219
internal/auth/jwtCookieSession.go
Normal file
@@ -0,0 +1,219 @@
|
||||
// Copyright (C) 2023 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
package auth
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/config"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/repository"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
)
|
||||
|
||||
type JWTCookieSessionAuthenticator struct {
|
||||
publicKey ed25519.PublicKey
|
||||
privateKey ed25519.PrivateKey
|
||||
publicKeyCrossLogin ed25519.PublicKey // For accepting externally generated JWTs
|
||||
}
|
||||
|
||||
var _ Authenticator = (*JWTCookieSessionAuthenticator)(nil)
|
||||
|
||||
func (ja *JWTCookieSessionAuthenticator) Init() error {
|
||||
pubKey, privKey := os.Getenv("JWT_PUBLIC_KEY"), os.Getenv("JWT_PRIVATE_KEY")
|
||||
if pubKey == "" || privKey == "" {
|
||||
log.Warn("environment variables 'JWT_PUBLIC_KEY' or 'JWT_PRIVATE_KEY' not set (token based authentication will not work)")
|
||||
return errors.New("environment variables 'JWT_PUBLIC_KEY' or 'JWT_PRIVATE_KEY' not set (token based authentication will not work)")
|
||||
} else {
|
||||
bytes, err := base64.StdEncoding.DecodeString(pubKey)
|
||||
if err != nil {
|
||||
log.Warn("Could not decode JWT public key")
|
||||
return err
|
||||
}
|
||||
ja.publicKey = ed25519.PublicKey(bytes)
|
||||
bytes, err = base64.StdEncoding.DecodeString(privKey)
|
||||
if err != nil {
|
||||
log.Warn("Could not decode JWT private key")
|
||||
return err
|
||||
}
|
||||
ja.privateKey = ed25519.PrivateKey(bytes)
|
||||
}
|
||||
|
||||
// Look for external public keys
|
||||
pubKeyCrossLogin, keyFound := os.LookupEnv("CROSS_LOGIN_JWT_PUBLIC_KEY")
|
||||
if keyFound && pubKeyCrossLogin != "" {
|
||||
bytes, err := base64.StdEncoding.DecodeString(pubKeyCrossLogin)
|
||||
if err != nil {
|
||||
log.Warn("Could not decode cross login JWT public key")
|
||||
return err
|
||||
}
|
||||
ja.publicKeyCrossLogin = ed25519.PublicKey(bytes)
|
||||
} else {
|
||||
ja.publicKeyCrossLogin = nil
|
||||
log.Debug("environment variable 'CROSS_LOGIN_JWT_PUBLIC_KEY' not set (cross login token based authentication will not work)")
|
||||
return errors.New("environment variable 'CROSS_LOGIN_JWT_PUBLIC_KEY' not set (cross login token based authentication will not work)")
|
||||
}
|
||||
|
||||
jc := config.Keys.JwtConfig
|
||||
// Warn if other necessary settings are not configured
|
||||
if jc != nil {
|
||||
if jc.CookieName == "" {
|
||||
log.Info("cookieName for JWTs not configured (cross login via JWT cookie will fail)")
|
||||
return errors.New("cookieName for JWTs not configured (cross login via JWT cookie will fail)")
|
||||
}
|
||||
if !jc.ValidateUser {
|
||||
log.Info("forceJWTValidationViaDatabase not set to true: CC will accept users and roles defined in JWTs regardless of its own database!")
|
||||
}
|
||||
if jc.TrustedIssuer == "" {
|
||||
log.Info("trustedExternalIssuer for JWTs not configured (cross login via JWT cookie will fail)")
|
||||
return errors.New("trustedExternalIssuer for JWTs not configured (cross login via JWT cookie will fail)")
|
||||
}
|
||||
} else {
|
||||
log.Warn("config for JWTs not configured (cross login via JWT cookie will fail)")
|
||||
return errors.New("config for JWTs not configured (cross login via JWT cookie will fail)")
|
||||
}
|
||||
|
||||
log.Info("JWT Cookie Session authenticator successfully registered")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ja *JWTCookieSessionAuthenticator) CanLogin(
|
||||
user *schema.User,
|
||||
username string,
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) (*schema.User, bool) {
|
||||
|
||||
jc := config.Keys.JwtConfig
|
||||
cookieName := ""
|
||||
if jc.CookieName != "" {
|
||||
cookieName = jc.CookieName
|
||||
}
|
||||
|
||||
// Try to read the JWT cookie
|
||||
if cookieName != "" {
|
||||
jwtCookie, err := r.Cookie(cookieName)
|
||||
|
||||
if err == nil && jwtCookie.Value != "" {
|
||||
return user, true
|
||||
}
|
||||
}
|
||||
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (ja *JWTCookieSessionAuthenticator) Login(
|
||||
user *schema.User,
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) (*schema.User, error) {
|
||||
|
||||
jc := config.Keys.JwtConfig
|
||||
jwtCookie, err := r.Cookie(jc.CookieName)
|
||||
var rawtoken string
|
||||
|
||||
if err == nil && jwtCookie.Value != "" {
|
||||
rawtoken = jwtCookie.Value
|
||||
}
|
||||
|
||||
token, err := jwt.Parse(rawtoken, func(t *jwt.Token) (interface{}, error) {
|
||||
if t.Method != jwt.SigningMethodEdDSA {
|
||||
return nil, errors.New("only Ed25519/EdDSA supported")
|
||||
}
|
||||
|
||||
unvalidatedIssuer, success := t.Claims.(jwt.MapClaims)["iss"].(string)
|
||||
if success && unvalidatedIssuer == jc.TrustedIssuer {
|
||||
// The (unvalidated) issuer seems to be the expected one,
|
||||
// use public cross login key from config
|
||||
return ja.publicKeyCrossLogin, nil
|
||||
}
|
||||
|
||||
// No cross login key configured or issuer not expected
|
||||
// Try own key
|
||||
return ja.publicKey, nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Warn("JWT cookie session: error while parsing token")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Check token validity and extract paypload
|
||||
if err := token.Claims.Valid(); err != nil {
|
||||
log.Warn("jwt token claims are not valid")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
claims := token.Claims.(jwt.MapClaims)
|
||||
sub, _ := claims["sub"].(string)
|
||||
|
||||
var name string
|
||||
if wrap, ok := claims["name"].(map[string]interface{}); ok {
|
||||
if vals, ok := wrap["values"].([]interface{}); ok {
|
||||
if len(vals) != 0 {
|
||||
name = fmt.Sprintf("%v", vals[0])
|
||||
|
||||
for i := 1; i < len(vals); i++ {
|
||||
name += fmt.Sprintf(" %v", vals[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var roles []string
|
||||
|
||||
if jc.ValidateUser {
|
||||
// Deny any logins for unknown usernames
|
||||
if user == nil {
|
||||
log.Warn("Could not find user from JWT in internal database.")
|
||||
return nil, errors.New("unknown user")
|
||||
}
|
||||
|
||||
// Take user roles from database instead of trusting the JWT
|
||||
roles = user.Roles
|
||||
} else {
|
||||
// Extract roles from JWT (if present)
|
||||
if rawroles, ok := claims["roles"].([]interface{}); ok {
|
||||
for _, rr := range rawroles {
|
||||
if r, ok := rr.(string); ok {
|
||||
roles = append(roles, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// (Ask browser to) Delete JWT cookie
|
||||
deletedCookie := &http.Cookie{
|
||||
Name: jc.CookieName,
|
||||
Value: "",
|
||||
Path: "/",
|
||||
MaxAge: -1,
|
||||
HttpOnly: true,
|
||||
}
|
||||
http.SetCookie(rw, deletedCookie)
|
||||
|
||||
if user == nil {
|
||||
projects := make([]string, 0)
|
||||
user = &schema.User{
|
||||
Username: sub,
|
||||
Name: name,
|
||||
Roles: roles,
|
||||
Projects: projects,
|
||||
AuthType: schema.AuthSession,
|
||||
AuthSource: schema.AuthViaToken,
|
||||
}
|
||||
|
||||
if jc.SyncUserOnLogin {
|
||||
if err := repository.GetUserRepository().AddUser(user); err != nil {
|
||||
log.Errorf("Error while adding user '%s' to DB", user.Username)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return user, nil
|
||||
}
|
||||
150
internal/auth/jwtSession.go
Normal file
150
internal/auth/jwtSession.go
Normal file
@@ -0,0 +1,150 @@
|
||||
// Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
package auth
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/config"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/repository"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
)
|
||||
|
||||
type JWTSessionAuthenticator struct {
|
||||
loginTokenKey []byte // HS256 key
|
||||
}
|
||||
|
||||
var _ Authenticator = (*JWTSessionAuthenticator)(nil)
|
||||
|
||||
func (ja *JWTSessionAuthenticator) Init() error {
|
||||
if pubKey := os.Getenv("CROSS_LOGIN_JWT_HS512_KEY"); pubKey != "" {
|
||||
bytes, err := base64.StdEncoding.DecodeString(pubKey)
|
||||
if err != nil {
|
||||
log.Warn("Could not decode cross login JWT HS512 key")
|
||||
return err
|
||||
}
|
||||
ja.loginTokenKey = bytes
|
||||
}
|
||||
|
||||
log.Info("JWT Session authenticator successfully registered")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ja *JWTSessionAuthenticator) CanLogin(
|
||||
user *schema.User,
|
||||
username string,
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) (*schema.User, bool) {
|
||||
|
||||
return user, r.Header.Get("Authorization") != "" ||
|
||||
r.URL.Query().Get("login-token") != ""
|
||||
}
|
||||
|
||||
func (ja *JWTSessionAuthenticator) Login(
|
||||
user *schema.User,
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) (*schema.User, error) {
|
||||
|
||||
rawtoken := strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ")
|
||||
if rawtoken == "" {
|
||||
rawtoken = r.URL.Query().Get("login-token")
|
||||
}
|
||||
|
||||
token, err := jwt.Parse(rawtoken, func(t *jwt.Token) (interface{}, error) {
|
||||
if t.Method == jwt.SigningMethodHS256 || t.Method == jwt.SigningMethodHS512 {
|
||||
return ja.loginTokenKey, nil
|
||||
}
|
||||
return nil, fmt.Errorf("unkown signing method for login token: %s (known: HS256, HS512, EdDSA)", t.Method.Alg())
|
||||
})
|
||||
if err != nil {
|
||||
log.Warn("Error while parsing jwt token")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = token.Claims.Valid(); err != nil {
|
||||
log.Warn("jwt token claims are not valid")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
claims := token.Claims.(jwt.MapClaims)
|
||||
sub, _ := claims["sub"].(string)
|
||||
|
||||
var name string
|
||||
if wrap, ok := claims["name"].(map[string]interface{}); ok {
|
||||
if vals, ok := wrap["values"].([]interface{}); ok {
|
||||
if len(vals) != 0 {
|
||||
name = fmt.Sprintf("%v", vals[0])
|
||||
|
||||
for i := 1; i < len(vals); i++ {
|
||||
name += fmt.Sprintf(" %v", vals[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var roles []string
|
||||
|
||||
if config.Keys.JwtConfig.ValidateUser {
|
||||
// Deny any logins for unknown usernames
|
||||
if user == nil {
|
||||
log.Warn("Could not find user from JWT in internal database.")
|
||||
return nil, errors.New("unknown user")
|
||||
}
|
||||
|
||||
// Take user roles from database instead of trusting the JWT
|
||||
roles = user.Roles
|
||||
} else {
|
||||
// Extract roles from JWT (if present)
|
||||
if rawroles, ok := claims["roles"].([]interface{}); ok {
|
||||
for _, rr := range rawroles {
|
||||
if r, ok := rr.(string); ok {
|
||||
if schema.IsValidRole(r) {
|
||||
roles = append(roles, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
projects := make([]string, 0)
|
||||
// Java/Grails Issued Token
|
||||
// if rawprojs, ok := claims["projects"].([]interface{}); ok {
|
||||
// for _, pp := range rawprojs {
|
||||
// if p, ok := pp.(string); ok {
|
||||
// projects = append(projects, p)
|
||||
// }
|
||||
// }
|
||||
// } else if rawprojs, ok := claims["projects"]; ok {
|
||||
// for _, p := range rawprojs.([]string) {
|
||||
// projects = append(projects, p)
|
||||
// }
|
||||
// }
|
||||
|
||||
if user == nil {
|
||||
user = &schema.User{
|
||||
Username: sub,
|
||||
Name: name,
|
||||
Roles: roles,
|
||||
Projects: projects,
|
||||
AuthType: schema.AuthSession,
|
||||
AuthSource: schema.AuthViaToken,
|
||||
}
|
||||
|
||||
if config.Keys.JwtConfig.SyncUserOnLogin {
|
||||
if err := repository.GetUserRepository().AddUser(user); err != nil {
|
||||
log.Errorf("Error while adding user '%s' to DB", user.Username)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return user, nil
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// Copyright (C) 2023 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
@@ -12,35 +12,33 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/config"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/repository"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
)
|
||||
|
||||
type LdapAuthenticator struct {
|
||||
auth *Authentication
|
||||
config *schema.LdapConfig
|
||||
syncPassword string
|
||||
UserAttr string
|
||||
}
|
||||
|
||||
var _ Authenticator = (*LdapAuthenticator)(nil)
|
||||
|
||||
func (la *LdapAuthenticator) Init(
|
||||
auth *Authentication,
|
||||
conf interface{}) error {
|
||||
|
||||
la.auth = auth
|
||||
la.config = conf.(*schema.LdapConfig)
|
||||
|
||||
func (la *LdapAuthenticator) Init() error {
|
||||
la.syncPassword = os.Getenv("LDAP_ADMIN_PASSWORD")
|
||||
if la.syncPassword == "" {
|
||||
log.Warn("environment variable 'LDAP_ADMIN_PASSWORD' not set (ldap sync will not work)")
|
||||
}
|
||||
|
||||
if la.config != nil && la.config.SyncInterval != "" {
|
||||
interval, err := time.ParseDuration(la.config.SyncInterval)
|
||||
lc := config.Keys.LdapConfig
|
||||
|
||||
if lc.SyncInterval != "" {
|
||||
interval, err := time.ParseDuration(lc.SyncInterval)
|
||||
if err != nil {
|
||||
log.Warnf("Could not parse duration for sync interval: %v", la.config.SyncInterval)
|
||||
log.Warnf("Could not parse duration for sync interval: %v",
|
||||
lc.SyncInterval)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -59,23 +57,88 @@ func (la *LdapAuthenticator) Init(
|
||||
log.Print("sync done")
|
||||
}
|
||||
}()
|
||||
} else {
|
||||
log.Info("LDAP configuration key sync_interval invalid")
|
||||
}
|
||||
|
||||
if lc.UserAttr != "" {
|
||||
la.UserAttr = lc.UserAttr
|
||||
} else {
|
||||
la.UserAttr = "gecos"
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (la *LdapAuthenticator) CanLogin(
|
||||
user *User,
|
||||
user *schema.User,
|
||||
username string,
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) bool {
|
||||
r *http.Request) (*schema.User, bool) {
|
||||
|
||||
return user != nil && user.AuthSource == AuthViaLDAP
|
||||
lc := config.Keys.LdapConfig
|
||||
|
||||
if user != nil {
|
||||
if user.AuthSource == schema.AuthViaLDAP {
|
||||
return user, true
|
||||
}
|
||||
} else {
|
||||
if lc.SyncUserOnLogin {
|
||||
l, err := la.getLdapConnection(true)
|
||||
if err != nil {
|
||||
log.Error("LDAP connection error")
|
||||
}
|
||||
defer l.Close()
|
||||
|
||||
// Search for the given username
|
||||
searchRequest := ldap.NewSearchRequest(
|
||||
lc.UserBase,
|
||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||
fmt.Sprintf("(&%s(uid=%s))", lc.UserFilter, username),
|
||||
[]string{"dn", "uid", la.UserAttr}, nil)
|
||||
|
||||
sr, err := l.Search(searchRequest)
|
||||
if err != nil {
|
||||
log.Warn(err)
|
||||
return nil, false
|
||||
}
|
||||
|
||||
if len(sr.Entries) != 1 {
|
||||
log.Warn("LDAP: User does not exist or too many entries returned")
|
||||
return nil, false
|
||||
}
|
||||
|
||||
entry := sr.Entries[0]
|
||||
name := entry.GetAttributeValue(la.UserAttr)
|
||||
var roles []string
|
||||
roles = append(roles, schema.GetRoleString(schema.RoleUser))
|
||||
projects := make([]string, 0)
|
||||
|
||||
user = &schema.User{
|
||||
Username: username,
|
||||
Name: name,
|
||||
Roles: roles,
|
||||
Projects: projects,
|
||||
AuthType: schema.AuthSession,
|
||||
AuthSource: schema.AuthViaLDAP,
|
||||
}
|
||||
|
||||
if err := repository.GetUserRepository().AddUser(user); err != nil {
|
||||
log.Errorf("User '%s' LDAP: Insert into DB failed", username)
|
||||
return nil, false
|
||||
}
|
||||
|
||||
return user, true
|
||||
}
|
||||
}
|
||||
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (la *LdapAuthenticator) Login(
|
||||
user *User,
|
||||
user *schema.User,
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) (*User, error) {
|
||||
r *http.Request) (*schema.User, error) {
|
||||
|
||||
l, err := la.getLdapConnection(false)
|
||||
if err != nil {
|
||||
@@ -84,42 +147,30 @@ func (la *LdapAuthenticator) Login(
|
||||
}
|
||||
defer l.Close()
|
||||
|
||||
userDn := strings.Replace(la.config.UserBind, "{username}", user.Username, -1)
|
||||
userDn := strings.Replace(config.Keys.LdapConfig.UserBind, "{username}", user.Username, -1)
|
||||
if err := l.Bind(userDn, r.FormValue("password")); err != nil {
|
||||
log.Errorf("AUTH/LOCAL > Authentication for user %s failed: %v", user.Username, err)
|
||||
return nil, fmt.Errorf("AUTH/LDAP > Authentication failed")
|
||||
log.Errorf("AUTH/LDAP > Authentication for user %s failed: %v",
|
||||
user.Username, err)
|
||||
return nil, fmt.Errorf("Authentication failed")
|
||||
}
|
||||
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (la *LdapAuthenticator) Auth(
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) (*User, error) {
|
||||
|
||||
return la.auth.AuthViaSession(rw, r)
|
||||
}
|
||||
|
||||
func (la *LdapAuthenticator) Sync() error {
|
||||
|
||||
const IN_DB int = 1
|
||||
const IN_LDAP int = 2
|
||||
const IN_BOTH int = 3
|
||||
ur := repository.GetUserRepository()
|
||||
lc := config.Keys.LdapConfig
|
||||
|
||||
users := map[string]int{}
|
||||
rows, err := la.auth.db.Query(`SELECT username FROM user WHERE user.ldap = 1`)
|
||||
usernames, err := ur.GetLdapUsernames()
|
||||
if err != nil {
|
||||
log.Warn("Error while querying LDAP users")
|
||||
return err
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
var username string
|
||||
if err := rows.Scan(&username); err != nil {
|
||||
log.Warnf("Error while scanning for user '%s'", username)
|
||||
return err
|
||||
}
|
||||
|
||||
for _, username := range usernames {
|
||||
users[username] = IN_DB
|
||||
}
|
||||
|
||||
@@ -131,8 +182,10 @@ func (la *LdapAuthenticator) Sync() error {
|
||||
defer l.Close()
|
||||
|
||||
ldapResults, err := l.Search(ldap.NewSearchRequest(
|
||||
la.config.UserBase, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||
la.config.UserFilter, []string{"dn", "uid", "gecos"}, nil))
|
||||
lc.UserBase,
|
||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||
lc.UserFilter,
|
||||
[]string{"dn", "uid", la.UserAttr}, nil))
|
||||
if err != nil {
|
||||
log.Warn("LDAP search error")
|
||||
return err
|
||||
@@ -148,25 +201,34 @@ func (la *LdapAuthenticator) Sync() error {
|
||||
_, ok := users[username]
|
||||
if !ok {
|
||||
users[username] = IN_LDAP
|
||||
newnames[username] = entry.GetAttributeValue("gecos")
|
||||
newnames[username] = entry.GetAttributeValue(la.UserAttr)
|
||||
} else {
|
||||
users[username] = IN_BOTH
|
||||
}
|
||||
}
|
||||
|
||||
for username, where := range users {
|
||||
if where == IN_DB && la.config.SyncDelOldUsers {
|
||||
if where == IN_DB && lc.SyncDelOldUsers {
|
||||
ur.DelUser(username)
|
||||
log.Debugf("sync: remove %v (does not show up in LDAP anymore)", username)
|
||||
if _, err := la.auth.db.Exec(`DELETE FROM user WHERE user.username = ?`, username); err != nil {
|
||||
log.Errorf("User '%s' not in LDAP anymore: Delete from DB failed", username)
|
||||
return err
|
||||
}
|
||||
} else if where == IN_LDAP {
|
||||
name := newnames[username]
|
||||
|
||||
var roles []string
|
||||
roles = append(roles, schema.GetRoleString(schema.RoleUser))
|
||||
projects := make([]string, 0)
|
||||
|
||||
user := &schema.User{
|
||||
Username: username,
|
||||
Name: name,
|
||||
Roles: roles,
|
||||
Projects: projects,
|
||||
AuthSource: schema.AuthViaLDAP,
|
||||
}
|
||||
|
||||
log.Debugf("sync: add %v (name: %v, roles: [user], ldap: true)", username, name)
|
||||
if _, err := la.auth.db.Exec(`INSERT INTO user (username, ldap, name, roles) VALUES (?, ?, ?, ?)`,
|
||||
username, 1, name, "[\""+GetRoleString(RoleUser)+"\"]"); err != nil {
|
||||
log.Errorf("User '%s' new in LDAP: Insert into DB failed", username)
|
||||
if err := ur.AddUser(user); err != nil {
|
||||
log.Errorf("User '%s' LDAP: Insert into DB failed", username)
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -175,18 +237,17 @@ func (la *LdapAuthenticator) Sync() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: Add a connection pool or something like
|
||||
// that so that connections can be reused/cached.
|
||||
func (la *LdapAuthenticator) getLdapConnection(admin bool) (*ldap.Conn, error) {
|
||||
|
||||
conn, err := ldap.DialURL(la.config.Url)
|
||||
lc := config.Keys.LdapConfig
|
||||
conn, err := ldap.DialURL(lc.Url)
|
||||
if err != nil {
|
||||
log.Warn("LDAP URL dial failed")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if admin {
|
||||
if err := conn.Bind(la.config.SearchDN, la.syncPassword); err != nil {
|
||||
if err := conn.Bind(lc.SearchDN, la.syncPassword); err != nil {
|
||||
conn.Close()
|
||||
log.Warn("LDAP connection bind failed")
|
||||
return nil, err
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
@@ -18,38 +19,29 @@ type LocalAuthenticator struct {
|
||||
|
||||
var _ Authenticator = (*LocalAuthenticator)(nil)
|
||||
|
||||
func (la *LocalAuthenticator) Init(
|
||||
auth *Authentication,
|
||||
_ interface{}) error {
|
||||
|
||||
la.auth = auth
|
||||
func (la *LocalAuthenticator) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (la *LocalAuthenticator) CanLogin(
|
||||
user *User,
|
||||
user *schema.User,
|
||||
username string,
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) bool {
|
||||
r *http.Request) (*schema.User, bool) {
|
||||
|
||||
return user != nil && user.AuthSource == AuthViaLocalPassword
|
||||
return user, user != nil && user.AuthSource == schema.AuthViaLocalPassword
|
||||
}
|
||||
|
||||
func (la *LocalAuthenticator) Login(
|
||||
user *User,
|
||||
user *schema.User,
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) (*User, error) {
|
||||
r *http.Request) (*schema.User, error) {
|
||||
|
||||
if e := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(r.FormValue("password"))); e != nil {
|
||||
if e := bcrypt.CompareHashAndPassword([]byte(user.Password),
|
||||
[]byte(r.FormValue("password"))); e != nil {
|
||||
log.Errorf("AUTH/LOCAL > Authentication for user %s failed!", user.Username)
|
||||
return nil, fmt.Errorf("AUTH/LOCAL > Authentication failed")
|
||||
return nil, fmt.Errorf("Authentication failed")
|
||||
}
|
||||
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (la *LocalAuthenticator) Auth(
|
||||
rw http.ResponseWriter,
|
||||
r *http.Request) (*User, error) {
|
||||
|
||||
return la.auth.AuthViaSession(rw, r)
|
||||
}
|
||||
|
||||
@@ -1,289 +0,0 @@
|
||||
// Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
func (auth *Authentication) GetUser(username string) (*User, error) {
|
||||
|
||||
user := &User{Username: username}
|
||||
var hashedPassword, name, rawRoles, email, rawProjects sql.NullString
|
||||
if err := sq.Select("password", "ldap", "name", "roles", "email", "projects").From("user").
|
||||
Where("user.username = ?", username).RunWith(auth.db).
|
||||
QueryRow().Scan(&hashedPassword, &user.AuthSource, &name, &rawRoles, &email, &rawProjects); err != nil {
|
||||
log.Warnf("Error while querying user '%v' from database", username)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
user.Password = hashedPassword.String
|
||||
user.Name = name.String
|
||||
user.Email = email.String
|
||||
if rawRoles.Valid {
|
||||
if err := json.Unmarshal([]byte(rawRoles.String), &user.Roles); err != nil {
|
||||
log.Warn("Error while unmarshaling raw roles from DB")
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if rawProjects.Valid {
|
||||
if err := json.Unmarshal([]byte(rawProjects.String), &user.Projects); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (auth *Authentication) AddUser(user *User) error {
|
||||
|
||||
rolesJson, _ := json.Marshal(user.Roles)
|
||||
projectsJson, _ := json.Marshal(user.Projects)
|
||||
|
||||
cols := []string{"username", "roles", "projects"}
|
||||
vals := []interface{}{user.Username, string(rolesJson), string(projectsJson)}
|
||||
|
||||
if user.Name != "" {
|
||||
cols = append(cols, "name")
|
||||
vals = append(vals, user.Name)
|
||||
}
|
||||
if user.Email != "" {
|
||||
cols = append(cols, "email")
|
||||
vals = append(vals, user.Email)
|
||||
}
|
||||
if user.Password != "" {
|
||||
password, err := bcrypt.GenerateFromPassword([]byte(user.Password), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
log.Error("Error while encrypting new user password")
|
||||
return err
|
||||
}
|
||||
cols = append(cols, "password")
|
||||
vals = append(vals, string(password))
|
||||
}
|
||||
|
||||
if _, err := sq.Insert("user").Columns(cols...).Values(vals...).RunWith(auth.db).Exec(); err != nil {
|
||||
log.Errorf("Error while inserting new user '%v' into DB", user.Username)
|
||||
return err
|
||||
}
|
||||
|
||||
log.Infof("new user %#v created (roles: %s, auth-source: %d, projects: %s)", user.Username, rolesJson, user.AuthSource, projectsJson)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (auth *Authentication) DelUser(username string) error {
|
||||
|
||||
_, err := auth.db.Exec(`DELETE FROM user WHERE user.username = ?`, username)
|
||||
log.Errorf("Error while deleting user '%s' from DB", username)
|
||||
return err
|
||||
}
|
||||
|
||||
func (auth *Authentication) ListUsers(specialsOnly bool) ([]*User, error) {
|
||||
|
||||
q := sq.Select("username", "name", "email", "roles", "projects").From("user")
|
||||
if specialsOnly {
|
||||
q = q.Where("(roles != '[\"user\"]' AND roles != '[]')")
|
||||
}
|
||||
|
||||
rows, err := q.RunWith(auth.db).Query()
|
||||
if err != nil {
|
||||
log.Warn("Error while querying user list")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
users := make([]*User, 0)
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
rawroles := ""
|
||||
rawprojects := ""
|
||||
user := &User{}
|
||||
var name, email sql.NullString
|
||||
if err := rows.Scan(&user.Username, &name, &email, &rawroles, &rawprojects); err != nil {
|
||||
log.Warn("Error while scanning user list")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal([]byte(rawroles), &user.Roles); err != nil {
|
||||
log.Warn("Error while unmarshaling raw role list")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal([]byte(rawprojects), &user.Projects); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
user.Name = name.String
|
||||
user.Email = email.String
|
||||
users = append(users, user)
|
||||
}
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (auth *Authentication) AddRole(
|
||||
ctx context.Context,
|
||||
username string,
|
||||
queryrole string) error {
|
||||
|
||||
newRole := strings.ToLower(queryrole)
|
||||
user, err := auth.GetUser(username)
|
||||
if err != nil {
|
||||
log.Warnf("Could not load user '%s'", username)
|
||||
return err
|
||||
}
|
||||
|
||||
exists, valid := user.HasValidRole(newRole)
|
||||
|
||||
if !valid {
|
||||
return fmt.Errorf("Supplied role is no valid option : %v", newRole)
|
||||
}
|
||||
if exists {
|
||||
return fmt.Errorf("User %v already has role %v", username, newRole)
|
||||
}
|
||||
|
||||
roles, _ := json.Marshal(append(user.Roles, newRole))
|
||||
if _, err := sq.Update("user").Set("roles", roles).Where("user.username = ?", username).RunWith(auth.db).Exec(); err != nil {
|
||||
log.Errorf("Error while adding new role for user '%s'", user.Username)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (auth *Authentication) RemoveRole(ctx context.Context, username string, queryrole string) error {
|
||||
oldRole := strings.ToLower(queryrole)
|
||||
user, err := auth.GetUser(username)
|
||||
if err != nil {
|
||||
log.Warnf("Could not load user '%s'", username)
|
||||
return err
|
||||
}
|
||||
|
||||
exists, valid := user.HasValidRole(oldRole)
|
||||
|
||||
if !valid {
|
||||
return fmt.Errorf("Supplied role is no valid option : %v", oldRole)
|
||||
}
|
||||
if !exists {
|
||||
return fmt.Errorf("Role already deleted for user '%v': %v", username, oldRole)
|
||||
}
|
||||
|
||||
if oldRole == GetRoleString(RoleManager) && len(user.Projects) != 0 {
|
||||
return fmt.Errorf("Cannot remove role 'manager' while user %s still has assigned project(s) : %v", username, user.Projects)
|
||||
}
|
||||
|
||||
var newroles []string
|
||||
for _, r := range user.Roles {
|
||||
if r != oldRole {
|
||||
newroles = append(newroles, r) // Append all roles not matching requested to be deleted role
|
||||
}
|
||||
}
|
||||
|
||||
var mroles, _ = json.Marshal(newroles)
|
||||
if _, err := sq.Update("user").Set("roles", mroles).Where("user.username = ?", username).RunWith(auth.db).Exec(); err != nil {
|
||||
log.Errorf("Error while removing role for user '%s'", user.Username)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (auth *Authentication) AddProject(
|
||||
ctx context.Context,
|
||||
username string,
|
||||
project string) error {
|
||||
|
||||
user, err := auth.GetUser(username)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !user.HasRole(RoleManager) {
|
||||
return fmt.Errorf("user '%s' is not a manager!", username)
|
||||
}
|
||||
|
||||
if user.HasProject(project) {
|
||||
return fmt.Errorf("user '%s' already manages project '%s'", username, project)
|
||||
}
|
||||
|
||||
projects, _ := json.Marshal(append(user.Projects, project))
|
||||
if _, err := sq.Update("user").Set("projects", projects).Where("user.username = ?", username).RunWith(auth.db).Exec(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (auth *Authentication) RemoveProject(ctx context.Context, username string, project string) error {
|
||||
user, err := auth.GetUser(username)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !user.HasRole(RoleManager) {
|
||||
return fmt.Errorf("user '%#v' is not a manager!", username)
|
||||
}
|
||||
|
||||
if !user.HasProject(project) {
|
||||
return fmt.Errorf("user '%#v': Cannot remove project '%#v' - Does not match!", username, project)
|
||||
}
|
||||
|
||||
var exists bool
|
||||
var newprojects []string
|
||||
for _, p := range user.Projects {
|
||||
if p != project {
|
||||
newprojects = append(newprojects, p) // Append all projects not matching requested to be deleted project
|
||||
} else {
|
||||
exists = true
|
||||
}
|
||||
}
|
||||
|
||||
if exists == true {
|
||||
var result interface{}
|
||||
if len(newprojects) == 0 {
|
||||
result = "[]"
|
||||
} else {
|
||||
result, _ = json.Marshal(newprojects)
|
||||
}
|
||||
if _, err := sq.Update("user").Set("projects", result).Where("user.username = ?", username).RunWith(auth.db).Exec(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
} else {
|
||||
return fmt.Errorf("user %s already does not manage project %s", username, project)
|
||||
}
|
||||
}
|
||||
|
||||
func FetchUser(ctx context.Context, db *sqlx.DB, username string) (*model.User, error) {
|
||||
me := GetUser(ctx)
|
||||
if me != nil && me.Username != username && me.HasNotRoles([]Role{RoleAdmin, RoleSupport, RoleManager}) {
|
||||
return nil, errors.New("forbidden")
|
||||
}
|
||||
|
||||
user := &model.User{Username: username}
|
||||
var name, email sql.NullString
|
||||
if err := sq.Select("name", "email").From("user").Where("user.username = ?", username).
|
||||
RunWith(db).QueryRow().Scan(&name, &email); err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
/* This warning will be logged *often* for non-local users, i.e. users mentioned only in job-table or archive, */
|
||||
/* since FetchUser will be called to retrieve full name and mail for every job in query/list */
|
||||
// log.Warnf("User '%s' Not found in DB", username)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
log.Warnf("Error while fetching user '%s'", username)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
user.Name = name.String
|
||||
user.Email = email.String
|
||||
return user, nil
|
||||
}
|
||||
@@ -22,26 +22,29 @@ var Keys schema.ProgramConfig = schema.ProgramConfig{
|
||||
Archive: json.RawMessage(`{\"kind\":\"file\",\"path\":\"./var/job-archive\"}`),
|
||||
DisableArchive: false,
|
||||
Validate: false,
|
||||
LdapConfig: nil,
|
||||
SessionMaxAge: "168h",
|
||||
StopJobsExceedingWalltime: 0,
|
||||
ShortRunningJobsDuration: 5 * 60,
|
||||
UiDefaults: map[string]interface{}{
|
||||
"analysis_view_histogramMetrics": []string{"flops_any", "mem_bw", "mem_used"},
|
||||
"analysis_view_scatterPlotMetrics": [][]string{{"flops_any", "mem_bw"}, {"flops_any", "cpu_load"}, {"cpu_load", "mem_bw"}},
|
||||
"job_view_nodestats_selectedMetrics": []string{"flops_any", "mem_bw", "mem_used"},
|
||||
"job_view_polarPlotMetrics": []string{"flops_any", "mem_bw", "mem_used"},
|
||||
"job_view_selectedMetrics": []string{"flops_any", "mem_bw", "mem_used"},
|
||||
"plot_general_colorBackground": true,
|
||||
"plot_general_colorscheme": []string{"#00bfff", "#0000ff", "#ff00ff", "#ff0000", "#ff8000", "#ffff00", "#80ff00"},
|
||||
"plot_general_lineWidth": 3,
|
||||
"plot_list_jobsPerPage": 50,
|
||||
"plot_list_selectedMetrics": []string{"cpu_load", "mem_used", "flops_any", "mem_bw"},
|
||||
"plot_view_plotsPerRow": 3,
|
||||
"plot_view_showPolarplot": true,
|
||||
"plot_view_showRoofline": true,
|
||||
"plot_view_showStatTable": true,
|
||||
"system_view_selectedMetric": "cpu_load",
|
||||
"analysis_view_histogramMetrics": []string{"flops_any", "mem_bw", "mem_used"},
|
||||
"analysis_view_scatterPlotMetrics": [][]string{{"flops_any", "mem_bw"}, {"flops_any", "cpu_load"}, {"cpu_load", "mem_bw"}},
|
||||
"job_view_nodestats_selectedMetrics": []string{"flops_any", "mem_bw", "mem_used"},
|
||||
"job_view_polarPlotMetrics": []string{"flops_any", "mem_bw", "mem_used"},
|
||||
"job_view_selectedMetrics": []string{"flops_any", "mem_bw", "mem_used"},
|
||||
"plot_general_colorBackground": true,
|
||||
"plot_general_colorscheme": []string{"#00bfff", "#0000ff", "#ff00ff", "#ff0000", "#ff8000", "#ffff00", "#80ff00"},
|
||||
"plot_general_lineWidth": 3,
|
||||
"plot_list_jobsPerPage": 50,
|
||||
"plot_list_selectedMetrics": []string{"cpu_load", "mem_used", "flops_any", "mem_bw"},
|
||||
"plot_view_plotsPerRow": 3,
|
||||
"plot_view_showPolarplot": true,
|
||||
"plot_view_showRoofline": true,
|
||||
"plot_view_showStatTable": true,
|
||||
"system_view_selectedMetric": "cpu_load",
|
||||
"analysis_view_selectedTopEntity": "user",
|
||||
"analysis_view_selectedTopCategory": "totalWalltime",
|
||||
"status_view_selectedTopUserCategory": "totalJobs",
|
||||
"status_view_selectedTopProjectCategory": "totalJobs",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,8 +22,8 @@ type FloatRange struct {
|
||||
}
|
||||
|
||||
type Footprints struct {
|
||||
Nodehours []schema.Float `json:"nodehours"`
|
||||
Metrics []*MetricFootprints `json:"metrics"`
|
||||
TimeWeights *TimeWeights `json:"timeWeights"`
|
||||
Metrics []*MetricFootprints `json:"metrics"`
|
||||
}
|
||||
|
||||
type HistoPoint struct {
|
||||
@@ -37,27 +37,27 @@ type IntRangeOutput struct {
|
||||
}
|
||||
|
||||
type JobFilter struct {
|
||||
Tags []string `json:"tags"`
|
||||
JobID *StringInput `json:"jobId"`
|
||||
ArrayJobID *int `json:"arrayJobId"`
|
||||
User *StringInput `json:"user"`
|
||||
Project *StringInput `json:"project"`
|
||||
JobName *StringInput `json:"jobName"`
|
||||
Cluster *StringInput `json:"cluster"`
|
||||
Partition *StringInput `json:"partition"`
|
||||
Duration *schema.IntRange `json:"duration"`
|
||||
MinRunningFor *int `json:"minRunningFor"`
|
||||
NumNodes *schema.IntRange `json:"numNodes"`
|
||||
NumAccelerators *schema.IntRange `json:"numAccelerators"`
|
||||
NumHWThreads *schema.IntRange `json:"numHWThreads"`
|
||||
StartTime *schema.TimeRange `json:"startTime"`
|
||||
State []schema.JobState `json:"state"`
|
||||
FlopsAnyAvg *FloatRange `json:"flopsAnyAvg"`
|
||||
MemBwAvg *FloatRange `json:"memBwAvg"`
|
||||
LoadAvg *FloatRange `json:"loadAvg"`
|
||||
MemUsedMax *FloatRange `json:"memUsedMax"`
|
||||
Exclusive *int `json:"exclusive"`
|
||||
Node *StringInput `json:"node"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
JobID *StringInput `json:"jobId,omitempty"`
|
||||
ArrayJobID *int `json:"arrayJobId,omitempty"`
|
||||
User *StringInput `json:"user,omitempty"`
|
||||
Project *StringInput `json:"project,omitempty"`
|
||||
JobName *StringInput `json:"jobName,omitempty"`
|
||||
Cluster *StringInput `json:"cluster,omitempty"`
|
||||
Partition *StringInput `json:"partition,omitempty"`
|
||||
Duration *schema.IntRange `json:"duration,omitempty"`
|
||||
MinRunningFor *int `json:"minRunningFor,omitempty"`
|
||||
NumNodes *schema.IntRange `json:"numNodes,omitempty"`
|
||||
NumAccelerators *schema.IntRange `json:"numAccelerators,omitempty"`
|
||||
NumHWThreads *schema.IntRange `json:"numHWThreads,omitempty"`
|
||||
StartTime *schema.TimeRange `json:"startTime,omitempty"`
|
||||
State []schema.JobState `json:"state,omitempty"`
|
||||
FlopsAnyAvg *FloatRange `json:"flopsAnyAvg,omitempty"`
|
||||
MemBwAvg *FloatRange `json:"memBwAvg,omitempty"`
|
||||
LoadAvg *FloatRange `json:"loadAvg,omitempty"`
|
||||
MemUsedMax *FloatRange `json:"memUsedMax,omitempty"`
|
||||
Exclusive *int `json:"exclusive,omitempty"`
|
||||
Node *StringInput `json:"node,omitempty"`
|
||||
}
|
||||
|
||||
type JobLink struct {
|
||||
@@ -66,9 +66,9 @@ type JobLink struct {
|
||||
}
|
||||
|
||||
type JobLinkResultList struct {
|
||||
ListQuery *string `json:"listQuery"`
|
||||
ListQuery *string `json:"listQuery,omitempty"`
|
||||
Items []*JobLink `json:"items"`
|
||||
Count *int `json:"count"`
|
||||
Count *int `json:"count,omitempty"`
|
||||
}
|
||||
|
||||
type JobMetricWithName struct {
|
||||
@@ -79,9 +79,9 @@ type JobMetricWithName struct {
|
||||
|
||||
type JobResultList struct {
|
||||
Items []*schema.Job `json:"items"`
|
||||
Offset *int `json:"offset"`
|
||||
Limit *int `json:"limit"`
|
||||
Count *int `json:"count"`
|
||||
Offset *int `json:"offset,omitempty"`
|
||||
Limit *int `json:"limit,omitempty"`
|
||||
Count *int `json:"count,omitempty"`
|
||||
}
|
||||
|
||||
type JobsStatistics struct {
|
||||
@@ -91,11 +91,16 @@ type JobsStatistics struct {
|
||||
RunningJobs int `json:"runningJobs"`
|
||||
ShortJobs int `json:"shortJobs"`
|
||||
TotalWalltime int `json:"totalWalltime"`
|
||||
TotalNodes int `json:"totalNodes"`
|
||||
TotalNodeHours int `json:"totalNodeHours"`
|
||||
TotalCores int `json:"totalCores"`
|
||||
TotalCoreHours int `json:"totalCoreHours"`
|
||||
TotalAccs int `json:"totalAccs"`
|
||||
TotalAccHours int `json:"totalAccHours"`
|
||||
HistDuration []*HistoPoint `json:"histDuration"`
|
||||
HistNumNodes []*HistoPoint `json:"histNumNodes"`
|
||||
HistNumCores []*HistoPoint `json:"histNumCores"`
|
||||
HistNumAccs []*HistoPoint `json:"histNumAccs"`
|
||||
}
|
||||
|
||||
type MetricFootprints struct {
|
||||
@@ -120,12 +125,12 @@ type PageRequest struct {
|
||||
}
|
||||
|
||||
type StringInput struct {
|
||||
Eq *string `json:"eq"`
|
||||
Neq *string `json:"neq"`
|
||||
Contains *string `json:"contains"`
|
||||
StartsWith *string `json:"startsWith"`
|
||||
EndsWith *string `json:"endsWith"`
|
||||
In []string `json:"in"`
|
||||
Eq *string `json:"eq,omitempty"`
|
||||
Neq *string `json:"neq,omitempty"`
|
||||
Contains *string `json:"contains,omitempty"`
|
||||
StartsWith *string `json:"startsWith,omitempty"`
|
||||
EndsWith *string `json:"endsWith,omitempty"`
|
||||
In []string `json:"in,omitempty"`
|
||||
}
|
||||
|
||||
type TimeRangeOutput struct {
|
||||
@@ -133,6 +138,12 @@ type TimeRangeOutput struct {
|
||||
To time.Time `json:"to"`
|
||||
}
|
||||
|
||||
type TimeWeights struct {
|
||||
NodeHours []schema.Float `json:"nodeHours"`
|
||||
AccHours []schema.Float `json:"accHours"`
|
||||
CoreHours []schema.Float `json:"coreHours"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Username string `json:"username"`
|
||||
Name string `json:"name"`
|
||||
@@ -182,6 +193,59 @@ func (e Aggregate) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
type SortByAggregate string
|
||||
|
||||
const (
|
||||
SortByAggregateTotalwalltime SortByAggregate = "TOTALWALLTIME"
|
||||
SortByAggregateTotaljobs SortByAggregate = "TOTALJOBS"
|
||||
SortByAggregateTotalnodes SortByAggregate = "TOTALNODES"
|
||||
SortByAggregateTotalnodehours SortByAggregate = "TOTALNODEHOURS"
|
||||
SortByAggregateTotalcores SortByAggregate = "TOTALCORES"
|
||||
SortByAggregateTotalcorehours SortByAggregate = "TOTALCOREHOURS"
|
||||
SortByAggregateTotalaccs SortByAggregate = "TOTALACCS"
|
||||
SortByAggregateTotalacchours SortByAggregate = "TOTALACCHOURS"
|
||||
)
|
||||
|
||||
var AllSortByAggregate = []SortByAggregate{
|
||||
SortByAggregateTotalwalltime,
|
||||
SortByAggregateTotaljobs,
|
||||
SortByAggregateTotalnodes,
|
||||
SortByAggregateTotalnodehours,
|
||||
SortByAggregateTotalcores,
|
||||
SortByAggregateTotalcorehours,
|
||||
SortByAggregateTotalaccs,
|
||||
SortByAggregateTotalacchours,
|
||||
}
|
||||
|
||||
func (e SortByAggregate) IsValid() bool {
|
||||
switch e {
|
||||
case SortByAggregateTotalwalltime, SortByAggregateTotaljobs, SortByAggregateTotalnodes, SortByAggregateTotalnodehours, SortByAggregateTotalcores, SortByAggregateTotalcorehours, SortByAggregateTotalaccs, SortByAggregateTotalacchours:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e SortByAggregate) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e *SortByAggregate) UnmarshalGQL(v interface{}) error {
|
||||
str, ok := v.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("enums must be strings")
|
||||
}
|
||||
|
||||
*e = SortByAggregate(str)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid SortByAggregate", str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e SortByAggregate) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
type SortDirectionEnum string
|
||||
|
||||
const (
|
||||
@@ -222,44 +286,3 @@ func (e *SortDirectionEnum) UnmarshalGQL(v interface{}) error {
|
||||
func (e SortDirectionEnum) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
type Weights string
|
||||
|
||||
const (
|
||||
WeightsNodeCount Weights = "NODE_COUNT"
|
||||
WeightsNodeHours Weights = "NODE_HOURS"
|
||||
)
|
||||
|
||||
var AllWeights = []Weights{
|
||||
WeightsNodeCount,
|
||||
WeightsNodeHours,
|
||||
}
|
||||
|
||||
func (e Weights) IsValid() bool {
|
||||
switch e {
|
||||
case WeightsNodeCount, WeightsNodeHours:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e Weights) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e *Weights) UnmarshalGQL(v interface{}) error {
|
||||
str, ok := v.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("enums must be strings")
|
||||
}
|
||||
|
||||
*e = Weights(str)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid Weights", str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e Weights) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package graph
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
||||
// Code generated by github.com/99designs/gqlgen version v0.17.24
|
||||
// Code generated by github.com/99designs/gqlgen version v0.17.36
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/auth"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/graph/generated"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/metricdata"
|
||||
@@ -51,7 +50,7 @@ func (r *jobResolver) MetaData(ctx context.Context, obj *schema.Job) (interface{
|
||||
|
||||
// UserData is the resolver for the userData field.
|
||||
func (r *jobResolver) UserData(ctx context.Context, obj *schema.Job) (*model.User, error) {
|
||||
return auth.FetchUser(ctx, r.DB, obj.User)
|
||||
return repository.GetUserRepository().FetchUserInCtx(ctx, obj.User)
|
||||
}
|
||||
|
||||
// CreateTag is the resolver for the createTag field.
|
||||
@@ -122,7 +121,7 @@ func (r *mutationResolver) RemoveTagsFromJob(ctx context.Context, job string, ta
|
||||
|
||||
// UpdateConfiguration is the resolver for the updateConfiguration field.
|
||||
func (r *mutationResolver) UpdateConfiguration(ctx context.Context, name string, value string) (*string, error) {
|
||||
if err := repository.GetUserCfgRepo().UpdateConfig(name, value, auth.GetUser(ctx)); err != nil {
|
||||
if err := repository.GetUserCfgRepo().UpdateConfig(name, value, repository.GetUserFromContext(ctx)); err != nil {
|
||||
log.Warn("Error while updating user config")
|
||||
return nil, err
|
||||
}
|
||||
@@ -142,7 +141,7 @@ func (r *queryResolver) Tags(ctx context.Context) ([]*schema.Tag, error) {
|
||||
|
||||
// User is the resolver for the user field.
|
||||
func (r *queryResolver) User(ctx context.Context, username string) (*model.User, error) {
|
||||
return auth.FetchUser(ctx, r.DB, username)
|
||||
return repository.GetUserRepository().FetchUserInCtx(ctx, username)
|
||||
}
|
||||
|
||||
// AllocatedNodes is the resolver for the allocatedNodes field.
|
||||
@@ -178,7 +177,9 @@ func (r *queryResolver) Job(ctx context.Context, id string) (*schema.Job, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if user := auth.GetUser(ctx); user != nil && job.User != user.Username && user.HasNotRoles([]auth.Role{auth.RoleAdmin, auth.RoleSupport, auth.RoleManager}) {
|
||||
if user := repository.GetUserFromContext(ctx); user != nil &&
|
||||
job.User != user.Username &&
|
||||
user.HasNotRoles([]schema.Role{schema.RoleAdmin, schema.RoleSupport, schema.RoleManager}) {
|
||||
return nil, errors.New("you are not allowed to see this job")
|
||||
}
|
||||
|
||||
@@ -243,34 +244,34 @@ func (r *queryResolver) Jobs(ctx context.Context, filter []*model.JobFilter, pag
|
||||
}
|
||||
|
||||
// JobsStatistics is the resolver for the jobsStatistics field.
|
||||
func (r *queryResolver) JobsStatistics(ctx context.Context, filter []*model.JobFilter, groupBy *model.Aggregate) ([]*model.JobsStatistics, error) {
|
||||
func (r *queryResolver) JobsStatistics(ctx context.Context, filter []*model.JobFilter, page *model.PageRequest, sortBy *model.SortByAggregate, groupBy *model.Aggregate) ([]*model.JobsStatistics, error) {
|
||||
var err error
|
||||
var stats []*model.JobsStatistics
|
||||
|
||||
if requireField(ctx, "totalJobs") {
|
||||
if requireField(ctx, "totalJobs") || requireField(ctx, "totalWalltime") || requireField(ctx, "totalNodes") || requireField(ctx, "totalCores") ||
|
||||
requireField(ctx, "totalAccs") || requireField(ctx, "totalNodeHours") || requireField(ctx, "totalCoreHours") || requireField(ctx, "totalAccHours") {
|
||||
if groupBy == nil {
|
||||
stats, err = r.Repo.JobsStats(ctx, filter)
|
||||
} else {
|
||||
stats, err = r.Repo.JobsStatsGrouped(ctx, filter, groupBy)
|
||||
stats, err = r.Repo.JobsStatsGrouped(ctx, filter, page, sortBy, groupBy)
|
||||
}
|
||||
} else {
|
||||
stats = make([]*model.JobsStatistics, 0, 1)
|
||||
stats = append(stats,
|
||||
&model.JobsStatistics{})
|
||||
stats = append(stats, &model.JobsStatistics{})
|
||||
}
|
||||
|
||||
if groupBy != nil {
|
||||
if requireField(ctx, "shortJobs") {
|
||||
stats, err = r.Repo.AddJobCountGrouped(ctx, filter, groupBy, stats, "short")
|
||||
}
|
||||
if requireField(ctx, "RunningJobs") {
|
||||
if requireField(ctx, "runningJobs") {
|
||||
stats, err = r.Repo.AddJobCountGrouped(ctx, filter, groupBy, stats, "running")
|
||||
}
|
||||
} else {
|
||||
if requireField(ctx, "shortJobs") {
|
||||
stats, err = r.Repo.AddJobCount(ctx, filter, stats, "short")
|
||||
}
|
||||
if requireField(ctx, "RunningJobs") {
|
||||
if requireField(ctx, "runningJobs") {
|
||||
stats, err = r.Repo.AddJobCount(ctx, filter, stats, "running")
|
||||
}
|
||||
}
|
||||
@@ -279,7 +280,7 @@ func (r *queryResolver) JobsStatistics(ctx context.Context, filter []*model.JobF
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if requireField(ctx, "histDuration") || requireField(ctx, "histNumNodes") {
|
||||
if requireField(ctx, "histDuration") || requireField(ctx, "histNumNodes") || requireField(ctx, "histNumCores") || requireField(ctx, "histNumAccs") {
|
||||
if groupBy == nil {
|
||||
stats[0], err = r.Repo.AddHistograms(ctx, filter, stats[0])
|
||||
if err != nil {
|
||||
@@ -293,24 +294,6 @@ func (r *queryResolver) JobsStatistics(ctx context.Context, filter []*model.JobF
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
// JobsCount is the resolver for the jobsCount field.
|
||||
func (r *queryResolver) JobsCount(ctx context.Context, filter []*model.JobFilter, groupBy model.Aggregate, weight *model.Weights, limit *int) ([]*model.Count, error) {
|
||||
counts, err := r.Repo.CountGroupedJobs(ctx, groupBy, filter, weight, limit)
|
||||
if err != nil {
|
||||
log.Warn("Error while counting grouped jobs")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res := make([]*model.Count, 0, len(counts))
|
||||
for name, count := range counts {
|
||||
res = append(res, &model.Count{
|
||||
Name: name,
|
||||
Count: count,
|
||||
})
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// RooflineHeatmap is the resolver for the rooflineHeatmap field.
|
||||
func (r *queryResolver) RooflineHeatmap(ctx context.Context, filter []*model.JobFilter, rows int, cols int, minX float64, minY float64, maxX float64, maxY float64) ([][]float64, error) {
|
||||
return r.rooflineHeatmap(ctx, filter, rows, cols, minX, minY, maxX, maxY)
|
||||
@@ -318,8 +301,8 @@ func (r *queryResolver) RooflineHeatmap(ctx context.Context, filter []*model.Job
|
||||
|
||||
// NodeMetrics is the resolver for the nodeMetrics field.
|
||||
func (r *queryResolver) NodeMetrics(ctx context.Context, cluster string, nodes []string, scopes []schema.MetricScope, metrics []string, from time.Time, to time.Time) ([]*model.NodeMetrics, error) {
|
||||
user := auth.GetUser(ctx)
|
||||
if user != nil && !user.HasRole(auth.RoleAdmin) {
|
||||
user := repository.GetUserFromContext(ctx)
|
||||
if user != nil && !user.HasRole(schema.RoleAdmin) {
|
||||
return nil, errors.New("you need to be an administrator for this query")
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ package graph
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
@@ -15,6 +14,7 @@ import (
|
||||
"github.com/ClusterCockpit/cc-backend/internal/metricdata"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
// "github.com/ClusterCockpit/cc-backend/pkg/archive"
|
||||
)
|
||||
|
||||
const MAX_JOBS_FOR_ANALYSIS = 500
|
||||
@@ -32,7 +32,7 @@ func (r *queryResolver) rooflineHeatmap(
|
||||
return nil, err
|
||||
}
|
||||
if len(jobs) > MAX_JOBS_FOR_ANALYSIS {
|
||||
return nil, fmt.Errorf("GRAPH/STATS > too many jobs matched (max: %d)", MAX_JOBS_FOR_ANALYSIS)
|
||||
return nil, fmt.Errorf("GRAPH/UTIL > too many jobs matched (max: %d)", MAX_JOBS_FOR_ANALYSIS)
|
||||
}
|
||||
|
||||
fcols, frows := float64(cols), float64(rows)
|
||||
@@ -49,20 +49,24 @@ func (r *queryResolver) rooflineHeatmap(
|
||||
|
||||
jobdata, err := metricdata.LoadData(job, []string{"flops_any", "mem_bw"}, []schema.MetricScope{schema.MetricScopeNode}, ctx)
|
||||
if err != nil {
|
||||
log.Error("Error while loading metrics for roofline")
|
||||
log.Errorf("Error while loading roofline metrics for job %d", job.ID)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
flops_, membw_ := jobdata["flops_any"], jobdata["mem_bw"]
|
||||
if flops_ == nil && membw_ == nil {
|
||||
return nil, fmt.Errorf("GRAPH/STATS > 'flops_any' or 'mem_bw' missing for job %d", job.ID)
|
||||
log.Infof("rooflineHeatmap(): 'flops_any' or 'mem_bw' missing for job %d", job.ID)
|
||||
continue
|
||||
// return nil, fmt.Errorf("GRAPH/UTIL > 'flops_any' or 'mem_bw' missing for job %d", job.ID)
|
||||
}
|
||||
|
||||
flops, ok1 := flops_["node"]
|
||||
membw, ok2 := membw_["node"]
|
||||
if !ok1 || !ok2 {
|
||||
log.Info("rooflineHeatmap() query not implemented for where flops_any or mem_bw not available at 'node' level")
|
||||
continue
|
||||
// TODO/FIXME:
|
||||
return nil, errors.New("GRAPH/STATS > todo: rooflineHeatmap() query not implemented for where flops_any or mem_bw not available at 'node' level")
|
||||
// return nil, errors.New("GRAPH/UTIL > todo: rooflineHeatmap() query not implemented for where flops_any or mem_bw not available at 'node' level")
|
||||
}
|
||||
|
||||
for n := 0; n < len(flops.Series); n++ {
|
||||
@@ -98,7 +102,7 @@ func (r *queryResolver) jobsFootprints(ctx context.Context, filter []*model.JobF
|
||||
return nil, err
|
||||
}
|
||||
if len(jobs) > MAX_JOBS_FOR_ANALYSIS {
|
||||
return nil, fmt.Errorf("GRAPH/STATS > too many jobs matched (max: %d)", MAX_JOBS_FOR_ANALYSIS)
|
||||
return nil, fmt.Errorf("GRAPH/UTIL > too many jobs matched (max: %d)", MAX_JOBS_FOR_ANALYSIS)
|
||||
}
|
||||
|
||||
avgs := make([][]schema.Float, len(metrics))
|
||||
@@ -106,7 +110,11 @@ func (r *queryResolver) jobsFootprints(ctx context.Context, filter []*model.JobF
|
||||
avgs[i] = make([]schema.Float, 0, len(jobs))
|
||||
}
|
||||
|
||||
nodehours := make([]schema.Float, 0, len(jobs))
|
||||
timeweights := new(model.TimeWeights)
|
||||
timeweights.NodeHours = make([]schema.Float, 0, len(jobs))
|
||||
timeweights.AccHours = make([]schema.Float, 0, len(jobs))
|
||||
timeweights.CoreHours = make([]schema.Float, 0, len(jobs))
|
||||
|
||||
for _, job := range jobs {
|
||||
if job.MonitoringStatus == schema.MonitoringStatusDisabled || job.MonitoringStatus == schema.MonitoringStatusArchivingFailed {
|
||||
continue
|
||||
@@ -117,7 +125,18 @@ func (r *queryResolver) jobsFootprints(ctx context.Context, filter []*model.JobF
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nodehours = append(nodehours, schema.Float(float64(job.Duration)/60.0*float64(job.NumNodes)))
|
||||
// #166 collect arrays: Null values or no null values?
|
||||
timeweights.NodeHours = append(timeweights.NodeHours, schema.Float(float64(job.Duration)/60.0*float64(job.NumNodes)))
|
||||
if job.NumAcc > 0 {
|
||||
timeweights.AccHours = append(timeweights.AccHours, schema.Float(float64(job.Duration)/60.0*float64(job.NumAcc)))
|
||||
} else {
|
||||
timeweights.AccHours = append(timeweights.AccHours, schema.Float(1.0))
|
||||
}
|
||||
if job.NumHWThreads > 0 {
|
||||
timeweights.CoreHours = append(timeweights.CoreHours, schema.Float(float64(job.Duration)/60.0*float64(job.NumHWThreads))) // SQLite HWThreads == Cores; numCoresForJob(job)
|
||||
} else {
|
||||
timeweights.CoreHours = append(timeweights.CoreHours, schema.Float(1.0))
|
||||
}
|
||||
}
|
||||
|
||||
res := make([]*model.MetricFootprints, len(avgs))
|
||||
@@ -129,11 +148,34 @@ func (r *queryResolver) jobsFootprints(ctx context.Context, filter []*model.JobF
|
||||
}
|
||||
|
||||
return &model.Footprints{
|
||||
Nodehours: nodehours,
|
||||
Metrics: res,
|
||||
TimeWeights: timeweights,
|
||||
Metrics: res,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// func numCoresForJob(job *schema.Job) (numCores int) {
|
||||
|
||||
// subcluster, scerr := archive.GetSubCluster(job.Cluster, job.SubCluster)
|
||||
// if scerr != nil {
|
||||
// return 1
|
||||
// }
|
||||
|
||||
// totalJobCores := 0
|
||||
// topology := subcluster.Topology
|
||||
|
||||
// for _, host := range job.Resources {
|
||||
// hwthreads := host.HWThreads
|
||||
// if hwthreads == nil {
|
||||
// hwthreads = topology.Node
|
||||
// }
|
||||
|
||||
// hostCores, _ := topology.GetCoresFromHWThreads(hwthreads)
|
||||
// totalJobCores += len(hostCores)
|
||||
// }
|
||||
|
||||
// return totalJobCores
|
||||
// }
|
||||
|
||||
func requireField(ctx context.Context, name string) bool {
|
||||
fields := graphql.CollectAllFields(ctx)
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ func setup(t *testing.T) *repository.JobRepository {
|
||||
"kind": "file",
|
||||
"path": "./var/job-archive"
|
||||
},
|
||||
"jwts": {
|
||||
"max-age": "2m"
|
||||
},
|
||||
"clusters": [
|
||||
{
|
||||
"name": "testcluster",
|
||||
|
||||
@@ -506,7 +506,7 @@ func (ccms *CCMetricStore) LoadStats(
|
||||
metrics []string,
|
||||
ctx context.Context) (map[string]map[string]schema.MetricStatistics, error) {
|
||||
|
||||
queries, _, err := ccms.buildQueries(job, metrics, []schema.MetricScope{schema.MetricScopeNode})
|
||||
queries, _, err := ccms.buildQueries(job, metrics, []schema.MetricScope{schema.MetricScopeNode}) // #166 Add scope shere for analysis view accelerator normalization?
|
||||
if err != nil {
|
||||
log.Warn("Error while building query")
|
||||
return nil, err
|
||||
@@ -533,7 +533,9 @@ func (ccms *CCMetricStore) LoadStats(
|
||||
metric := ccms.toLocalName(query.Metric)
|
||||
data := res[0]
|
||||
if data.Error != nil {
|
||||
return nil, fmt.Errorf("METRICDATA/CCMS > fetching %s for node %s failed: %s", metric, query.Hostname, *data.Error)
|
||||
log.Infof("fetching %s for node %s failed: %s", metric, query.Hostname, *data.Error)
|
||||
continue
|
||||
// return nil, fmt.Errorf("METRICDATA/CCMS > fetching %s for node %s failed: %s", metric, query.Hostname, *data.Error)
|
||||
}
|
||||
|
||||
metricdata, ok := stats[metric]
|
||||
@@ -543,7 +545,9 @@ func (ccms *CCMetricStore) LoadStats(
|
||||
}
|
||||
|
||||
if data.Avg.IsNaN() || data.Min.IsNaN() || data.Max.IsNaN() {
|
||||
return nil, fmt.Errorf("METRICDATA/CCMS > fetching %s for node %s failed: %s", metric, query.Hostname, "avg/min/max is NaN")
|
||||
log.Infof("fetching %s for node %s failed: one of avg/min/max is NaN", metric, query.Hostname)
|
||||
continue
|
||||
// return nil, fmt.Errorf("METRICDATA/CCMS > fetching %s for node %s failed: %s", metric, query.Hostname, "avg/min/max is NaN")
|
||||
}
|
||||
|
||||
metricdata[query.Hostname] = schema.MetricStatistics{
|
||||
|
||||
@@ -182,7 +182,7 @@ func LoadAverages(
|
||||
ctx context.Context) error {
|
||||
|
||||
if job.State != schema.JobStateRunning && useArchive {
|
||||
return archive.LoadAveragesFromArchive(job, metrics, data)
|
||||
return archive.LoadAveragesFromArchive(job, metrics, data) // #166 change also here?
|
||||
}
|
||||
|
||||
repo, ok := metricDataRepos[job.Cluster]
|
||||
@@ -190,7 +190,7 @@ func LoadAverages(
|
||||
return fmt.Errorf("METRICDATA/METRICDATA > no metric data repository configured for '%s'", job.Cluster)
|
||||
}
|
||||
|
||||
stats, err := repo.LoadStats(job, metrics, ctx)
|
||||
stats, err := repo.LoadStats(job, metrics, ctx) // #166 how to handle stats for acc normalizazion?
|
||||
if err != nil {
|
||||
log.Errorf("Error while loading statistics for job %v (User %v, Project %v)", job.JobID, job.User, job.Project)
|
||||
return err
|
||||
|
||||
@@ -326,7 +326,6 @@ func (pdb *PrometheusDataRepository) LoadData(
|
||||
Timestep: metricConfig.Timestep,
|
||||
Series: make([]schema.Series, 0),
|
||||
}
|
||||
jobData[metric][scope] = jobMetric
|
||||
}
|
||||
step := int64(metricConfig.Timestep)
|
||||
steps := int64(to.Sub(from).Seconds()) / step
|
||||
@@ -335,6 +334,10 @@ func (pdb *PrometheusDataRepository) LoadData(
|
||||
jobMetric.Series = append(jobMetric.Series,
|
||||
pdb.RowToSeries(from, step, steps, row))
|
||||
}
|
||||
// only add metric if at least one host returned data
|
||||
if !ok && len(jobMetric.Series) > 0{
|
||||
jobData[metric][scope] = jobMetric
|
||||
}
|
||||
// sort by hostname to get uniform coloring
|
||||
sort.Slice(jobMetric.Series, func(i, j int) bool {
|
||||
return (jobMetric.Series[i].Hostname < jobMetric.Series[j].Hostname)
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/auth"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/metricdata"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
@@ -456,69 +455,6 @@ func (r *JobRepository) DeleteJobById(id int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: Use node hours instead: SELECT job.user, sum(job.num_nodes * (CASE WHEN job.job_state = "running" THEN CAST(strftime('%s', 'now') AS INTEGER) - job.start_time ELSE job.duration END)) as x FROM job GROUP BY user ORDER BY x DESC;
|
||||
func (r *JobRepository) CountGroupedJobs(
|
||||
ctx context.Context,
|
||||
aggreg model.Aggregate,
|
||||
filters []*model.JobFilter,
|
||||
weight *model.Weights,
|
||||
limit *int) (map[string]int, error) {
|
||||
|
||||
start := time.Now()
|
||||
if !aggreg.IsValid() {
|
||||
return nil, errors.New("invalid aggregate")
|
||||
}
|
||||
|
||||
runner := (sq.BaseRunner)(r.stmtCache)
|
||||
count := "count(*) as count"
|
||||
if weight != nil {
|
||||
switch *weight {
|
||||
case model.WeightsNodeCount:
|
||||
count = "sum(job.num_nodes) as count"
|
||||
case model.WeightsNodeHours:
|
||||
now := time.Now().Unix()
|
||||
count = fmt.Sprintf(`sum(job.num_nodes * (CASE WHEN job.job_state = "running" THEN %d - job.start_time ELSE job.duration END)) as count`, now)
|
||||
runner = r.DB
|
||||
default:
|
||||
log.Debugf("CountGroupedJobs() Weight %v unknown.", *weight)
|
||||
}
|
||||
}
|
||||
|
||||
q, qerr := SecurityCheck(ctx, sq.Select("job."+string(aggreg), count).From("job").GroupBy("job."+string(aggreg)).OrderBy("count DESC"))
|
||||
|
||||
if qerr != nil {
|
||||
return nil, qerr
|
||||
}
|
||||
|
||||
for _, f := range filters {
|
||||
q = BuildWhereClause(f, q)
|
||||
}
|
||||
if limit != nil {
|
||||
q = q.Limit(uint64(*limit))
|
||||
}
|
||||
|
||||
counts := map[string]int{}
|
||||
rows, err := q.RunWith(runner).Query()
|
||||
if err != nil {
|
||||
log.Error("Error while running query")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
var group string
|
||||
var count int
|
||||
if err := rows.Scan(&group, &count); err != nil {
|
||||
log.Warn("Error while scanning rows")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
counts[group] = count
|
||||
}
|
||||
|
||||
log.Debugf("Timer CountGroupedJobs %s", time.Since(start))
|
||||
return counts, nil
|
||||
}
|
||||
|
||||
func (r *JobRepository) UpdateMonitoringStatus(job int64, monitoringStatus int32) (err error) {
|
||||
stmt := sq.Update("job").
|
||||
Set("monitoring_status", monitoringStatus).
|
||||
@@ -615,7 +551,7 @@ func (r *JobRepository) WaitForArchiving() {
|
||||
r.archivePending.Wait()
|
||||
}
|
||||
|
||||
func (r *JobRepository) FindUserOrProjectOrJobname(user *auth.User, searchterm string) (jobid string, username string, project string, jobname string) {
|
||||
func (r *JobRepository) FindUserOrProjectOrJobname(user *schema.User, searchterm string) (jobid string, username string, project string, jobname string) {
|
||||
if _, err := strconv.Atoi(searchterm); err == nil { // Return empty on successful conversion: parent method will redirect for integer jobId
|
||||
return searchterm, "", "", ""
|
||||
} else { // Has to have letters and logged-in user for other guesses
|
||||
@@ -644,14 +580,14 @@ func (r *JobRepository) FindUserOrProjectOrJobname(user *auth.User, searchterm s
|
||||
var ErrNotFound = errors.New("no such jobname, project or user")
|
||||
var ErrForbidden = errors.New("not authorized")
|
||||
|
||||
func (r *JobRepository) FindColumnValue(user *auth.User, searchterm string, table string, selectColumn string, whereColumn string, isLike bool) (result string, err error) {
|
||||
func (r *JobRepository) FindColumnValue(user *schema.User, searchterm string, table string, selectColumn string, whereColumn string, isLike bool) (result string, err error) {
|
||||
compareStr := " = ?"
|
||||
query := searchterm
|
||||
if isLike {
|
||||
compareStr = " LIKE ?"
|
||||
query = "%" + searchterm + "%"
|
||||
}
|
||||
if user.HasAnyRole([]auth.Role{auth.RoleAdmin, auth.RoleSupport, auth.RoleManager}) {
|
||||
if user.HasAnyRole([]schema.Role{schema.RoleAdmin, schema.RoleSupport, schema.RoleManager}) {
|
||||
theQuery := sq.Select(table+"."+selectColumn).Distinct().From(table).
|
||||
Where(table+"."+whereColumn+compareStr, query)
|
||||
|
||||
@@ -676,9 +612,9 @@ func (r *JobRepository) FindColumnValue(user *auth.User, searchterm string, tabl
|
||||
}
|
||||
}
|
||||
|
||||
func (r *JobRepository) FindColumnValues(user *auth.User, query string, table string, selectColumn string, whereColumn string) (results []string, err error) {
|
||||
func (r *JobRepository) FindColumnValues(user *schema.User, query string, table string, selectColumn string, whereColumn string) (results []string, err error) {
|
||||
emptyResult := make([]string, 0)
|
||||
if user.HasAnyRole([]auth.Role{auth.RoleAdmin, auth.RoleSupport, auth.RoleManager}) {
|
||||
if user.HasAnyRole([]schema.Role{schema.RoleAdmin, schema.RoleSupport, schema.RoleManager}) {
|
||||
rows, err := sq.Select(table+"."+selectColumn).Distinct().From(table).
|
||||
Where(table+"."+whereColumn+" LIKE ?", fmt.Sprint("%", query, "%")).
|
||||
RunWith(r.stmtCache).Query()
|
||||
|
||||
@@ -12,20 +12,23 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/auth"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
)
|
||||
|
||||
// SecurityCheck-less, private: Returns a list of jobs matching the provided filters. page and order are optional-
|
||||
func (r *JobRepository) queryJobs(
|
||||
query sq.SelectBuilder,
|
||||
func (r *JobRepository) QueryJobs(
|
||||
ctx context.Context,
|
||||
filters []*model.JobFilter,
|
||||
page *model.PageRequest,
|
||||
order *model.OrderByInput) ([]*schema.Job, error) {
|
||||
|
||||
query, qerr := SecurityCheck(ctx, sq.Select(jobColumns...).From("job"))
|
||||
if qerr != nil {
|
||||
return nil, qerr
|
||||
}
|
||||
|
||||
if order != nil {
|
||||
field := toSnakeCase(order.Field)
|
||||
|
||||
@@ -68,34 +71,15 @@ func (r *JobRepository) queryJobs(
|
||||
return jobs, nil
|
||||
}
|
||||
|
||||
// testFunction for queryJobs
|
||||
func (r *JobRepository) testQueryJobs(
|
||||
filters []*model.JobFilter,
|
||||
page *model.PageRequest,
|
||||
order *model.OrderByInput) ([]*schema.Job, error) {
|
||||
|
||||
return r.queryJobs(sq.Select(jobColumns...).From("job"), filters, page, order)
|
||||
}
|
||||
|
||||
// Public function with added securityCheck, calls private queryJobs function above
|
||||
func (r *JobRepository) QueryJobs(
|
||||
func (r *JobRepository) CountJobs(
|
||||
ctx context.Context,
|
||||
filters []*model.JobFilter,
|
||||
page *model.PageRequest,
|
||||
order *model.OrderByInput) ([]*schema.Job, error) {
|
||||
|
||||
query, qerr := SecurityCheck(ctx, sq.Select(jobColumns...).From("job"))
|
||||
if qerr != nil {
|
||||
return nil, qerr
|
||||
}
|
||||
|
||||
return r.queryJobs(query, filters, page, order)
|
||||
}
|
||||
|
||||
// SecurityCheck-less, private: Returns the number of jobs matching the filters
|
||||
func (r *JobRepository) countJobs(query sq.SelectBuilder,
|
||||
filters []*model.JobFilter) (int, error) {
|
||||
|
||||
query, qerr := SecurityCheck(ctx, sq.Select("count(*)").From("job"))
|
||||
if qerr != nil {
|
||||
return 0, qerr
|
||||
}
|
||||
|
||||
for _, f := range filters {
|
||||
query = BuildWhereClause(f, query)
|
||||
}
|
||||
@@ -108,42 +92,21 @@ func (r *JobRepository) countJobs(query sq.SelectBuilder,
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// testFunction for countJobs
|
||||
func (r *JobRepository) testCountJobs(
|
||||
filters []*model.JobFilter) (int, error) {
|
||||
|
||||
return r.countJobs(sq.Select("count(*)").From("job"), filters)
|
||||
}
|
||||
|
||||
// Public function with added securityCheck, calls private countJobs function above
|
||||
func (r *JobRepository) CountJobs(
|
||||
ctx context.Context,
|
||||
filters []*model.JobFilter) (int, error) {
|
||||
|
||||
query, qerr := SecurityCheck(ctx, sq.Select("count(*)").From("job"))
|
||||
|
||||
if qerr != nil {
|
||||
return 0, qerr
|
||||
}
|
||||
|
||||
return r.countJobs(query, filters)
|
||||
}
|
||||
|
||||
func SecurityCheck(ctx context.Context, query sq.SelectBuilder) (sq.SelectBuilder, error) {
|
||||
user := auth.GetUser(ctx)
|
||||
user := GetUserFromContext(ctx)
|
||||
if user == nil {
|
||||
var qnil sq.SelectBuilder
|
||||
return qnil, fmt.Errorf("user context is nil!")
|
||||
} else if user.HasAnyRole([]auth.Role{auth.RoleAdmin, auth.RoleSupport, auth.RoleApi}) { // Admin & Co. : All jobs
|
||||
} else if user.HasAnyRole([]schema.Role{schema.RoleAdmin, schema.RoleSupport, schema.RoleApi}) { // Admin & Co. : All jobs
|
||||
return query, nil
|
||||
} else if user.HasRole(auth.RoleManager) { // Manager : Add filter for managed projects' jobs only + personal jobs
|
||||
} else if user.HasRole(schema.RoleManager) { // Manager : Add filter for managed projects' jobs only + personal jobs
|
||||
if len(user.Projects) != 0 {
|
||||
return query.Where(sq.Or{sq.Eq{"job.project": user.Projects}, sq.Eq{"job.user": user.Username}}), nil
|
||||
} else {
|
||||
log.Debugf("Manager-User '%s' has no defined projects to lookup! Query only personal jobs ...", user.Username)
|
||||
return query.Where("job.user = ?", user.Username), nil
|
||||
}
|
||||
} else if user.HasRole(auth.RoleUser) { // User : Only personal jobs
|
||||
} else if user.HasRole(schema.RoleUser) { // User : Only personal jobs
|
||||
return query.Where("job.user = ?", user.Username), nil
|
||||
} else {
|
||||
// Shortterm compatibility: Return User-Query if no roles:
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
@@ -94,7 +96,7 @@ func BenchmarkDB_CountJobs(b *testing.B) {
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, err := db.testCountJobs([]*model.JobFilter{filter})
|
||||
_, err := db.CountJobs(getContext(b), []*model.JobFilter{filter})
|
||||
noErr(b, err)
|
||||
}
|
||||
})
|
||||
@@ -118,20 +120,37 @@ func BenchmarkDB_QueryJobs(b *testing.B) {
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_, err := db.testQueryJobs([]*model.JobFilter{filter}, page, order)
|
||||
_, err := db.QueryJobs(getContext(b), []*model.JobFilter{filter}, page, order)
|
||||
noErr(b, err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func getContext(tb testing.TB) context.Context {
|
||||
tb.Helper()
|
||||
|
||||
var roles []string
|
||||
roles = append(roles, schema.GetRoleString(schema.RoleAdmin))
|
||||
projects := make([]string, 0)
|
||||
|
||||
user := &schema.User{
|
||||
Username: "demo",
|
||||
Name: "The man",
|
||||
Roles: roles,
|
||||
Projects: projects,
|
||||
AuthSource: schema.AuthViaLDAP,
|
||||
}
|
||||
ctx := context.Background()
|
||||
return context.WithValue(ctx, ContextUserKey, user)
|
||||
}
|
||||
|
||||
func setup(tb testing.TB) *JobRepository {
|
||||
tb.Helper()
|
||||
log.Init("warn", true)
|
||||
dbfile := "testdata/job.db"
|
||||
err := MigrateDB("sqlite3", dbfile)
|
||||
noErr(tb, err)
|
||||
|
||||
Connect("sqlite3", dbfile)
|
||||
return GetJobRepository()
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/auth"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/config"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
@@ -24,6 +23,17 @@ var groupBy2column = map[model.Aggregate]string{
|
||||
model.AggregateCluster: "job.cluster",
|
||||
}
|
||||
|
||||
var sortBy2column = map[model.SortByAggregate]string{
|
||||
model.SortByAggregateTotaljobs: "totalJobs",
|
||||
model.SortByAggregateTotalwalltime: "totalWalltime",
|
||||
model.SortByAggregateTotalnodes: "totalNodes",
|
||||
model.SortByAggregateTotalnodehours: "totalNodeHours",
|
||||
model.SortByAggregateTotalcores: "totalCores",
|
||||
model.SortByAggregateTotalcorehours: "totalCoreHours",
|
||||
model.SortByAggregateTotalaccs: "totalAccs",
|
||||
model.SortByAggregateTotalacchours: "totalAccHours",
|
||||
}
|
||||
|
||||
func (r *JobRepository) buildCountQuery(
|
||||
filter []*model.JobFilter,
|
||||
kind string,
|
||||
@@ -61,19 +71,26 @@ func (r *JobRepository) buildStatsQuery(
|
||||
castType := r.getCastType()
|
||||
|
||||
if col != "" {
|
||||
// Scan columns: id, totalJobs, totalWalltime, totalNodeHours, totalCoreHours, totalAccHours
|
||||
query = sq.Select(col, "COUNT(job.id)",
|
||||
fmt.Sprintf("CAST(ROUND(SUM(job.duration) / 3600) as %s)", castType),
|
||||
fmt.Sprintf("CAST(ROUND(SUM(job.duration * job.num_nodes) / 3600) as %s)", castType),
|
||||
fmt.Sprintf("CAST(ROUND(SUM(job.duration * job.num_hwthreads) / 3600) as %s)", castType),
|
||||
fmt.Sprintf("CAST(ROUND(SUM(job.duration * job.num_acc) / 3600) as %s)", castType),
|
||||
// Scan columns: id, totalJobs, totalWalltime, totalNodes, totalNodeHours, totalCores, totalCoreHours, totalAccs, totalAccHours
|
||||
query = sq.Select(col, "COUNT(job.id) as totalJobs",
|
||||
fmt.Sprintf("CAST(ROUND(SUM(job.duration) / 3600) as %s) as totalWalltime", castType),
|
||||
fmt.Sprintf("CAST(SUM(job.num_nodes) as %s) as totalNodes", castType),
|
||||
fmt.Sprintf("CAST(ROUND(SUM(job.duration * job.num_nodes) / 3600) as %s) as totalNodeHours", castType),
|
||||
fmt.Sprintf("CAST(SUM(job.num_hwthreads) as %s) as totalCores", castType),
|
||||
fmt.Sprintf("CAST(ROUND(SUM(job.duration * job.num_hwthreads) / 3600) as %s) as totalCoreHours", castType),
|
||||
fmt.Sprintf("CAST(SUM(job.num_acc) as %s) as totalAccs", castType),
|
||||
fmt.Sprintf("CAST(ROUND(SUM(job.duration * job.num_acc) / 3600) as %s) as totalAccHours", castType),
|
||||
).From("job").GroupBy(col)
|
||||
|
||||
} else {
|
||||
// Scan columns: totalJobs, totalWalltime, totalNodeHours, totalCoreHours, totalAccHours
|
||||
// Scan columns: totalJobs, totalWalltime, totalNodes, totalNodeHours, totalCores, totalCoreHours, totalAccs, totalAccHours
|
||||
query = sq.Select("COUNT(job.id)",
|
||||
fmt.Sprintf("CAST(ROUND(SUM(job.duration) / 3600) as %s)", castType),
|
||||
fmt.Sprintf("CAST(SUM(job.num_nodes) as %s)", castType),
|
||||
fmt.Sprintf("CAST(ROUND(SUM(job.duration * job.num_nodes) / 3600) as %s)", castType),
|
||||
fmt.Sprintf("CAST(SUM(job.num_hwthreads) as %s)", castType),
|
||||
fmt.Sprintf("CAST(ROUND(SUM(job.duration * job.num_hwthreads) / 3600) as %s)", castType),
|
||||
fmt.Sprintf("CAST(SUM(job.num_acc) as %s)", castType),
|
||||
fmt.Sprintf("CAST(ROUND(SUM(job.duration * job.num_acc) / 3600) as %s)", castType),
|
||||
).From("job")
|
||||
}
|
||||
@@ -86,7 +103,7 @@ func (r *JobRepository) buildStatsQuery(
|
||||
}
|
||||
|
||||
func (r *JobRepository) getUserName(ctx context.Context, id string) string {
|
||||
user := auth.GetUser(ctx)
|
||||
user := GetUserFromContext(ctx)
|
||||
name, _ := r.FindColumnValue(user, id, "user", "name", "username", false)
|
||||
if name != "" {
|
||||
return name
|
||||
@@ -113,16 +130,28 @@ func (r *JobRepository) getCastType() string {
|
||||
func (r *JobRepository) JobsStatsGrouped(
|
||||
ctx context.Context,
|
||||
filter []*model.JobFilter,
|
||||
page *model.PageRequest,
|
||||
sortBy *model.SortByAggregate,
|
||||
groupBy *model.Aggregate) ([]*model.JobsStatistics, error) {
|
||||
|
||||
start := time.Now()
|
||||
col := groupBy2column[*groupBy]
|
||||
query := r.buildStatsQuery(filter, col)
|
||||
|
||||
query, err := SecurityCheck(ctx, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if sortBy != nil {
|
||||
sortBy := sortBy2column[*sortBy]
|
||||
query = query.OrderBy(fmt.Sprintf("%s DESC", sortBy))
|
||||
}
|
||||
if page != nil && page.ItemsPerPage != -1 {
|
||||
limit := uint64(page.ItemsPerPage)
|
||||
query = query.Offset((uint64(page.Page) - 1) * limit).Limit(limit)
|
||||
}
|
||||
|
||||
rows, err := query.RunWith(r.DB).Query()
|
||||
if err != nil {
|
||||
log.Warn("Error while querying DB for job statistics")
|
||||
@@ -133,15 +162,36 @@ func (r *JobRepository) JobsStatsGrouped(
|
||||
|
||||
for rows.Next() {
|
||||
var id sql.NullString
|
||||
var jobs, walltime, nodeHours, coreHours, accHours sql.NullInt64
|
||||
if err := rows.Scan(&id, &jobs, &walltime, &nodeHours, &coreHours, &accHours); err != nil {
|
||||
var jobs, walltime, nodes, nodeHours, cores, coreHours, accs, accHours sql.NullInt64
|
||||
if err := rows.Scan(&id, &jobs, &walltime, &nodes, &nodeHours, &cores, &coreHours, &accs, &accHours); err != nil {
|
||||
log.Warn("Error while scanning rows")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if id.Valid {
|
||||
var totalCoreHours, totalAccHours int
|
||||
var totalJobs, totalWalltime, totalNodes, totalNodeHours, totalCores, totalCoreHours, totalAccs, totalAccHours int
|
||||
|
||||
if jobs.Valid {
|
||||
totalJobs = int(jobs.Int64)
|
||||
}
|
||||
|
||||
if walltime.Valid {
|
||||
totalWalltime = int(walltime.Int64)
|
||||
}
|
||||
|
||||
if nodes.Valid {
|
||||
totalNodes = int(nodes.Int64)
|
||||
}
|
||||
if cores.Valid {
|
||||
totalCores = int(cores.Int64)
|
||||
}
|
||||
if accs.Valid {
|
||||
totalAccs = int(accs.Int64)
|
||||
}
|
||||
|
||||
if nodeHours.Valid {
|
||||
totalNodeHours = int(nodeHours.Int64)
|
||||
}
|
||||
if coreHours.Valid {
|
||||
totalCoreHours = int(coreHours.Int64)
|
||||
}
|
||||
@@ -155,9 +205,13 @@ func (r *JobRepository) JobsStatsGrouped(
|
||||
&model.JobsStatistics{
|
||||
ID: id.String,
|
||||
Name: name,
|
||||
TotalJobs: int(jobs.Int64),
|
||||
TotalWalltime: int(walltime.Int64),
|
||||
TotalJobs: totalJobs,
|
||||
TotalWalltime: totalWalltime,
|
||||
TotalNodes: totalNodes,
|
||||
TotalNodeHours: totalNodeHours,
|
||||
TotalCores: totalCores,
|
||||
TotalCoreHours: totalCoreHours,
|
||||
TotalAccs: totalAccs,
|
||||
TotalAccHours: totalAccHours})
|
||||
} else {
|
||||
stats = append(stats,
|
||||
@@ -165,7 +219,11 @@ func (r *JobRepository) JobsStatsGrouped(
|
||||
ID: id.String,
|
||||
TotalJobs: int(jobs.Int64),
|
||||
TotalWalltime: int(walltime.Int64),
|
||||
TotalNodes: totalNodes,
|
||||
TotalNodeHours: totalNodeHours,
|
||||
TotalCores: totalCores,
|
||||
TotalCoreHours: totalCoreHours,
|
||||
TotalAccs: totalAccs,
|
||||
TotalAccHours: totalAccHours})
|
||||
}
|
||||
}
|
||||
@@ -189,15 +247,18 @@ func (r *JobRepository) JobsStats(
|
||||
row := query.RunWith(r.DB).QueryRow()
|
||||
stats := make([]*model.JobsStatistics, 0, 1)
|
||||
|
||||
var jobs, walltime, nodeHours, coreHours, accHours sql.NullInt64
|
||||
if err := row.Scan(&jobs, &walltime, &nodeHours, &coreHours, &accHours); err != nil {
|
||||
var jobs, walltime, nodes, nodeHours, cores, coreHours, accs, accHours sql.NullInt64
|
||||
if err := row.Scan(&jobs, &walltime, &nodes, &nodeHours, &cores, &coreHours, &accs, &accHours); err != nil {
|
||||
log.Warn("Error while scanning rows")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if jobs.Valid {
|
||||
var totalCoreHours, totalAccHours int
|
||||
var totalNodeHours, totalCoreHours, totalAccHours int
|
||||
|
||||
if nodeHours.Valid {
|
||||
totalNodeHours = int(nodeHours.Int64)
|
||||
}
|
||||
if coreHours.Valid {
|
||||
totalCoreHours = int(coreHours.Int64)
|
||||
}
|
||||
@@ -208,6 +269,7 @@ func (r *JobRepository) JobsStats(
|
||||
&model.JobsStatistics{
|
||||
TotalJobs: int(jobs.Int64),
|
||||
TotalWalltime: int(walltime.Int64),
|
||||
TotalNodeHours: totalNodeHours,
|
||||
TotalCoreHours: totalCoreHours,
|
||||
TotalAccHours: totalAccHours})
|
||||
}
|
||||
@@ -322,7 +384,7 @@ func (r *JobRepository) AddJobCount(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
counts := make(map[string]int)
|
||||
var count int
|
||||
|
||||
for rows.Next() {
|
||||
var cnt sql.NullInt64
|
||||
@@ -330,20 +392,22 @@ func (r *JobRepository) AddJobCount(
|
||||
log.Warn("Error while scanning rows")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
count = int(cnt.Int64)
|
||||
}
|
||||
|
||||
switch kind {
|
||||
case "running":
|
||||
for _, s := range stats {
|
||||
s.RunningJobs = counts[s.ID]
|
||||
s.RunningJobs = count
|
||||
}
|
||||
case "short":
|
||||
for _, s := range stats {
|
||||
s.ShortJobs = counts[s.ID]
|
||||
s.ShortJobs = count
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("Timer JobJobCount %s", time.Since(start))
|
||||
log.Debugf("Timer AddJobCount %s", time.Since(start))
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
@@ -368,6 +432,18 @@ func (r *JobRepository) AddHistograms(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stat.HistNumCores, err = r.jobsStatisticsHistogram(ctx, "job.num_hwthreads as value", filter)
|
||||
if err != nil {
|
||||
log.Warn("Error while loading job statistics histogram: num hwthreads")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stat.HistNumAccs, err = r.jobsStatisticsHistogram(ctx, "job.num_acc as value", filter)
|
||||
if err != nil {
|
||||
log.Warn("Error while loading job statistics histogram: num acc")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugf("Timer AddHistograms %s", time.Since(start))
|
||||
return stat, nil
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ package repository
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
|
||||
)
|
||||
|
||||
func TestBuildJobStatsQuery(t *testing.T) {
|
||||
@@ -19,3 +21,15 @@ func TestBuildJobStatsQuery(t *testing.T) {
|
||||
fmt.Printf("SQL: %s\n", sql)
|
||||
|
||||
}
|
||||
|
||||
func TestJobStats(t *testing.T) {
|
||||
r := setup(t)
|
||||
|
||||
filter := &model.JobFilter{}
|
||||
stats, err := r.JobsStats(getContext(t), []*model.JobFilter{filter})
|
||||
noErr(t, err)
|
||||
|
||||
if stats[0].TotalJobs != 6 {
|
||||
t.Fatalf("Want 98, Got %d", stats[0].TotalJobs)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ package repository
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/auth"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/archive"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
@@ -68,7 +67,7 @@ func (r *JobRepository) CreateTag(tagType string, tagName string) (tagId int64,
|
||||
return res.LastInsertId()
|
||||
}
|
||||
|
||||
func (r *JobRepository) CountTags(user *auth.User) (tags []schema.Tag, counts map[string]int, err error) {
|
||||
func (r *JobRepository) CountTags(user *schema.User) (tags []schema.Tag, counts map[string]int, err error) {
|
||||
tags = make([]schema.Tag, 0, 100)
|
||||
xrows, err := r.DB.Queryx("SELECT id, tag_type, tag_name FROM tag")
|
||||
if err != nil {
|
||||
@@ -88,10 +87,10 @@ func (r *JobRepository) CountTags(user *auth.User) (tags []schema.Tag, counts ma
|
||||
LeftJoin("jobtag jt ON t.id = jt.tag_id").
|
||||
GroupBy("t.tag_name")
|
||||
|
||||
if user != nil && user.HasAnyRole([]auth.Role{auth.RoleAdmin, auth.RoleSupport}) { // ADMIN || SUPPORT: Count all jobs
|
||||
if user != nil && user.HasAnyRole([]schema.Role{schema.RoleAdmin, schema.RoleSupport}) { // ADMIN || SUPPORT: Count all jobs
|
||||
log.Debug("CountTags: User Admin or Support -> Count all Jobs for Tags")
|
||||
// Unchanged: Needs to be own case still, due to UserRole/NoRole compatibility handling in else case
|
||||
} else if user != nil && user.HasRole(auth.RoleManager) { // MANAGER: Count own jobs plus project's jobs
|
||||
} else if user != nil && user.HasRole(schema.RoleManager) { // MANAGER: Count own jobs plus project's jobs
|
||||
// Build ("project1", "project2", ...) list of variable length directly in SQL string
|
||||
q = q.Where("jt.job_id IN (SELECT id FROM job WHERE job.user = ? OR job.project IN (\""+strings.Join(user.Projects, "\",\"")+"\"))", user.Username)
|
||||
} else if user != nil { // USER OR NO ROLE (Compatibility): Only count own jobs
|
||||
|
||||
BIN
internal/repository/testdata/job.db
vendored
BIN
internal/repository/testdata/job.db
vendored
Binary file not shown.
@@ -1,137 +1,355 @@
|
||||
// Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// Copyright (C) 2023 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/auth"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/config"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/lrucache"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
var (
|
||||
userCfgRepoOnce sync.Once
|
||||
userCfgRepoInstance *UserCfgRepo
|
||||
userRepoOnce sync.Once
|
||||
userRepoInstance *UserRepository
|
||||
)
|
||||
|
||||
type UserCfgRepo struct {
|
||||
DB *sqlx.DB
|
||||
Lookup *sqlx.Stmt
|
||||
lock sync.RWMutex
|
||||
uiDefaults map[string]interface{}
|
||||
cache *lrucache.Cache
|
||||
type UserRepository struct {
|
||||
DB *sqlx.DB
|
||||
driver string
|
||||
}
|
||||
|
||||
func GetUserCfgRepo() *UserCfgRepo {
|
||||
userCfgRepoOnce.Do(func() {
|
||||
func GetUserRepository() *UserRepository {
|
||||
userRepoOnce.Do(func() {
|
||||
db := GetConnection()
|
||||
|
||||
lookupConfigStmt, err := db.DB.Preparex(`SELECT confkey, value FROM configuration WHERE configuration.username = ?`)
|
||||
if err != nil {
|
||||
log.Fatalf("db.DB.Preparex() error: %v", err)
|
||||
}
|
||||
|
||||
userCfgRepoInstance = &UserCfgRepo{
|
||||
DB: db.DB,
|
||||
Lookup: lookupConfigStmt,
|
||||
uiDefaults: config.Keys.UiDefaults,
|
||||
cache: lrucache.New(1024),
|
||||
userRepoInstance = &UserRepository{
|
||||
DB: db.DB,
|
||||
driver: db.Driver,
|
||||
}
|
||||
})
|
||||
|
||||
return userCfgRepoInstance
|
||||
return userRepoInstance
|
||||
}
|
||||
|
||||
// Return the personalised UI config for the currently authenticated
|
||||
// user or return the plain default config.
|
||||
func (uCfg *UserCfgRepo) GetUIConfig(user *auth.User) (map[string]interface{}, error) {
|
||||
if user == nil {
|
||||
uCfg.lock.RLock()
|
||||
copy := make(map[string]interface{}, len(uCfg.uiDefaults))
|
||||
for k, v := range uCfg.uiDefaults {
|
||||
copy[k] = v
|
||||
}
|
||||
uCfg.lock.RUnlock()
|
||||
return copy, nil
|
||||
}
|
||||
|
||||
data := uCfg.cache.Get(user.Username, func() (interface{}, time.Duration, int) {
|
||||
uiconfig := make(map[string]interface{}, len(uCfg.uiDefaults))
|
||||
for k, v := range uCfg.uiDefaults {
|
||||
uiconfig[k] = v
|
||||
}
|
||||
|
||||
rows, err := uCfg.Lookup.Query(user.Username)
|
||||
if err != nil {
|
||||
log.Warnf("Error while looking up user uiconfig for user '%v'", user.Username)
|
||||
return err, 0, 0
|
||||
}
|
||||
|
||||
size := 0
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
var key, rawval string
|
||||
if err := rows.Scan(&key, &rawval); err != nil {
|
||||
log.Warn("Error while scanning user uiconfig values")
|
||||
return err, 0, 0
|
||||
}
|
||||
|
||||
var val interface{}
|
||||
if err := json.Unmarshal([]byte(rawval), &val); err != nil {
|
||||
log.Warn("Error while unmarshaling raw user uiconfig json")
|
||||
return err, 0, 0
|
||||
}
|
||||
|
||||
size += len(key)
|
||||
size += len(rawval)
|
||||
uiconfig[key] = val
|
||||
}
|
||||
|
||||
// Add global ShortRunningJobsDuration setting as plot_list_hideShortRunningJobs
|
||||
uiconfig["plot_list_hideShortRunningJobs"] = config.Keys.ShortRunningJobsDuration
|
||||
|
||||
return uiconfig, 24 * time.Hour, size
|
||||
})
|
||||
if err, ok := data.(error); ok {
|
||||
log.Error("Error in returned dataset")
|
||||
func (r *UserRepository) GetUser(username string) (*schema.User, error) {
|
||||
user := &schema.User{Username: username}
|
||||
var hashedPassword, name, rawRoles, email, rawProjects sql.NullString
|
||||
if err := sq.Select("password", "ldap", "name", "roles", "email", "projects").From("user").
|
||||
Where("user.username = ?", username).RunWith(r.DB).
|
||||
QueryRow().Scan(&hashedPassword, &user.AuthSource, &name, &rawRoles, &email, &rawProjects); err != nil {
|
||||
log.Warnf("Error while querying user '%v' from database", username)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return data.(map[string]interface{}), nil
|
||||
}
|
||||
|
||||
// If the context does not have a user, update the global ui configuration
|
||||
// without persisting it! If there is a (authenticated) user, update only his
|
||||
// configuration.
|
||||
func (uCfg *UserCfgRepo) UpdateConfig(
|
||||
key, value string,
|
||||
user *auth.User) error {
|
||||
|
||||
if user == nil {
|
||||
var val interface{}
|
||||
if err := json.Unmarshal([]byte(value), &val); err != nil {
|
||||
log.Warn("Error while unmarshaling raw user config json")
|
||||
return err
|
||||
user.Password = hashedPassword.String
|
||||
user.Name = name.String
|
||||
user.Email = email.String
|
||||
if rawRoles.Valid {
|
||||
if err := json.Unmarshal([]byte(rawRoles.String), &user.Roles); err != nil {
|
||||
log.Warn("Error while unmarshaling raw roles from DB")
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if rawProjects.Valid {
|
||||
if err := json.Unmarshal([]byte(rawProjects.String), &user.Projects); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
uCfg.lock.Lock()
|
||||
defer uCfg.lock.Unlock()
|
||||
uCfg.uiDefaults[key] = val
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, err := uCfg.DB.Exec(`REPLACE INTO configuration (username, confkey, value) VALUES (?, ?, ?)`, user.Username, key, value); err != nil {
|
||||
log.Warnf("Error while replacing user config in DB for user '%v'", user.Username)
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (r *UserRepository) GetLdapUsernames() ([]string, error) {
|
||||
|
||||
var users []string
|
||||
rows, err := r.DB.Query(`SELECT username FROM user WHERE user.ldap = 1`)
|
||||
if err != nil {
|
||||
log.Warn("Error while querying usernames")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
var username string
|
||||
if err := rows.Scan(&username); err != nil {
|
||||
log.Warnf("Error while scanning for user '%s'", username)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
users = append(users, username)
|
||||
}
|
||||
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (r *UserRepository) AddUser(user *schema.User) error {
|
||||
rolesJson, _ := json.Marshal(user.Roles)
|
||||
projectsJson, _ := json.Marshal(user.Projects)
|
||||
|
||||
cols := []string{"username", "roles", "projects"}
|
||||
vals := []interface{}{user.Username, string(rolesJson), string(projectsJson)}
|
||||
|
||||
if user.Name != "" {
|
||||
cols = append(cols, "name")
|
||||
vals = append(vals, user.Name)
|
||||
}
|
||||
if user.Email != "" {
|
||||
cols = append(cols, "email")
|
||||
vals = append(vals, user.Email)
|
||||
}
|
||||
if user.Password != "" {
|
||||
password, err := bcrypt.GenerateFromPassword([]byte(user.Password), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
log.Error("Error while encrypting new user password")
|
||||
return err
|
||||
}
|
||||
cols = append(cols, "password")
|
||||
vals = append(vals, string(password))
|
||||
}
|
||||
if user.AuthSource != -1 {
|
||||
cols = append(cols, "ldap")
|
||||
vals = append(vals, int(user.AuthSource))
|
||||
}
|
||||
|
||||
if _, err := sq.Insert("user").Columns(cols...).Values(vals...).RunWith(r.DB).Exec(); err != nil {
|
||||
log.Errorf("Error while inserting new user '%v' into DB", user.Username)
|
||||
return err
|
||||
}
|
||||
|
||||
uCfg.cache.Del(user.Username)
|
||||
log.Infof("new user %#v created (roles: %s, auth-source: %d, projects: %s)", user.Username, rolesJson, user.AuthSource, projectsJson)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *UserRepository) DelUser(username string) error {
|
||||
|
||||
_, err := r.DB.Exec(`DELETE FROM user WHERE user.username = ?`, username)
|
||||
if err != nil {
|
||||
log.Errorf("Error while deleting user '%s' from DB", username)
|
||||
return err
|
||||
}
|
||||
log.Infof("deleted user '%s' from DB", username)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *UserRepository) ListUsers(specialsOnly bool) ([]*schema.User, error) {
|
||||
|
||||
q := sq.Select("username", "name", "email", "roles", "projects").From("user")
|
||||
if specialsOnly {
|
||||
q = q.Where("(roles != '[\"user\"]' AND roles != '[]')")
|
||||
}
|
||||
|
||||
rows, err := q.RunWith(r.DB).Query()
|
||||
if err != nil {
|
||||
log.Warn("Error while querying user list")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
users := make([]*schema.User, 0)
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
rawroles := ""
|
||||
rawprojects := ""
|
||||
user := &schema.User{}
|
||||
var name, email sql.NullString
|
||||
if err := rows.Scan(&user.Username, &name, &email, &rawroles, &rawprojects); err != nil {
|
||||
log.Warn("Error while scanning user list")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal([]byte(rawroles), &user.Roles); err != nil {
|
||||
log.Warn("Error while unmarshaling raw role list")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := json.Unmarshal([]byte(rawprojects), &user.Projects); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
user.Name = name.String
|
||||
user.Email = email.String
|
||||
users = append(users, user)
|
||||
}
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (r *UserRepository) AddRole(
|
||||
ctx context.Context,
|
||||
username string,
|
||||
queryrole string) error {
|
||||
|
||||
newRole := strings.ToLower(queryrole)
|
||||
user, err := r.GetUser(username)
|
||||
if err != nil {
|
||||
log.Warnf("Could not load user '%s'", username)
|
||||
return err
|
||||
}
|
||||
|
||||
exists, valid := user.HasValidRole(newRole)
|
||||
|
||||
if !valid {
|
||||
return fmt.Errorf("Supplied role is no valid option : %v", newRole)
|
||||
}
|
||||
if exists {
|
||||
return fmt.Errorf("User %v already has role %v", username, newRole)
|
||||
}
|
||||
|
||||
roles, _ := json.Marshal(append(user.Roles, newRole))
|
||||
if _, err := sq.Update("user").Set("roles", roles).Where("user.username = ?", username).RunWith(r.DB).Exec(); err != nil {
|
||||
log.Errorf("Error while adding new role for user '%s'", user.Username)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *UserRepository) RemoveRole(ctx context.Context, username string, queryrole string) error {
|
||||
oldRole := strings.ToLower(queryrole)
|
||||
user, err := r.GetUser(username)
|
||||
if err != nil {
|
||||
log.Warnf("Could not load user '%s'", username)
|
||||
return err
|
||||
}
|
||||
|
||||
exists, valid := user.HasValidRole(oldRole)
|
||||
|
||||
if !valid {
|
||||
return fmt.Errorf("Supplied role is no valid option : %v", oldRole)
|
||||
}
|
||||
if !exists {
|
||||
return fmt.Errorf("Role already deleted for user '%v': %v", username, oldRole)
|
||||
}
|
||||
|
||||
if oldRole == schema.GetRoleString(schema.RoleManager) && len(user.Projects) != 0 {
|
||||
return fmt.Errorf("Cannot remove role 'manager' while user %s still has assigned project(s) : %v", username, user.Projects)
|
||||
}
|
||||
|
||||
var newroles []string
|
||||
for _, r := range user.Roles {
|
||||
if r != oldRole {
|
||||
newroles = append(newroles, r) // Append all roles not matching requested to be deleted role
|
||||
}
|
||||
}
|
||||
|
||||
var mroles, _ = json.Marshal(newroles)
|
||||
if _, err := sq.Update("user").Set("roles", mroles).Where("user.username = ?", username).RunWith(r.DB).Exec(); err != nil {
|
||||
log.Errorf("Error while removing role for user '%s'", user.Username)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *UserRepository) AddProject(
|
||||
ctx context.Context,
|
||||
username string,
|
||||
project string) error {
|
||||
|
||||
user, err := r.GetUser(username)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !user.HasRole(schema.RoleManager) {
|
||||
return fmt.Errorf("user '%s' is not a manager!", username)
|
||||
}
|
||||
|
||||
if user.HasProject(project) {
|
||||
return fmt.Errorf("user '%s' already manages project '%s'", username, project)
|
||||
}
|
||||
|
||||
projects, _ := json.Marshal(append(user.Projects, project))
|
||||
if _, err := sq.Update("user").Set("projects", projects).Where("user.username = ?", username).RunWith(r.DB).Exec(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *UserRepository) RemoveProject(ctx context.Context, username string, project string) error {
|
||||
user, err := r.GetUser(username)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !user.HasRole(schema.RoleManager) {
|
||||
return fmt.Errorf("user '%#v' is not a manager!", username)
|
||||
}
|
||||
|
||||
if !user.HasProject(project) {
|
||||
return fmt.Errorf("user '%#v': Cannot remove project '%#v' - Does not match!", username, project)
|
||||
}
|
||||
|
||||
var exists bool
|
||||
var newprojects []string
|
||||
for _, p := range user.Projects {
|
||||
if p != project {
|
||||
newprojects = append(newprojects, p) // Append all projects not matching requested to be deleted project
|
||||
} else {
|
||||
exists = true
|
||||
}
|
||||
}
|
||||
|
||||
if exists == true {
|
||||
var result interface{}
|
||||
if len(newprojects) == 0 {
|
||||
result = "[]"
|
||||
} else {
|
||||
result, _ = json.Marshal(newprojects)
|
||||
}
|
||||
if _, err := sq.Update("user").Set("projects", result).Where("user.username = ?", username).RunWith(r.DB).Exec(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
} else {
|
||||
return fmt.Errorf("user %s already does not manage project %s", username, project)
|
||||
}
|
||||
}
|
||||
|
||||
type ContextKey string
|
||||
|
||||
const ContextUserKey ContextKey = "user"
|
||||
|
||||
func GetUserFromContext(ctx context.Context) *schema.User {
|
||||
x := ctx.Value(ContextUserKey)
|
||||
if x == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return x.(*schema.User)
|
||||
}
|
||||
|
||||
func (r *UserRepository) FetchUserInCtx(ctx context.Context, username string) (*model.User, error) {
|
||||
me := GetUserFromContext(ctx)
|
||||
if me != nil && me.Username != username &&
|
||||
me.HasNotRoles([]schema.Role{schema.RoleAdmin, schema.RoleSupport, schema.RoleManager}) {
|
||||
return nil, errors.New("forbidden")
|
||||
}
|
||||
|
||||
user := &model.User{Username: username}
|
||||
var name, email sql.NullString
|
||||
if err := sq.Select("name", "email").From("user").Where("user.username = ?", username).
|
||||
RunWith(r.DB).QueryRow().Scan(&name, &email); err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
/* This warning will be logged *often* for non-local users, i.e. users mentioned only in job-table or archive, */
|
||||
/* since FetchUser will be called to retrieve full name and mail for every job in query/list */
|
||||
// log.Warnf("User '%s' Not found in DB", username)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
log.Warnf("Error while fetching user '%s'", username)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
user.Name = name.String
|
||||
user.Email = email.String
|
||||
return user, nil
|
||||
}
|
||||
|
||||
137
internal/repository/userConfig.go
Normal file
137
internal/repository/userConfig.go
Normal file
@@ -0,0 +1,137 @@
|
||||
// Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
package repository
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/config"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/lrucache"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
var (
|
||||
userCfgRepoOnce sync.Once
|
||||
userCfgRepoInstance *UserCfgRepo
|
||||
)
|
||||
|
||||
type UserCfgRepo struct {
|
||||
DB *sqlx.DB
|
||||
Lookup *sqlx.Stmt
|
||||
lock sync.RWMutex
|
||||
uiDefaults map[string]interface{}
|
||||
cache *lrucache.Cache
|
||||
}
|
||||
|
||||
func GetUserCfgRepo() *UserCfgRepo {
|
||||
userCfgRepoOnce.Do(func() {
|
||||
db := GetConnection()
|
||||
|
||||
lookupConfigStmt, err := db.DB.Preparex(`SELECT confkey, value FROM configuration WHERE configuration.username = ?`)
|
||||
if err != nil {
|
||||
log.Fatalf("db.DB.Preparex() error: %v", err)
|
||||
}
|
||||
|
||||
userCfgRepoInstance = &UserCfgRepo{
|
||||
DB: db.DB,
|
||||
Lookup: lookupConfigStmt,
|
||||
uiDefaults: config.Keys.UiDefaults,
|
||||
cache: lrucache.New(1024),
|
||||
}
|
||||
})
|
||||
|
||||
return userCfgRepoInstance
|
||||
}
|
||||
|
||||
// Return the personalised UI config for the currently authenticated
|
||||
// user or return the plain default config.
|
||||
func (uCfg *UserCfgRepo) GetUIConfig(user *schema.User) (map[string]interface{}, error) {
|
||||
if user == nil {
|
||||
uCfg.lock.RLock()
|
||||
copy := make(map[string]interface{}, len(uCfg.uiDefaults))
|
||||
for k, v := range uCfg.uiDefaults {
|
||||
copy[k] = v
|
||||
}
|
||||
uCfg.lock.RUnlock()
|
||||
return copy, nil
|
||||
}
|
||||
|
||||
data := uCfg.cache.Get(user.Username, func() (interface{}, time.Duration, int) {
|
||||
uiconfig := make(map[string]interface{}, len(uCfg.uiDefaults))
|
||||
for k, v := range uCfg.uiDefaults {
|
||||
uiconfig[k] = v
|
||||
}
|
||||
|
||||
rows, err := uCfg.Lookup.Query(user.Username)
|
||||
if err != nil {
|
||||
log.Warnf("Error while looking up user uiconfig for user '%v'", user.Username)
|
||||
return err, 0, 0
|
||||
}
|
||||
|
||||
size := 0
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
var key, rawval string
|
||||
if err := rows.Scan(&key, &rawval); err != nil {
|
||||
log.Warn("Error while scanning user uiconfig values")
|
||||
return err, 0, 0
|
||||
}
|
||||
|
||||
var val interface{}
|
||||
if err := json.Unmarshal([]byte(rawval), &val); err != nil {
|
||||
log.Warn("Error while unmarshaling raw user uiconfig json")
|
||||
return err, 0, 0
|
||||
}
|
||||
|
||||
size += len(key)
|
||||
size += len(rawval)
|
||||
uiconfig[key] = val
|
||||
}
|
||||
|
||||
// Add global ShortRunningJobsDuration setting as plot_list_hideShortRunningJobs
|
||||
uiconfig["plot_list_hideShortRunningJobs"] = config.Keys.ShortRunningJobsDuration
|
||||
|
||||
return uiconfig, 24 * time.Hour, size
|
||||
})
|
||||
if err, ok := data.(error); ok {
|
||||
log.Error("Error in returned dataset")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return data.(map[string]interface{}), nil
|
||||
}
|
||||
|
||||
// If the context does not have a user, update the global ui configuration
|
||||
// without persisting it! If there is a (authenticated) user, update only his
|
||||
// configuration.
|
||||
func (uCfg *UserCfgRepo) UpdateConfig(
|
||||
key, value string,
|
||||
user *schema.User) error {
|
||||
|
||||
if user == nil {
|
||||
var val interface{}
|
||||
if err := json.Unmarshal([]byte(value), &val); err != nil {
|
||||
log.Warn("Error while unmarshaling raw user config json")
|
||||
return err
|
||||
}
|
||||
|
||||
uCfg.lock.Lock()
|
||||
defer uCfg.lock.Unlock()
|
||||
uCfg.uiDefaults[key] = val
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, err := uCfg.DB.Exec(`REPLACE INTO configuration (username, confkey, value) VALUES (?, ?, ?)`, user.Username, key, value); err != nil {
|
||||
log.Warnf("Error while replacing user config in DB for user '%v'", user.Username)
|
||||
return err
|
||||
}
|
||||
|
||||
uCfg.cache.Del(user.Username)
|
||||
return nil
|
||||
}
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/auth"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/config"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
@@ -22,6 +22,9 @@ func setupUserTest(t *testing.T) *UserCfgRepo {
|
||||
"kind": "file",
|
||||
"path": "./var/job-archive"
|
||||
},
|
||||
"jwts": {
|
||||
"max-age": "2m"
|
||||
},
|
||||
"clusters": [
|
||||
{
|
||||
"name": "testcluster",
|
||||
@@ -53,7 +56,7 @@ func setupUserTest(t *testing.T) *UserCfgRepo {
|
||||
|
||||
func TestGetUIConfig(t *testing.T) {
|
||||
r := setupUserTest(t)
|
||||
u := auth.User{Username: "demo"}
|
||||
u := schema.User{Username: "demo"}
|
||||
|
||||
cfg, err := r.GetUIConfig(&u)
|
||||
if err != nil {
|
||||
@@ -13,11 +13,11 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/auth"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/repository"
|
||||
"github.com/ClusterCockpit/cc-backend/internal/util"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/log"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/schema"
|
||||
"github.com/ClusterCockpit/cc-backend/web"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
@@ -81,12 +81,11 @@ func setupJobRoute(i InfoType, r *http.Request) InfoType {
|
||||
}
|
||||
|
||||
func setupUserRoute(i InfoType, r *http.Request) InfoType {
|
||||
jobRepo := repository.GetJobRepository()
|
||||
username := mux.Vars(r)["id"]
|
||||
i["id"] = username
|
||||
i["username"] = username
|
||||
// TODO: If forbidden (== err exists), redirect to error page
|
||||
if user, _ := auth.FetchUser(r.Context(), jobRepo.DB, username); user != nil {
|
||||
if user, _ := repository.GetUserRepository().FetchUserInCtx(r.Context(), username); user != nil {
|
||||
i["name"] = user.Name
|
||||
i["email"] = user.Email
|
||||
}
|
||||
@@ -125,7 +124,7 @@ func setupAnalysisRoute(i InfoType, r *http.Request) InfoType {
|
||||
|
||||
func setupTaglistRoute(i InfoType, r *http.Request) InfoType {
|
||||
jobRepo := repository.GetJobRepository()
|
||||
user := auth.GetUser(r.Context())
|
||||
user := repository.GetUserFromContext(r.Context())
|
||||
|
||||
tags, counts, err := jobRepo.CountTags(user)
|
||||
tagMap := make(map[string][]map[string]interface{})
|
||||
@@ -255,7 +254,7 @@ func SetupRoutes(router *mux.Router, buildInfo web.Build) {
|
||||
for _, route := range routes {
|
||||
route := route
|
||||
router.HandleFunc(route.Route, func(rw http.ResponseWriter, r *http.Request) {
|
||||
conf, err := userCfgRepo.GetUIConfig(auth.GetUser(r.Context()))
|
||||
conf, err := userCfgRepo.GetUIConfig(repository.GetUserFromContext(r.Context()))
|
||||
if err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@@ -268,9 +267,9 @@ func SetupRoutes(router *mux.Router, buildInfo web.Build) {
|
||||
}
|
||||
|
||||
// Get User -> What if NIL?
|
||||
user := auth.GetUser(r.Context())
|
||||
user := repository.GetUserFromContext(r.Context())
|
||||
// Get Roles
|
||||
availableRoles, _ := auth.GetValidRolesMap(user)
|
||||
availableRoles, _ := schema.GetValidRolesMap(user)
|
||||
|
||||
page := web.Page{
|
||||
Title: title,
|
||||
@@ -285,14 +284,14 @@ func SetupRoutes(router *mux.Router, buildInfo web.Build) {
|
||||
page.FilterPresets = buildFilterPresets(r.URL.Query())
|
||||
}
|
||||
|
||||
web.RenderTemplate(rw, r, route.Template, &page)
|
||||
web.RenderTemplate(rw, route.Template, &page)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func HandleSearchBar(rw http.ResponseWriter, r *http.Request, buildInfo web.Build) {
|
||||
user := auth.GetUser(r.Context())
|
||||
availableRoles, _ := auth.GetValidRolesMap(user)
|
||||
user := repository.GetUserFromContext(r.Context())
|
||||
availableRoles, _ := schema.GetValidRolesMap(user)
|
||||
|
||||
if search := r.URL.Query().Get("searchId"); search != "" {
|
||||
repo := repository.GetJobRepository()
|
||||
@@ -309,10 +308,10 @@ func HandleSearchBar(rw http.ResponseWriter, r *http.Request, buildInfo web.Buil
|
||||
case "arrayJobId":
|
||||
http.Redirect(rw, r, "/monitoring/jobs/?arrayJobId="+url.QueryEscape(strings.Trim(splitSearch[1], " ")), http.StatusFound) // All Users: Redirect to Tablequery
|
||||
case "username":
|
||||
if user.HasAnyRole([]auth.Role{auth.RoleAdmin, auth.RoleSupport, auth.RoleManager}) {
|
||||
if user.HasAnyRole([]schema.Role{schema.RoleAdmin, schema.RoleSupport, schema.RoleManager}) {
|
||||
http.Redirect(rw, r, "/monitoring/users/?user="+url.QueryEscape(strings.Trim(splitSearch[1], " ")), http.StatusFound)
|
||||
} else {
|
||||
web.RenderTemplate(rw, r, "message.tmpl", &web.Page{Title: "Error", MsgType: "alert-danger", Message: "Missing Access Rights", User: *user, Roles: availableRoles, Build: buildInfo})
|
||||
web.RenderTemplate(rw, "message.tmpl", &web.Page{Title: "Error", MsgType: "alert-danger", Message: "Missing Access Rights", User: *user, Roles: availableRoles, Build: buildInfo})
|
||||
}
|
||||
case "name":
|
||||
usernames, _ := repo.FindColumnValues(user, strings.Trim(splitSearch[1], " "), "user", "username", "name")
|
||||
@@ -320,14 +319,14 @@ func HandleSearchBar(rw http.ResponseWriter, r *http.Request, buildInfo web.Buil
|
||||
joinedNames := strings.Join(usernames, "&user=")
|
||||
http.Redirect(rw, r, "/monitoring/users/?user="+joinedNames, http.StatusFound)
|
||||
} else {
|
||||
if user.HasAnyRole([]auth.Role{auth.RoleAdmin, auth.RoleSupport, auth.RoleManager}) {
|
||||
if user.HasAnyRole([]schema.Role{schema.RoleAdmin, schema.RoleSupport, schema.RoleManager}) {
|
||||
http.Redirect(rw, r, "/monitoring/users/?user=NoUserNameFound", http.StatusPermanentRedirect)
|
||||
} else {
|
||||
web.RenderTemplate(rw, r, "message.tmpl", &web.Page{Title: "Error", MsgType: "alert-danger", Message: "Missing Access Rights", User: *user, Roles: availableRoles, Build: buildInfo})
|
||||
web.RenderTemplate(rw, "message.tmpl", &web.Page{Title: "Error", MsgType: "alert-danger", Message: "Missing Access Rights", User: *user, Roles: availableRoles, Build: buildInfo})
|
||||
}
|
||||
}
|
||||
default:
|
||||
web.RenderTemplate(rw, r, "message.tmpl", &web.Page{Title: "Warning", MsgType: "alert-warning", Message: fmt.Sprintf("Unknown search type: %s", strings.Trim(splitSearch[0], " ")), User: *user, Roles: availableRoles, Build: buildInfo})
|
||||
web.RenderTemplate(rw, "message.tmpl", &web.Page{Title: "Warning", MsgType: "alert-warning", Message: fmt.Sprintf("Unknown search type: %s", strings.Trim(splitSearch[0], " ")), User: *user, Roles: availableRoles, Build: buildInfo})
|
||||
}
|
||||
} else if len(splitSearch) == 1 {
|
||||
|
||||
@@ -342,13 +341,13 @@ func HandleSearchBar(rw http.ResponseWriter, r *http.Request, buildInfo web.Buil
|
||||
} else if jobname != "" {
|
||||
http.Redirect(rw, r, "/monitoring/jobs/?jobName="+url.QueryEscape(jobname), http.StatusFound) // JobName (contains)
|
||||
} else {
|
||||
web.RenderTemplate(rw, r, "message.tmpl", &web.Page{Title: "Info", MsgType: "alert-info", Message: "Search without result", User: *user, Roles: availableRoles, Build: buildInfo})
|
||||
web.RenderTemplate(rw, "message.tmpl", &web.Page{Title: "Info", MsgType: "alert-info", Message: "Search without result", User: *user, Roles: availableRoles, Build: buildInfo})
|
||||
}
|
||||
|
||||
} else {
|
||||
web.RenderTemplate(rw, r, "message.tmpl", &web.Page{Title: "Error", MsgType: "alert-danger", Message: "Searchbar query parameters malformed", User: *user, Roles: availableRoles, Build: buildInfo})
|
||||
web.RenderTemplate(rw, "message.tmpl", &web.Page{Title: "Error", MsgType: "alert-danger", Message: "Searchbar query parameters malformed", User: *user, Roles: availableRoles, Build: buildInfo})
|
||||
}
|
||||
} else {
|
||||
web.RenderTemplate(rw, r, "message.tmpl", &web.Page{Title: "Warning", MsgType: "alert-warning", Message: "Empty search", User: *user, Roles: availableRoles, Build: buildInfo})
|
||||
web.RenderTemplate(rw, "message.tmpl", &web.Page{Title: "Warning", MsgType: "alert-warning", Message: "Empty search", User: *user, Roles: availableRoles, Build: buildInfo})
|
||||
}
|
||||
}
|
||||
|
||||
0
internal/scheduler/slurmRestClient.go
Normal file
0
internal/scheduler/slurmRestClient.go
Normal file
14
internal/util/array.go
Normal file
14
internal/util/array.go
Normal file
@@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2023 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
package util
|
||||
|
||||
func Contains[T comparable](items []T, item T) bool {
|
||||
for _, v := range items {
|
||||
if v == item {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user