Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide zms endpoint to return list of roles and groups for review #2355

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions clients/go/zms/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4257,6 +4257,70 @@ func (client ZMSClient) GetDependentDomainList(service ServiceName) (*DomainList
}
}

func (client ZMSClient) GetRolesForReview(principal ResourceName) (*ReviewObjects, error) {
var data *ReviewObjects
url := client.URL + "/review/role" + encodeParams(encodeStringParam("principal", string(principal), ""))
resp, err := client.httpGet(url, nil)
if err != nil {
return data, err
}
defer resp.Body.Close()
switch resp.StatusCode {
case 200:
err = json.NewDecoder(resp.Body).Decode(&data)
if err != nil {
return data, err
}
return data, nil
default:
var errobj rdl.ResourceError
contentBytes, err := io.ReadAll(resp.Body)
if err != nil {
return data, err
}
json.Unmarshal(contentBytes, &errobj)
if errobj.Code == 0 {
errobj.Code = resp.StatusCode
}
if errobj.Message == "" {
errobj.Message = string(contentBytes)
}
return data, errobj
}
}

func (client ZMSClient) GetGroupsForReview(principal ResourceName) (*ReviewObjects, error) {
var data *ReviewObjects
url := client.URL + "/review/group" + encodeParams(encodeStringParam("principal", string(principal), ""))
resp, err := client.httpGet(url, nil)
if err != nil {
return data, err
}
defer resp.Body.Close()
switch resp.StatusCode {
case 200:
err = json.NewDecoder(resp.Body).Decode(&data)
if err != nil {
return data, err
}
return data, nil
default:
var errobj rdl.ResourceError
contentBytes, err := io.ReadAll(resp.Body)
if err != nil {
return data, err
}
json.Unmarshal(contentBytes, &errobj)
if errobj.Code == 0 {
errobj.Code = resp.StatusCode
}
if errobj.Message == "" {
errobj.Message = string(contentBytes)
}
return data, errobj
}
}

func (client ZMSClient) GetInfo() (*Info, error) {
var data *Info
url := client.URL + "/sys/info"
Expand Down
145 changes: 145 additions & 0 deletions clients/go/zms/model.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 43 additions & 1 deletion clients/go/zms/zms_schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4111,6 +4111,66 @@ public DomainList getDependentDomainList(String service) throws URISyntaxExcepti
}
}

public ReviewObjects getRolesForReview(String principal) throws URISyntaxException, IOException {
UriTemplateBuilder uriTemplateBuilder = new UriTemplateBuilder(baseUrl, "/review/role");
URIBuilder uriBuilder = new URIBuilder(uriTemplateBuilder.getUri());
if (principal != null) {
uriBuilder.setParameter("principal", principal);
}
HttpUriRequest httpUriRequest = RequestBuilder.get()
.setUri(uriBuilder.build())
.build();
if (credsHeader != null) {
httpUriRequest.addHeader(credsHeader, credsToken);
}
HttpEntity httpResponseEntity = null;
try (CloseableHttpResponse httpResponse = client.execute(httpUriRequest, httpContext)) {
int code = httpResponse.getStatusLine().getStatusCode();
httpResponseEntity = httpResponse.getEntity();
switch (code) {
case 200:
return jsonMapper.readValue(httpResponseEntity.getContent(), ReviewObjects.class);
default:
final String errorData = (httpResponseEntity == null) ? null : EntityUtils.toString(httpResponseEntity);
throw (errorData != null && !errorData.isEmpty())
? new ResourceException(code, jsonMapper.readValue(errorData, ResourceError.class))
: new ResourceException(code);
}
} finally {
EntityUtils.consumeQuietly(httpResponseEntity);
}
}

public ReviewObjects getGroupsForReview(String principal) throws URISyntaxException, IOException {
UriTemplateBuilder uriTemplateBuilder = new UriTemplateBuilder(baseUrl, "/review/group");
URIBuilder uriBuilder = new URIBuilder(uriTemplateBuilder.getUri());
if (principal != null) {
uriBuilder.setParameter("principal", principal);
}
HttpUriRequest httpUriRequest = RequestBuilder.get()
.setUri(uriBuilder.build())
.build();
if (credsHeader != null) {
httpUriRequest.addHeader(credsHeader, credsToken);
}
HttpEntity httpResponseEntity = null;
try (CloseableHttpResponse httpResponse = client.execute(httpUriRequest, httpContext)) {
int code = httpResponse.getStatusLine().getStatusCode();
httpResponseEntity = httpResponse.getEntity();
switch (code) {
case 200:
return jsonMapper.readValue(httpResponseEntity.getContent(), ReviewObjects.class);
default:
final String errorData = (httpResponseEntity == null) ? null : EntityUtils.toString(httpResponseEntity);
throw (errorData != null && !errorData.isEmpty())
? new ResourceException(code, jsonMapper.readValue(errorData, ResourceError.class))
: new ResourceException(code);
}
} finally {
EntityUtils.consumeQuietly(httpResponseEntity);
}
}

public Info getInfo() throws URISyntaxException, IOException {
UriTemplateBuilder uriTemplateBuilder = new UriTemplateBuilder(baseUrl, "/sys/info");
URIBuilder uriBuilder = new URIBuilder(uriTemplateBuilder.getUri());
Expand Down
Loading