Skip to content

Commit

Permalink
Merge pull request #508 from SujanSanjula96/ar-properties
Browse files Browse the repository at this point in the history
Add support for API Resource properties
  • Loading branch information
SujanSanjula96 authored Oct 21, 2023
2 parents b10c511 + 04bf3e6 commit f5e0231
Show file tree
Hide file tree
Showing 11 changed files with 332 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
import org.wso2.carbon.identity.api.server.api.resource.v1.Property;
import javax.validation.constraints.*;


Expand All @@ -37,6 +40,8 @@ public class APIResourceListItem {
private String identifier;
private String type;
private Boolean requiresAuthorization;
private List<Property> properties = null;

private String self;

/**
Expand Down Expand Up @@ -137,6 +142,32 @@ public void setRequiresAuthorization(Boolean requiresAuthorization) {

/**
**/
public APIResourceListItem properties(List<Property> properties) {

this.properties = properties;
return this;
}

@ApiModelProperty(value = "")
@JsonProperty("properties")
@Valid
public List<Property> getProperties() {
return properties;
}
public void setProperties(List<Property> properties) {
this.properties = properties;
}

public APIResourceListItem addPropertiesItem(Property propertiesItem) {
if (this.properties == null) {
this.properties = new ArrayList<Property>();
}
this.properties.add(propertiesItem);
return this;
}

/**
**/
public APIResourceListItem self(String self) {

this.self = self;
Expand Down Expand Up @@ -172,12 +203,13 @@ public boolean equals(java.lang.Object o) {
Objects.equals(this.identifier, apIResourceListItem.identifier) &&
Objects.equals(this.type, apIResourceListItem.type) &&
Objects.equals(this.requiresAuthorization, apIResourceListItem.requiresAuthorization) &&
Objects.equals(this.properties, apIResourceListItem.properties) &&
Objects.equals(this.self, apIResourceListItem.self);
}

@Override
public int hashCode() {
return Objects.hash(id, name, identifier, type, requiresAuthorization, self);
return Objects.hash(id, name, identifier, type, requiresAuthorization, properties, self);
}

@Override
Expand All @@ -191,6 +223,7 @@ public String toString() {
sb.append(" identifier: ").append(toIndentedString(identifier)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" requiresAuthorization: ").append(toIndentedString(requiresAuthorization)).append("\n");
sb.append(" properties: ").append(toIndentedString(properties)).append("\n");
sb.append(" self: ").append(toIndentedString(self)).append("\n");
sb.append("}");
return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
import org.wso2.carbon.identity.api.server.api.resource.v1.Property;
import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeGetModel;
import org.wso2.carbon.identity.api.server.api.resource.v1.SubscribedApplicationGetModel;
import javax.validation.constraints.*;
Expand All @@ -46,6 +47,8 @@ public class APIResourceResponse {

private List<SubscribedApplicationGetModel> subscribedApplications = null;

private List<Property> properties = null;

private String self;

/**
Expand Down Expand Up @@ -216,6 +219,32 @@ public APIResourceResponse addSubscribedApplicationsItem(SubscribedApplicationGe

/**
**/
public APIResourceResponse properties(List<Property> properties) {

this.properties = properties;
return this;
}

@ApiModelProperty(value = "")
@JsonProperty("properties")
@Valid
public List<Property> getProperties() {
return properties;
}
public void setProperties(List<Property> properties) {
this.properties = properties;
}

public APIResourceResponse addPropertiesItem(Property propertiesItem) {
if (this.properties == null) {
this.properties = new ArrayList<Property>();
}
this.properties.add(propertiesItem);
return this;
}

/**
**/
public APIResourceResponse self(String self) {

this.self = self;
Expand Down Expand Up @@ -254,12 +283,13 @@ public boolean equals(java.lang.Object o) {
Objects.equals(this.requiresAuthorization, apIResourceResponse.requiresAuthorization) &&
Objects.equals(this.scopes, apIResourceResponse.scopes) &&
Objects.equals(this.subscribedApplications, apIResourceResponse.subscribedApplications) &&
Objects.equals(this.properties, apIResourceResponse.properties) &&
Objects.equals(this.self, apIResourceResponse.self);
}

@Override
public int hashCode() {
return Objects.hash(id, name, description, identifier, type, requiresAuthorization, scopes, subscribedApplications, self);
return Objects.hash(id, name, description, identifier, type, requiresAuthorization, scopes, subscribedApplications, properties, self);
}

@Override
Expand All @@ -276,6 +306,7 @@ public String toString() {
sb.append(" requiresAuthorization: ").append(toIndentedString(requiresAuthorization)).append("\n");
sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n");
sb.append(" subscribedApplications: ").append(toIndentedString(subscribedApplications)).append("\n");
sb.append(" properties: ").append(toIndentedString(properties)).append("\n");
sb.append(" self: ").append(toIndentedString(self)).append("\n");
sb.append("}");
return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,28 @@
package org.wso2.carbon.identity.api.server.api.resource.v1;

import org.springframework.beans.factory.annotation.Autowired;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.io.InputStream;
import java.util.List;

import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceCreationModel;
import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceListResponse;
import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourcePatchModel;
import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceResponse;
import org.wso2.carbon.identity.api.server.api.resource.v1.Error;
import java.util.List;
import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeCreationModel;
import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeGetModel;
import org.wso2.carbon.identity.api.server.api.resource.v1.ApiResourcesApiService;

import javax.validation.Valid;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import io.swagger.annotations.*;

import javax.validation.constraints.*;

@Path("/api-resources")
@Api(description = "The api-resources API")

Expand All @@ -40,7 +54,7 @@ public class ApiResourcesApi {

@Consumes({ "application/json" })
@Produces({ "application/json", "application/xml", })
@ApiOperation(value = "Add a new API resource", notes = "Add a new API resource", response = APIResourceResponse.class, authorizations = {
@ApiOperation(value = "Add a new API resource", notes = "Add a new API resource <b>Permission required:</b> <br> * /permission/admin/manage/identity/apiresourcemgt/create <br> <b>Scope required:</b> <br> * internal_api_resource_create ", response = APIResourceResponse.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

Expand All @@ -65,7 +79,7 @@ public Response addAPIResource(@ApiParam(value = "This represents the API resour
@Path("/{apiResourceId}")

@Produces({ "application/json" })
@ApiOperation(value = "Delete API resource specified by the id", notes = "Delete API resource specified by the id", response = Void.class, authorizations = {
@ApiOperation(value = "Delete API resource specified by the id", notes = "Delete API resource specified by the id <b>Permission required:</b> <br> * /permission/admin/manage/identity/apiresourcemgt/delete <br> <b>Scope required:</b> <br> * internal_api_resource_delete ", response = Void.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

Expand All @@ -87,7 +101,7 @@ public Response apiResourcesApiResourceIdDelete(@ApiParam(value = "ID of the API
@Path("/{apiResourceId}")

@Produces({ "application/json" })
@ApiOperation(value = "Get API resource specified by the id", notes = "Get API resource specified by the id", response = APIResourceResponse.class, authorizations = {
@ApiOperation(value = "Get API resource specified by the id", notes = "Get API resource specified by the id <b>Permission required:</b> <br> * /permission/admin/manage/identity/apiresourcemgt/view <br> <b>Scope required:</b> <br> * internal_api_resource_view ", response = APIResourceResponse.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

Expand All @@ -109,14 +123,14 @@ public Response apiResourcesApiResourceIdGet(@ApiParam(value = "ID of the API Re
@Path("/{apiResourceId}")
@Consumes({ "application/json" })
@Produces({ "application/json", "application/xml", })
@ApiOperation(value = "Patch API resource specified by the id", notes = "Patch API resource specified by the id. Patch operation only supports \"name\", \"description\" updating and \"addedScopes\" fields at the moment.", response = APIResourceResponse.class, authorizations = {
@ApiOperation(value = "Patch API resource specified by the id", notes = "Patch API resource specified by the id. Patch operation only supports \"name\", \"description\" updating and \"addedScopes\" fields at the moment. <b>Permission required:</b> <br> * /permission/admin/manage/identity/apiresourcemgt/update <br> <b>Scope required:</b> <br> * internal_api_resource_update ", response = Void.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

})
}, tags={ "API Resources", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK", response = APIResourceResponse.class),
@ApiResponse(code = 204, message = "Not Content", response = Void.class),
@ApiResponse(code = 400, message = "Bad Request", response = Error.class),
@ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@ApiResponse(code = 403, message = "Forbidden", response = Void.class),
Expand All @@ -135,7 +149,7 @@ public Response apiResourcesApiResourceIdPatch(@ApiParam(value = "ID of the API
@Path("/{apiResourceId}/scopes")

@Produces({ "application/json" })
@ApiOperation(value = "Get API resource scopes", notes = "Get API resource scopes specified by the id", response = ScopeGetModel.class, responseContainer = "List", authorizations = {
@ApiOperation(value = "Get API resource scopes", notes = "Get API resource scopes specified by the id <b>Permission required:</b> <br> * /permission/admin/manage/identity/apiresourcemgt/view <br> <b>Scope required:</b> <br> * internal_api_resource_view ", response = ScopeGetModel.class, responseContainer = "List", authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

Expand All @@ -158,7 +172,7 @@ public Response apiResourcesApiResourceIdScopesGet(@ApiParam(value = "ID of the
@Path("/{apiResourceId}/scopes")
@Consumes({ "application/json" })
@Produces({ "application/json", "application/xml", })
@ApiOperation(value = "Add scopes to API resource", notes = "Put scopes API resource specified by the id", response = Void.class, authorizations = {
@ApiOperation(value = "Add scopes to API resource", notes = "Put scopes API resource specified by the id <b>Permission required:</b> <br> * /permission/admin/manage/identity/apiresourcemgt/update <br> <b>Scope required:</b> <br> * internal_api_resource_update ", response = Void.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

Expand All @@ -180,10 +194,10 @@ public Response apiResourcesApiResourceIdScopesPut(@ApiParam(value = "ID of the

@Valid
@DELETE
@Path("/{apiResourceId}/scopes/{scopeId}")
@Path("/{apiResourceId}/scopes/{scopeName}")

@Produces({ "application/json" })
@ApiOperation(value = "Delete API resource specified by the id", notes = "Delete API resource specified by the id", response = Void.class, authorizations = {
@ApiOperation(value = "Delete API scope specified by the name", notes = "Delete API scope specified by the name <b>Permission required:</b> <br> * /permission/admin/manage/identity/apiresourcemgt/delete <br> <b>Scope required:</b> <br> * internal_api_resource_delete ", response = Void.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

Expand All @@ -194,31 +208,31 @@ public Response apiResourcesApiResourceIdScopesPut(@ApiParam(value = "ID of the
@ApiResponse(code = 403, message = "Forbidden", response = Void.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response apiResourcesApiResourceIdScopesScopeIdDelete(@ApiParam(value = "ID of the API Resource.",required=true) @PathParam("apiResourceId") String apiResourceId, @ApiParam(value = "ID of the Scope.",required=true) @PathParam("scopeId") String scopeId) {
public Response apiResourcesApiResourceIdScopesScopeNameDelete(@ApiParam(value = "ID of the API Resource.",required=true) @PathParam("apiResourceId") String apiResourceId, @ApiParam(value = "Name of the Scope.",required=true) @PathParam("scopeName") String scopeName) {

return delegate.apiResourcesApiResourceIdScopesScopeNameDelete(apiResourceId, scopeId );
return delegate.apiResourcesApiResourceIdScopesScopeNameDelete(apiResourceId, scopeName );
}

@Valid
@GET


@Produces({ "application/json" })
@ApiOperation(value = "List all API resources in the server", notes = "List all API resources in the server", response = APIResourceListResponse.class, authorizations = {
@ApiOperation(value = "List all API resources in the server", notes = "List all API resources in the server <b>Permission required:</b> <br> * /permission/admin/manage/identity/apiresourcemgt/view <br> <b>Scope required:</b> <br> * internal_api_resource_view ", response = APIResourceListResponse.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

})
}, tags={ "API Resources", })
}, tags={ "API Resources" })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK", response = APIResourceListResponse.class),
@ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@ApiResponse(code = 403, message = "Forbidden", response = Void.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response getAPIResources( @Valid@ApiParam(value = "Base64 encoded cursor value for backward pagination. ") @QueryParam("before") String before, @Valid@ApiParam(value = "Base64 encoded cursor value for forward pagination. ") @QueryParam("after") String after, @Valid@ApiParam(value = "Condition to filter the retrieval of records. Supports 'sw', 'co', 'ew' and 'eq' operations. ") @QueryParam("filter") String filter, @Valid@ApiParam(value = "Maximum number of records to return. ") @QueryParam("limit") Integer limit, @Valid@ApiParam(value = "Specifies the required parameters in the response. This parameter is not supported yet") @QueryParam("requiredAttributes") String requiredAttributes) {
public Response getAPIResources( @Valid@ApiParam(value = "Base64 encoded cursor value for backward pagination. ") @QueryParam("before") String before, @Valid@ApiParam(value = "Base64 encoded cursor value for forward pagination. ") @QueryParam("after") String after, @Valid@ApiParam(value = "Condition to filter the retrieval of records. Supports 'sw', 'co', 'ew' and 'eq' operations. ") @QueryParam("filter") String filter, @Valid@ApiParam(value = "Maximum number of records to return. ") @QueryParam("limit") Integer limit, @Valid@ApiParam(value = "Specifies the required attributes in the response. Only 'properties' attribute is currently supported.") @QueryParam("attributes") String attributes) {

return delegate.getAPIResources(before, after, filter, limit, requiredAttributes );
return delegate.getAPIResources(before, after, filter, limit, attributes );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,20 @@

package org.wso2.carbon.identity.api.server.api.resource.v1;

import org.wso2.carbon.identity.api.server.api.resource.v1.*;
import org.wso2.carbon.identity.api.server.api.resource.v1.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.io.InputStream;
import java.util.List;

import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceCreationModel;
import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceListResponse;
import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourcePatchModel;
import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceResponse;
import org.wso2.carbon.identity.api.server.api.resource.v1.Error;
import java.util.List;
import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeCreationModel;
import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeGetModel;
import javax.ws.rs.core.Response;


Expand All @@ -39,5 +51,5 @@ public interface ApiResourcesApiService {

public Response apiResourcesApiResourceIdScopesScopeNameDelete(String apiResourceId, String scopeName);

public Response getAPIResources(String before, String after, String filter, Integer limit, String requiredAttributes);
public Response getAPIResources(String before, String after, String filter, Integer limit, String attributes);
}
Loading

0 comments on commit f5e0231

Please sign in to comment.