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

Add PUT endpoint for organization configuration management API #732

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
* Copyright (c) 2023-2024, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -99,7 +99,7 @@ public Response deleteDiscoveryConfig() {
@Authorization(value = "OAuth2", scopes = {

})
}, tags={ "Discovery" })
}, tags={ "Discovery", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful response.", response = Config.class),
@ApiResponse(code = 401, message = "Authentication information is missing or invalid.", response = Void.class),
Expand All @@ -112,4 +112,27 @@ public Response getDiscoveryConfig() {
return delegate.getDiscoveryConfig();
}

@Valid
@PUT
@Path("/discovery")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@ApiOperation(value = "Update organization discovery configuration.", notes = "This API provides the capability to update discovery configuration of the primary organization. <br> <b>Permission required:</b> <br> * /permission/admin/manage/identity/configmgt/update <br> <b>Scope required:</b> <br> * internal_config_mgt_update ", response = Config.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

})
}, tags={ "Discovery" })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful Response", response = Config.class),
@ApiResponse(code = 400, message = "Invalid input in the request.", response = Error.class),
@ApiResponse(code = 401, message = "Authentication information is missing or invalid.", response = Void.class),
@ApiResponse(code = 403, message = "Access forbidden.", response = Void.class),
@ApiResponse(code = 500, message = "Internal server error.", response = Error.class)
})
public Response updateDiscoveryConfig(@ApiParam(value = "" ) @Valid Config config) {

return delegate.updateDiscoveryConfig(config );
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
* Copyright (c) 2023-2024, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -36,4 +36,6 @@ public interface OrganizationConfigsApiService {
public Response deleteDiscoveryConfig();

public Response getDiscoveryConfig();

public Response updateDiscoveryConfig(Config config);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
* Copyright (c) 2023-2024, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -63,6 +63,24 @@ public void addDiscoveryConfiguration(Config config) {
}
}

/**
* Update the organization discovery configuration in the primary organization.
*
* @param config The organization discovery configuration.
*/
public void updateDiscoveryConfiguration(Config config) {

List<ConfigProperty> configProperties = config.getProperties().stream()
.map(property -> new ConfigProperty(property.getKey(), property.getValue()))
.collect(Collectors.toList());
try {
OrganizationConfigsServiceHolder.getOrganizationConfigManager().updateDiscoveryConfiguration
(new DiscoveryConfig(configProperties));
} catch (OrganizationConfigException e) {
throw handleException(e);
}
}

/**
* Fetch organization discovery configuration.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
* Copyright (c) 2023-2024, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -52,4 +52,11 @@ public Response getDiscoveryConfig() {

return Response.ok().entity(organizationConfigsService.getDiscoveryConfiguration()).build();
}

@Override
public Response updateDiscoveryConfig(Config config) {

organizationConfigsService.updateDiscoveryConfiguration(config);
return Response.ok().entity(config).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,37 @@ paths:
$ref: '#/components/responses/Conflict'
'500':
$ref: '#/components/responses/ServerError'
put:
tags:
- Discovery
summary: Update organization discovery configuration.
description: |
This API provides the capability to update discovery configuration of the primary organization. <br>
<b>Permission required:</b> <br>
* /permission/admin/manage/identity/configmgt/update <br>
<b>Scope required:</b> <br>
* internal_config_mgt_update
operationId: updateDiscoveryConfig
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Config'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/Config'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'500':
$ref: '#/components/responses/ServerError'
delete:
tags:
- Discovery
Expand Down
Loading