Skip to content

Commit

Permalink
Merge pull request #732 from Yasasr1/add-self-signup-config-org-mgt
Browse files Browse the repository at this point in the history
Add PUT endpoint for organization configuration management API
  • Loading branch information
Yasasr1 authored Nov 29, 2024
2 parents 5a5fc7c + c970d61 commit 5d24f11
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 6 deletions.
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>Scope(Permission) 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,35 @@ 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>Scope(Permission) 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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@
</org.wso2.carbon.identity.organization.management.core.version.range>

<!-- Organization management service Version -->
<org.wso2.carbon.identity.organization.management.version>1.4.52
<org.wso2.carbon.identity.organization.management.version>1.4.56
</org.wso2.carbon.identity.organization.management.version>

<!-- Unit test versions -->
Expand Down

0 comments on commit 5d24f11

Please sign in to comment.