io.service84.clients.permission.api.SubjectScopeApi Maven / Gradle / Ivy
package io.service84.clients.permission.api;
import io.service84.clients.permission.ApiClient;
import io.service84.clients.permission.dto.ErrorDTO;
import io.service84.clients.permission.dto.SubjectScopeDTO;
import io.service84.clients.permission.dto.SubjectScopeDataDTO;
import io.service84.clients.permission.dto.SubjectScopePageDTO;
import java.util.UUID;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.util.UriComponentsBuilder;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@Component("io.service84.clients.permission.api.SubjectScopeApi")
public class SubjectScopeApi {
private ApiClient apiClient;
public SubjectScopeApi() {
this(new ApiClient());
}
@Autowired
public SubjectScopeApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Get a Page of Subject Scopes
*
* 200 - Successful operation
*
400 - Bad request
*
403 - Insufficient Permission
*
500 - Internal Server Error
* @param authentication The Authentication Header (optional)
* @param subject Subject ID (optional, default to new ArrayList<>())
* @param scope Scope Name (optional, default to new ArrayList<>())
* @param pageIndex The index of the page to get (optional)
* @param pageSize The size of the page to get (optional, default to 20)
* @return SubjectScopePageDTO
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public SubjectScopePageDTO getSubjectScopes(String authentication, List subject, List scope, String pageIndex, Integer pageSize) throws RestClientException {
return getSubjectScopesWithHttpInfo(authentication, subject, scope, pageIndex, pageSize).getBody();
}
/**
* Get a Page of Subject Scopes
*
* 200 - Successful operation
*
400 - Bad request
*
403 - Insufficient Permission
*
500 - Internal Server Error
* @param authentication The Authentication Header (optional)
* @param subject Subject ID (optional, default to new ArrayList<>())
* @param scope Scope Name (optional, default to new ArrayList<>())
* @param pageIndex The index of the page to get (optional)
* @param pageSize The size of the page to get (optional, default to 20)
* @return ResponseEntity<SubjectScopePageDTO>
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public ResponseEntity getSubjectScopesWithHttpInfo(String authentication, List subject, List scope, String pageIndex, Integer pageSize) throws RestClientException {
Object postBody = null;
String path = apiClient.expandPath("/subject_scopes", Collections.emptyMap());
final MultiValueMap queryParams = new LinkedMultiValueMap();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap cookieParams = new LinkedMultiValueMap();
final MultiValueMap formParams = new LinkedMultiValueMap();
queryParams.putAll(apiClient.parameterToMultiValueMap(ApiClient.CollectionFormat.valueOf("multi".toUpperCase(Locale.ROOT)), "subject", subject));
queryParams.putAll(apiClient.parameterToMultiValueMap(ApiClient.CollectionFormat.valueOf("multi".toUpperCase(Locale.ROOT)), "scope", scope));
queryParams.putAll(apiClient.parameterToMultiValueMap(null, "page_index", pageIndex));
queryParams.putAll(apiClient.parameterToMultiValueMap(null, "page_size", pageSize));
if (authentication != null)
headerParams.add("Authentication", apiClient.parameterToString(authentication));
final String[] accepts = {
"application/json"
};
final List accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = { };
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { "BearerAuth" };
ParameterizedTypeReference returnType = new ParameterizedTypeReference() {};
return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType);
}
/**
* Request an API Key
*
* 200 - Successful operation
*
400 - Bad request
*
403 - Insufficient Permission
*
500 - Internal Server Error
* @param subjectScopeDataDTO Scope Data (required)
* @param authentication The Authentication Header (optional)
* @return SubjectScopeDTO
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public SubjectScopeDTO grantSubjectScope(SubjectScopeDataDTO subjectScopeDataDTO, String authentication) throws RestClientException {
return grantSubjectScopeWithHttpInfo(subjectScopeDataDTO, authentication).getBody();
}
/**
* Request an API Key
*
*
200 - Successful operation
*
400 - Bad request
*
403 - Insufficient Permission
*
500 - Internal Server Error
* @param subjectScopeDataDTO Scope Data (required)
* @param authentication The Authentication Header (optional)
* @return ResponseEntity<SubjectScopeDTO>
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public ResponseEntity grantSubjectScopeWithHttpInfo(SubjectScopeDataDTO subjectScopeDataDTO, String authentication) throws RestClientException {
Object postBody = subjectScopeDataDTO;
// verify the required parameter 'subjectScopeDataDTO' is set
if (subjectScopeDataDTO == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'subjectScopeDataDTO' when calling grantSubjectScope");
}
String path = apiClient.expandPath("/subject_scopes/grant", Collections.emptyMap());
final MultiValueMap queryParams = new LinkedMultiValueMap();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap cookieParams = new LinkedMultiValueMap();
final MultiValueMap formParams = new LinkedMultiValueMap();
if (authentication != null)
headerParams.add("Authentication", apiClient.parameterToString(authentication));
final String[] accepts = {
"application/json"
};
final List accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {
"application/json"
};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { "BearerAuth" };
ParameterizedTypeReference returnType = new ParameterizedTypeReference() {};
return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType);
}
/**
* Request an API Key
*
* 204 - Subject Scope Revoked
*
400 - Bad request
*
403 - Insufficient Permission
*
500 - Internal Server Error
* @param subjectScopeDataDTO Scope Data (required)
* @param authentication The Authentication Header (optional)
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public void revokeSubjectScope(SubjectScopeDataDTO subjectScopeDataDTO, String authentication) throws RestClientException {
revokeSubjectScopeWithHttpInfo(subjectScopeDataDTO, authentication);
}
/**
* Request an API Key
*
*
204 - Subject Scope Revoked
*
400 - Bad request
*
403 - Insufficient Permission
*
500 - Internal Server Error
* @param subjectScopeDataDTO Scope Data (required)
* @param authentication The Authentication Header (optional)
* @return ResponseEntity<Void>
* @throws RestClientException if an error occurs while attempting to invoke the API
*/
public ResponseEntity revokeSubjectScopeWithHttpInfo(SubjectScopeDataDTO subjectScopeDataDTO, String authentication) throws RestClientException {
Object postBody = subjectScopeDataDTO;
// verify the required parameter 'subjectScopeDataDTO' is set
if (subjectScopeDataDTO == null) {
throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'subjectScopeDataDTO' when calling revokeSubjectScope");
}
String path = apiClient.expandPath("/subject_scopes/revoke", Collections.emptyMap());
final MultiValueMap queryParams = new LinkedMultiValueMap();
final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap cookieParams = new LinkedMultiValueMap();
final MultiValueMap formParams = new LinkedMultiValueMap();
if (authentication != null)
headerParams.add("Authentication", apiClient.parameterToString(authentication));
final String[] accepts = {
"application/json"
};
final List accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {
"application/json"
};
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { "BearerAuth" };
ParameterizedTypeReference returnType = new ParameterizedTypeReference() {};
return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType);
}
}