diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/findbugs-exclude-filter.xml b/components/org.wso2.carbon.identity.api.server.api.resource/findbugs-exclude-filter.xml new file mode 100644 index 0000000000..6cf6746037 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/findbugs-exclude-filter.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/pom.xml b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/pom.xml new file mode 100644 index 0000000000..4f9431b3a3 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.api.resource + 1.2.67-SNAPSHOT + ../pom.xml + + + org.wso2.carbon.identity.api.server.api.resource.common + 1.2.67-SNAPSHOT + jar + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + org.springframework + spring-web + provided + + + javax.ws.rs + javax.ws.rs-api + provided + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.application.mgt + provided + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.api.resource.mgt + provided + + + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/ApiResourceManagementServiceHolder.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/ApiResourceManagementServiceHolder.java new file mode 100644 index 0000000000..13ef6bf64c --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/ApiResourceManagementServiceHolder.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023, 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 + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.common; + +import org.wso2.carbon.identity.api.resource.mgt.ApiResourceManager; + +/** + * Service holder class for api resource management. + */ +public class ApiResourceManagementServiceHolder { + + + + private static ApiResourceManager apiResourceManager; + + /** + * Get ApiResourceManager osgi service. + * + * @return ApiResourceManager. + */ + public static ApiResourceManager getApiResourceManager() { + + return apiResourceManager; + } + + /** + * Set ApiResourceManager osgi service. + * + * @param apiResourceManager ApiResourceManager. + */ + public static void setApiResourceManager(ApiResourceManager apiResourceManager) { + + ApiResourceManagementServiceHolder.apiResourceManager = apiResourceManager; + } + +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/factory/ApiResourceManagementOSGiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/factory/ApiResourceManagementOSGiServiceFactory.java new file mode 100644 index 0000000000..16f1368d6d --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/factory/ApiResourceManagementOSGiServiceFactory.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023, 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 + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.common.factory; + +import org.springframework.beans.factory.config.AbstractFactoryBean; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.api.resource.mgt.ApiResourceManager; + +/** + * Factory class for ApiResourceManagementOSGiService. + */ +public class ApiResourceManagementOSGiServiceFactory extends AbstractFactoryBean { + + private ApiResourceManager apiResourceManager; + + @Override + public Class getObjectType() { + + return Object.class; + } + + @Override + protected ApiResourceManager createInstance() throws Exception { + + if (this.apiResourceManager == null) { + ApiResourceManager taskOperationService = (ApiResourceManager) PrivilegedCarbonContext. + getThreadLocalCarbonContext().getOSGiService(ApiResourceManager.class, null); + if (taskOperationService != null) { + this.apiResourceManager = taskOperationService; + } else { + throw new Exception("Unable to retrieve ApiResourceManager service."); + } + } + return this.apiResourceManager; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/pom.xml new file mode 100644 index 0000000000..90bf15e52c --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/pom.xml @@ -0,0 +1,185 @@ + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.api.resource + 1.2.67-SNAPSHOT + ../pom.xml + + + WSO2 Identity Server - Applications Rest API + WSO2 Identity Server - API Resource Rest API + org.wso2.carbon.identity.api.server.api.resource.v1 + 1.2.67-SNAPSHOT + jar + + + + org.wso2.carbon.identity.organization.management.core + org.wso2.carbon.identity.organization.management.service + provided + + + org.apache.cxf + cxf-rt-frontend-jaxrs + provided + + + org.apache.cxf + cxf-rt-rs-service-description + provided + + + javax.ws.rs + javax.ws.rs-api + provided + + + io.swagger + swagger-jaxrs + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + javax.ws.rs + jsr311-api + + + com.google.guava + guava + + + + + org.springframework + spring-web + provided + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + provided + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.api.resource.mgt + provided + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.common + + + org.apache.cxf + cxf-rt-rs-extension-search + provided + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.api.resource.common + 1.2.67-SNAPSHOT + compile + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + 1.8 + 1.8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceCreationModel.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceCreationModel.java new file mode 100644 index 0000000000..47b31f09d5 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceCreationModel.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +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.ScopeCreationModel; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class ApiResourceCreationModel { + + private String name; + private String identifier; + private String description; + private Boolean requiresAuthorization; + private List scopes = null; + + + /** + **/ + public ApiResourceCreationModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "Greetings Api", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public ApiResourceCreationModel identifier(String identifier) { + + this.identifier = identifier; + return this; + } + + @ApiModelProperty(example = "greetings_api", required = true, value = "") + @JsonProperty("identifier") + @Valid + @NotNull(message = "Property identifier cannot be null.") + + public String getIdentifier() { + return identifier; + } + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + **/ + public ApiResourceCreationModel description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Greetings Api representation", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public ApiResourceCreationModel requiresAuthorization(Boolean requiresAuthorization) { + + this.requiresAuthorization = requiresAuthorization; + return this; + } + + @ApiModelProperty(example = "true", value = "") + @JsonProperty("requiresAuthorization") + @Valid + public Boolean getRequiresAuthorization() { + return requiresAuthorization; + } + public void setRequiresAuthorization(Boolean requiresAuthorization) { + this.requiresAuthorization = requiresAuthorization; + } + + /** + **/ + public ApiResourceCreationModel scopes(List scopes) { + + this.scopes = scopes; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("scopes") + @Valid + public List getScopes() { + return scopes; + } + public void setScopes(List scopes) { + this.scopes = scopes; + } + + public ApiResourceCreationModel addScopesItem(ScopeCreationModel scopesItem) { + if (this.scopes == null) { + this.scopes = new ArrayList(); + } + this.scopes.add(scopesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiResourceCreationModel apiResourceCreationModel = (ApiResourceCreationModel) o; + return Objects.equals(this.name, apiResourceCreationModel.name) && + Objects.equals(this.identifier, apiResourceCreationModel.identifier) && + Objects.equals(this.description, apiResourceCreationModel.description) && + Objects.equals(this.requiresAuthorization, apiResourceCreationModel.requiresAuthorization) && + Objects.equals(this.scopes, apiResourceCreationModel.scopes); + } + + @Override + public int hashCode() { + return Objects.hash(name, identifier, description, requiresAuthorization, scopes); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ApiResourceCreationModel {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" identifier: ").append(toIndentedString(identifier)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" requiresAuthorization: ").append(toIndentedString(requiresAuthorization)).append("\n"); + sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceListItem.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceListItem.java new file mode 100644 index 0000000000..a554272e2f --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceListItem.java @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class ApiResourceListItem { + + private String id; + private String name; + private String identifier; + private String type; + private Boolean requiresAuthorization; + private String self; + + /** + **/ + public ApiResourceListItem id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "gh43-jk34-vb34-df67", required = true, value = "") + @JsonProperty("id") + @Valid + @NotNull(message = "Property id cannot be null.") + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + /** + **/ + public ApiResourceListItem name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "Greetings Api", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public ApiResourceListItem identifier(String identifier) { + + this.identifier = identifier; + return this; + } + + @ApiModelProperty(example = "greetings_api", required = true, value = "") + @JsonProperty("identifier") + @Valid + @NotNull(message = "Property identifier cannot be null.") + + public String getIdentifier() { + return identifier; + } + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + **/ + public ApiResourceListItem type(String type) { + + this.type = type; + return this; + } + + @ApiModelProperty(example = "SYSTEM", value = "") + @JsonProperty("type") + @Valid + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + public ApiResourceListItem requiresAuthorization(Boolean requiresAuthorization) { + + this.requiresAuthorization = requiresAuthorization; + return this; + } + + @ApiModelProperty(example = "true", value = "") + @JsonProperty("requiresAuthorization") + @Valid + public Boolean getRequiresAuthorization() { + return requiresAuthorization; + } + public void setRequiresAuthorization(Boolean requiresAuthorization) { + this.requiresAuthorization = requiresAuthorization; + } + + /** + **/ + public ApiResourceListItem self(String self) { + + this.self = self; + return this; + } + + @ApiModelProperty(example = "/t/carbon.super/api/server/v1/api-resources/eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg", required = true, value = "") + @JsonProperty("self") + @Valid + @NotNull(message = "Property self cannot be null.") + + public String getSelf() { + return self; + } + public void setSelf(String self) { + this.self = self; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiResourceListItem apiResourceListItem = (ApiResourceListItem) o; + return Objects.equals(this.id, apiResourceListItem.id) && + Objects.equals(this.name, apiResourceListItem.name) && + Objects.equals(this.identifier, apiResourceListItem.identifier) && + Objects.equals(this.type, apiResourceListItem.type) && + Objects.equals(this.requiresAuthorization, apiResourceListItem.requiresAuthorization) && + Objects.equals(this.self, apiResourceListItem.self); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, identifier, type, requiresAuthorization, self); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ApiResourceListItem {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + 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(" self: ").append(toIndentedString(self)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceListResponse.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceListResponse.java new file mode 100644 index 0000000000..a0ea495d7c --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceListResponse.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +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.ApiResourceListItem; +import org.wso2.carbon.identity.api.server.api.resource.v1.PaginationLink; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class ApiResourceListResponse { + + private Integer totalResults; + private List links = new ArrayList(); + + private List apiResources = null; + + + /** + **/ + public ApiResourceListResponse totalResults(Integer totalResults) { + + this.totalResults = totalResults; + return this; + } + + @ApiModelProperty(example = "1", value = "") + @JsonProperty("totalResults") + @Valid + public Integer getTotalResults() { + return totalResults; + } + public void setTotalResults(Integer totalResults) { + this.totalResults = totalResults; + } + + /** + **/ + public ApiResourceListResponse links(List links) { + + this.links = links; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("links") + @Valid + @NotNull(message = "Property links cannot be null.") + + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public ApiResourceListResponse addLinksItem(PaginationLink linksItem) { + this.links.add(linksItem); + return this; + } + + /** + **/ + public ApiResourceListResponse apiResources(List apiResources) { + + this.apiResources = apiResources; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("apiResources") + @Valid + public List getApiResources() { + return apiResources; + } + public void setApiResources(List apiResources) { + this.apiResources = apiResources; + } + + public ApiResourceListResponse addApiResourcesItem(ApiResourceListItem apiResourcesItem) { + if (this.apiResources == null) { + this.apiResources = new ArrayList(); + } + this.apiResources.add(apiResourcesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiResourceListResponse apiResourceListResponse = (ApiResourceListResponse) o; + return Objects.equals(this.totalResults, apiResourceListResponse.totalResults) && + Objects.equals(this.links, apiResourceListResponse.links) && + Objects.equals(this.apiResources, apiResourceListResponse.apiResources); + } + + @Override + public int hashCode() { + return Objects.hash(totalResults, links, apiResources); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ApiResourceListResponse {\n"); + + sb.append(" totalResults: ").append(toIndentedString(totalResults)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append(" apiResources: ").append(toIndentedString(apiResources)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcePatchModel.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcePatchModel.java new file mode 100644 index 0000000000..bc89929801 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcePatchModel.java @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +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.ScopeCreationModel; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class ApiResourcePatchModel { + + private String name; + private String description; + private List addedScopes = null; + + private List removedScopes = null; + + + /** + **/ + public ApiResourcePatchModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "Greetings Api", value = "") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public ApiResourcePatchModel description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Greetings Api representation", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public ApiResourcePatchModel addedScopes(List addedScopes) { + + this.addedScopes = addedScopes; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("addedScopes") + @Valid + public List getAddedScopes() { + return addedScopes; + } + public void setAddedScopes(List addedScopes) { + this.addedScopes = addedScopes; + } + + public ApiResourcePatchModel addAddedScopesItem(ScopeCreationModel addedScopesItem) { + if (this.addedScopes == null) { + this.addedScopes = new ArrayList(); + } + this.addedScopes.add(addedScopesItem); + return this; + } + + /** + * This field is not supported yet. + **/ + public ApiResourcePatchModel removedScopes(List removedScopes) { + + this.removedScopes = removedScopes; + return this; + } + + @ApiModelProperty(value = "This field is not supported yet.") + @JsonProperty("removedScopes") + @Valid + public List getRemovedScopes() { + return removedScopes; + } + public void setRemovedScopes(List removedScopes) { + this.removedScopes = removedScopes; + } + + public ApiResourcePatchModel addRemovedScopesItem(String removedScopesItem) { + if (this.removedScopes == null) { + this.removedScopes = new ArrayList(); + } + this.removedScopes.add(removedScopesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiResourcePatchModel apiResourcePatchModel = (ApiResourcePatchModel) o; + return Objects.equals(this.name, apiResourcePatchModel.name) && + Objects.equals(this.description, apiResourcePatchModel.description) && + Objects.equals(this.addedScopes, apiResourcePatchModel.addedScopes) && + Objects.equals(this.removedScopes, apiResourcePatchModel.removedScopes); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, addedScopes, removedScopes); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ApiResourcePatchModel {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" addedScopes: ").append(toIndentedString(addedScopes)).append("\n"); + sb.append(" removedScopes: ").append(toIndentedString(removedScopes)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceResponse.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceResponse.java new file mode 100644 index 0000000000..8b4ce3415c --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceResponse.java @@ -0,0 +1,296 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +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.ScopeGetModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.SubscribedApplicationGetModel; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class ApiResourceResponse { + + private String id; + private String name; + private String description; + private String identifier; + private String type; + private Boolean requiresAuthorization; + private List scopes = null; + + private List subscribedApplications = null; + + private String self; + + /** + **/ + public ApiResourceResponse id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "gh43-jk34-vb34-df67", required = true, value = "") + @JsonProperty("id") + @Valid + @NotNull(message = "Property id cannot be null.") + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + /** + **/ + public ApiResourceResponse name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "Greetings Api", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public ApiResourceResponse description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Greeting Api representation", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public ApiResourceResponse identifier(String identifier) { + + this.identifier = identifier; + return this; + } + + @ApiModelProperty(example = "greetings_api", required = true, value = "") + @JsonProperty("identifier") + @Valid + @NotNull(message = "Property identifier cannot be null.") + + public String getIdentifier() { + return identifier; + } + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + **/ + public ApiResourceResponse type(String type) { + + this.type = type; + return this; + } + + @ApiModelProperty(example = "SYSTEM", value = "") + @JsonProperty("type") + @Valid + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + public ApiResourceResponse requiresAuthorization(Boolean requiresAuthorization) { + + this.requiresAuthorization = requiresAuthorization; + return this; + } + + @ApiModelProperty(example = "true", value = "") + @JsonProperty("requiresAuthorization") + @Valid + public Boolean getRequiresAuthorization() { + return requiresAuthorization; + } + public void setRequiresAuthorization(Boolean requiresAuthorization) { + this.requiresAuthorization = requiresAuthorization; + } + + /** + **/ + public ApiResourceResponse scopes(List scopes) { + + this.scopes = scopes; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("scopes") + @Valid + public List getScopes() { + return scopes; + } + public void setScopes(List scopes) { + this.scopes = scopes; + } + + public ApiResourceResponse addScopesItem(ScopeGetModel scopesItem) { + if (this.scopes == null) { + this.scopes = new ArrayList(); + } + this.scopes.add(scopesItem); + return this; + } + + /** + **/ + public ApiResourceResponse subscribedApplications(List subscribedApplications) { + + this.subscribedApplications = subscribedApplications; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("subscribedApplications") + @Valid + public List getSubscribedApplications() { + return subscribedApplications; + } + public void setSubscribedApplications(List subscribedApplications) { + this.subscribedApplications = subscribedApplications; + } + + public ApiResourceResponse addSubscribedApplicationsItem(SubscribedApplicationGetModel subscribedApplicationsItem) { + if (this.subscribedApplications == null) { + this.subscribedApplications = new ArrayList(); + } + this.subscribedApplications.add(subscribedApplicationsItem); + return this; + } + + /** + **/ + public ApiResourceResponse self(String self) { + + this.self = self; + return this; + } + + @ApiModelProperty(example = "/t/carbon.super/api/server/v1/api-resources/eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg", required = true, value = "") + @JsonProperty("self") + @Valid + @NotNull(message = "Property self cannot be null.") + + public String getSelf() { + return self; + } + public void setSelf(String self) { + this.self = self; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiResourceResponse apiResourceResponse = (ApiResourceResponse) o; + return Objects.equals(this.id, apiResourceResponse.id) && + Objects.equals(this.name, apiResourceResponse.name) && + Objects.equals(this.description, apiResourceResponse.description) && + Objects.equals(this.identifier, apiResourceResponse.identifier) && + Objects.equals(this.type, apiResourceResponse.type) && + Objects.equals(this.requiresAuthorization, apiResourceResponse.requiresAuthorization) && + Objects.equals(this.scopes, apiResourceResponse.scopes) && + Objects.equals(this.subscribedApplications, apiResourceResponse.subscribedApplications) && + Objects.equals(this.self, apiResourceResponse.self); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, description, identifier, type, requiresAuthorization, scopes, subscribedApplications, self); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ApiResourceResponse {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + 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(" scopes: ").append(toIndentedString(scopes)).append("\n"); + sb.append(" subscribedApplications: ").append(toIndentedString(subscribedApplications)).append("\n"); + sb.append(" self: ").append(toIndentedString(self)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceSearchPayload.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceSearchPayload.java new file mode 100644 index 0000000000..75a40d2a49 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceSearchPayload.java @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +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 javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class ApiResourceSearchPayload { + + private List apiResourceIds = new ArrayList(); + + private List requiredAttributes = null; + + private String filter; + private Integer limit; + + /** + **/ + public ApiResourceSearchPayload apiResourceIds(List apiResourceIds) { + + this.apiResourceIds = apiResourceIds; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("apiResourceIds") + @Valid + @NotNull(message = "Property apiResourceIds cannot be null.") + + public List getApiResourceIds() { + return apiResourceIds; + } + public void setApiResourceIds(List apiResourceIds) { + this.apiResourceIds = apiResourceIds; + } + + public ApiResourceSearchPayload addApiResourceIdsItem(String apiResourceIdsItem) { + this.apiResourceIds.add(apiResourceIdsItem); + return this; + } + + /** + **/ + public ApiResourceSearchPayload requiredAttributes(List requiredAttributes) { + + this.requiredAttributes = requiredAttributes; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("requiredAttributes") + @Valid + public List getRequiredAttributes() { + return requiredAttributes; + } + public void setRequiredAttributes(List requiredAttributes) { + this.requiredAttributes = requiredAttributes; + } + + public ApiResourceSearchPayload addRequiredAttributesItem(String requiredAttributesItem) { + if (this.requiredAttributes == null) { + this.requiredAttributes = new ArrayList(); + } + this.requiredAttributes.add(requiredAttributesItem); + return this; + } + + /** + **/ + public ApiResourceSearchPayload filter(String filter) { + + this.filter = filter; + return this; + } + + @ApiModelProperty(example = "name+eq+apiName", value = "") + @JsonProperty("filter") + @Valid + public String getFilter() { + return filter; + } + public void setFilter(String filter) { + this.filter = filter; + } + + /** + **/ + public ApiResourceSearchPayload limit(Integer limit) { + + this.limit = limit; + return this; + } + + @ApiModelProperty(example = "10", value = "") + @JsonProperty("limit") + @Valid + public Integer getLimit() { + return limit; + } + public void setLimit(Integer limit) { + this.limit = limit; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiResourceSearchPayload apiResourceSearchPayload = (ApiResourceSearchPayload) o; + return Objects.equals(this.apiResourceIds, apiResourceSearchPayload.apiResourceIds) && + Objects.equals(this.requiredAttributes, apiResourceSearchPayload.requiredAttributes) && + Objects.equals(this.filter, apiResourceSearchPayload.filter) && + Objects.equals(this.limit, apiResourceSearchPayload.limit); + } + + @Override + public int hashCode() { + return Objects.hash(apiResourceIds, requiredAttributes, filter, limit); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ApiResourceSearchPayload {\n"); + + sb.append(" apiResourceIds: ").append(toIndentedString(apiResourceIds)).append("\n"); + sb.append(" requiredAttributes: ").append(toIndentedString(requiredAttributes)).append("\n"); + sb.append(" filter: ").append(toIndentedString(filter)).append("\n"); + sb.append(" limit: ").append(toIndentedString(limit)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceSearchResult.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceSearchResult.java new file mode 100644 index 0000000000..cfe87ee750 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourceSearchResult.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +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.ScopeGetModel; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class ApiResourceSearchResult { + + private String id; + private String name; + private String description; + private String identifier; + private String type; + private List scopes = null; + + + /** + **/ + public ApiResourceSearchResult id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "gh43-jk34-vb34-df67", required = true, value = "") + @JsonProperty("id") + @Valid + @NotNull(message = "Property id cannot be null.") + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + /** + **/ + public ApiResourceSearchResult name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "Greetings Api", value = "") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public ApiResourceSearchResult description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Greetings Api representation", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public ApiResourceSearchResult identifier(String identifier) { + + this.identifier = identifier; + return this; + } + + @ApiModelProperty(example = "greetings_api", value = "") + @JsonProperty("identifier") + @Valid + public String getIdentifier() { + return identifier; + } + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + **/ + public ApiResourceSearchResult type(String type) { + + this.type = type; + return this; + } + + @ApiModelProperty(example = "SYSTEM", value = "") + @JsonProperty("type") + @Valid + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + public ApiResourceSearchResult scopes(List scopes) { + + this.scopes = scopes; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("scopes") + @Valid + public List getScopes() { + return scopes; + } + public void setScopes(List scopes) { + this.scopes = scopes; + } + + public ApiResourceSearchResult addScopesItem(ScopeGetModel scopesItem) { + if (this.scopes == null) { + this.scopes = new ArrayList(); + } + this.scopes.add(scopesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiResourceSearchResult apiResourceSearchResult = (ApiResourceSearchResult) o; + return Objects.equals(this.id, apiResourceSearchResult.id) && + Objects.equals(this.name, apiResourceSearchResult.name) && + Objects.equals(this.description, apiResourceSearchResult.description) && + Objects.equals(this.identifier, apiResourceSearchResult.identifier) && + Objects.equals(this.type, apiResourceSearchResult.type) && + Objects.equals(this.scopes, apiResourceSearchResult.scopes); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, description, identifier, type, scopes); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ApiResourceSearchResult {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" identifier: ").append(toIndentedString(identifier)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcesApi.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcesApi.java new file mode 100644 index 0000000000..fe473161b2 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcesApi.java @@ -0,0 +1,264 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +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.ApiResourceSearchPayload; +import org.wso2.carbon.identity.api.server.api.resource.v1.ApiResourceSearchResult; +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") + +public class ApiResourcesApi { + + @Autowired + private ApiResourcesApiService delegate; + + @Valid + @POST + + @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 = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Api Resources", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = ApiResourceResponse.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), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 409, message = "Conflict", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response addApiResource(@ApiParam(value = "This represents the Api resource to be created." ,required=true) @Valid ApiResourceCreationModel apiResourceCreationModel) { + + return delegate.addApiResource(apiResourceCreationModel ); + } + + @Valid + @DELETE + @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 = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Api Resources", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "No Content", response = Void.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 apiResourcesApiResourceIdDelete(@ApiParam(value = "ID of the Api Resource.",required=true) @PathParam("apiResourceId") String apiResourceId) { + + return delegate.apiResourcesApiResourceIdDelete(apiResourceId ); + } + + @Valid + @GET + @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 = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Api Resources", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = ApiResourceResponse.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 apiResourcesApiResourceIdGet(@ApiParam(value = "ID of the Api Resource.",required=true) @PathParam("apiResourceId") String apiResourceId) { + + return delegate.apiResourcesApiResourceIdGet(apiResourceId ); + } + + @Valid + @PATCH + @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 = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Api Resources", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = ApiResourceResponse.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), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 409, message = "Conflict", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class), + @ApiResponse(code = 501, message = "Not Implemented", response = Error.class) + }) + public Response apiResourcesApiResourceIdPatch(@ApiParam(value = "ID of the Api Resource.",required=true) @PathParam("apiResourceId") String apiResourceId, @ApiParam(value = "This represents the Api resource to be patched." ,required=true) @Valid ApiResourcePatchModel apiResourcePatchModel) { + + return delegate.apiResourcesApiResourceIdPatch(apiResourceId, apiResourcePatchModel ); + } + + @Valid + @GET + @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 = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Api Resource Scopes", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = ScopeGetModel.class, responseContainer = "List"), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response apiResourcesApiResourceIdScopesGet(@ApiParam(value = "ID of the Api Resource.",required=true) @PathParam("apiResourceId") String apiResourceId) { + + return delegate.apiResourcesApiResourceIdScopesGet(apiResourceId ); + } + + @Valid + @PUT + @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 = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Api Resource Scopes", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "No 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), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 409, message = "Conflict", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response apiResourcesApiResourceIdScopesPut(@ApiParam(value = "ID of the Api Resource.",required=true) @PathParam("apiResourceId") String apiResourceId, @ApiParam(value = "This represents the Api resource to be patched." ,required=true) @Valid List scopeCreationModel) { + + return delegate.apiResourcesApiResourceIdScopesPut(apiResourceId, scopeCreationModel ); + } + + @Valid + @DELETE + @Path("/{apiResourceId}/scopes/{scopeId}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Delete Api resource specified by the id", notes = "Delete Api resource specified by the id", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Api Resource Scopes", }) + @ApiResponses(value = { + @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 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) { + + return delegate.apiResourcesApiResourceIdScopesScopeIdDelete(apiResourceId, scopeId ); + } + + @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 = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, 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) { + + return delegate.getApiResources(before, after, filter, limit, requiredAttributes ); + } + + @Valid + @POST + @Path("/.search") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Search Api Resources", notes = "Search Api Resource attributes by Api Resource IDs. RequiredAttributes fields currently supports \"scopes\" value. Filter and Limit fields are not supported yet.", response = ApiResourceSearchResult.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Api Resources" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = ApiResourceSearchResult.class, responseContainer = "List"), + @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), + @ApiResponse(code = 500, message = "Server Error", response = Error.class), + @ApiResponse(code = 501, message = "Not Implemented", response = Error.class) + }) + public Response searchApiResources(@ApiParam(value = "This represents the Api resource IDs and attributes to be searched." ,required=true) @Valid ApiResourceSearchPayload apiResourceSearchPayload) { + + return delegate.searchApiResources(apiResourceSearchPayload ); + } + +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcesApiService.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcesApiService.java new file mode 100644 index 0000000000..57bd4b0261 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcesApiService.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +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.ApiResourceSearchPayload; +import org.wso2.carbon.identity.api.server.api.resource.v1.ApiResourceSearchResult; +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; + + +public interface ApiResourcesApiService { + + public Response addApiResource(ApiResourceCreationModel apiResourceCreationModel); + + public Response apiResourcesApiResourceIdDelete(String apiResourceId); + + public Response apiResourcesApiResourceIdGet(String apiResourceId); + + public Response apiResourcesApiResourceIdPatch(String apiResourceId, ApiResourcePatchModel apiResourcePatchModel); + + public Response apiResourcesApiResourceIdScopesGet(String apiResourceId); + + public Response apiResourcesApiResourceIdScopesPut(String apiResourceId, List scopeCreationModel); + + public Response apiResourcesApiResourceIdScopesScopeIdDelete(String apiResourceId, String scopeId); + + public Response getApiResources(String before, String after, String filter, Integer limit, String requiredAttributes); + + public Response searchApiResources(ApiResourceSearchPayload apiResourceSearchPayload); +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/Error.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/Error.java new file mode 100644 index 0000000000..b2b330f3ac --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/Error.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class Error { + + private String code; + private String message; + private String description; + private String traceId; + + /** + **/ + public Error code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "AAA-00000", value = "") + @JsonProperty("code") + @Valid + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + **/ + public Error message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "Some Error Message", value = "") + @JsonProperty("message") + @Valid + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + **/ + public Error description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Some Error Description", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public Error traceId(String traceId) { + + this.traceId = traceId; + return this; + } + + @ApiModelProperty(example = "e0fbcfeb-3617-43c4-8dd0-7b7d38e13047", value = "") + @JsonProperty("traceId") + @Valid + public String getTraceId() { + return traceId; + } + public void setTraceId(String traceId) { + this.traceId = traceId; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error error = (Error) o; + return Objects.equals(this.code, error.code) && + Objects.equals(this.message, error.message) && + Objects.equals(this.description, error.description) && + Objects.equals(this.traceId, error.traceId); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, description, traceId); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" traceId: ").append(toIndentedString(traceId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ErrorListItem.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ErrorListItem.java new file mode 100644 index 0000000000..b47eb51c72 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ErrorListItem.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2023, 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 + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + +/** + * Description of individual errors that may have occurred during a request. + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Description of individual errors that may have occurred during a request.") +public class ErrorListItem { + + private String code; + private String message; + private String description; + + /** + * Error code (i.e 400, 404 etc) + **/ + public ErrorListItem code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(required = true, value = "Error code (i.e 400, 404 etc)") + @JsonProperty("code") + @Valid + @NotNull(message = "Property code cannot be null.") + + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + * Description about individual errors occurred + **/ + public ErrorListItem message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(required = true, value = "Description about individual errors occurred ") + @JsonProperty("message") + @Valid + @NotNull(message = "Property message cannot be null.") + + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + * A detail description about the error message. + **/ + public ErrorListItem description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(value = "A detail description about the error message. ") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ErrorListItem errorListItem = (ErrorListItem) o; + return Objects.equals(this.code, errorListItem.code) && + Objects.equals(this.message, errorListItem.message) && + Objects.equals(this.description, errorListItem.description); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, description); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorListItem {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/PaginatedResponse.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/PaginatedResponse.java new file mode 100644 index 0000000000..af15e38649 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/PaginatedResponse.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + +public class PaginatedResponse { + + private List links = new ArrayList(); + + private List apiResources = null; + + + /** + **/ + public PaginatedResponse links(List links) { + + this.links = links; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("links") + @Valid + @NotNull(message = "Property links cannot be null.") + + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public PaginatedResponse addLinksItem(PaginationLink linksItem) { + this.links.add(linksItem); + return this; + } + + /** + **/ + public PaginatedResponse apiResources(List apiResources) { + + this.apiResources = apiResources; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("apiResources") + @Valid + public List getApiResources() { + return apiResources; + } + public void setApiResources(List apiResources) { + this.apiResources = apiResources; + } + + public PaginatedResponse addApiResourcesItem(ApiResourceListItem apiResourcesItem) { + if (this.apiResources == null) { + this.apiResources = new ArrayList(); + } + this.apiResources.add(apiResourcesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PaginatedResponse paginatedResponse = (PaginatedResponse) o; + return Objects.equals(this.links, paginatedResponse.links) && + Objects.equals(this.apiResources, paginatedResponse.apiResources); + } + + @Override + public int hashCode() { + return Objects.hash(links, apiResources); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class PaginatedResponse {\n"); + + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append(" apiResources: ").append(toIndentedString(apiResources)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/PaginationLink.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/PaginationLink.java new file mode 100644 index 0000000000..62fb9adff9 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/PaginationLink.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class PaginationLink { + + private String rel; + private String href; + + /** + **/ + public PaginationLink rel(String rel) { + + this.rel = rel; + return this; + } + + @ApiModelProperty(example = "before", value = "") + @JsonProperty("rel") + @Valid + public String getRel() { + return rel; + } + public void setRel(String rel) { + this.rel = rel; + } + + /** + **/ + public PaginationLink href(String href) { + + this.href = href; + return this; + } + + @ApiModelProperty(example = "/o/orgName/api-resources?after=NDoy", value = "") + @JsonProperty("href") + @Valid + public String getHref() { + return href; + } + public void setHref(String href) { + this.href = href; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PaginationLink paginationLink = (PaginationLink) o; + return Objects.equals(this.rel, paginationLink.rel) && + Objects.equals(this.href, paginationLink.href); + } + + @Override + public int hashCode() { + return Objects.hash(rel, href); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class PaginationLink {\n"); + + sb.append(" rel: ").append(toIndentedString(rel)).append("\n"); + sb.append(" href: ").append(toIndentedString(href)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopeCreationModel.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopeCreationModel.java new file mode 100644 index 0000000000..44bb02dd60 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopeCreationModel.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class ScopeCreationModel { + + private String name; + private String displayName; + private String description; + + /** + **/ + public ScopeCreationModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "greetings:write", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public ScopeCreationModel displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "Write Greetings", value = "") + @JsonProperty("displayName") + @Valid + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + **/ + public ScopeCreationModel description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Allows writing greetings", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScopeCreationModel scopeCreationModel = (ScopeCreationModel) o; + return Objects.equals(this.name, scopeCreationModel.name) && + Objects.equals(this.displayName, scopeCreationModel.displayName) && + Objects.equals(this.description, scopeCreationModel.description); + } + + @Override + public int hashCode() { + return Objects.hash(name, displayName, description); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ScopeCreationModel {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopeGetModel.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopeGetModel.java new file mode 100644 index 0000000000..a0f08ae828 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopeGetModel.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class ScopeGetModel { + + private String id; + private String displayName; + private String name; + private String description; + + /** + **/ + public ScopeGetModel id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "sf23-fg34-fy53-hj23", required = true, value = "") + @JsonProperty("id") + @Valid + @NotNull(message = "Property id cannot be null.") + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + /** + **/ + public ScopeGetModel displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "Write", required = true, value = "") + @JsonProperty("displayName") + @Valid + @NotNull(message = "Property displayName cannot be null.") + + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + **/ + public ScopeGetModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "greetings:write", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public ScopeGetModel description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Allow writing greetings", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScopeGetModel scopeGetModel = (ScopeGetModel) o; + return Objects.equals(this.id, scopeGetModel.id) && + Objects.equals(this.displayName, scopeGetModel.displayName) && + Objects.equals(this.name, scopeGetModel.name) && + Objects.equals(this.description, scopeGetModel.description); + } + + @Override + public int hashCode() { + return Objects.hash(id, displayName, name, description); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ScopeGetModel {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopesApi.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopesApi.java new file mode 100644 index 0000000000..71728eb394 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopesApi.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +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.Error; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeGetModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopesApiService; + +import javax.validation.Valid; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import io.swagger.annotations.*; + +import javax.validation.constraints.*; + +@Path("/scopes") +@Api(description = "The scopes API") + +public class ScopesApi { + + @Autowired + private ScopesApiService delegate; + + @Valid + @GET + + + @Produces({ "application/json" }) + @ApiOperation(value = "Get all scopes in the tenant", notes = "Get all scopes in the tenant", response = ScopeGetModel.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Api Resource Scopes" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = ScopeGetModel.class, responseContainer = "List"), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response scopesGet( @Valid@ApiParam(value = "Condition to filter the retrieval of records. Supports 'sw', 'co', 'ew' and 'eq' operations. ") @QueryParam("filter") String filter) { + + return delegate.scopesGet(filter ); + } + +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopesApiService.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopesApiService.java new file mode 100644 index 0000000000..3a5f7c42d7 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopesApiService.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +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.Error; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeGetModel; +import javax.ws.rs.core.Response; + + +public interface ScopesApiService { + + public Response scopesGet(String filter); +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/SubscribedApplicationGetModel.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/SubscribedApplicationGetModel.java new file mode 100644 index 0000000000..12d0242b9b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/SubscribedApplicationGetModel.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class SubscribedApplicationGetModel { + + private String name; + private String id; + + /** + **/ + public SubscribedApplicationGetModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "Application1", value = "") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public SubscribedApplicationGetModel id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "23fd-23gd-54vv-sdhf", value = "") + @JsonProperty("id") + @Valid + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SubscribedApplicationGetModel subscribedApplicationGetModel = (SubscribedApplicationGetModel) o; + return Objects.equals(this.name, subscribedApplicationGetModel.name) && + Objects.equals(this.id, subscribedApplicationGetModel.id); + } + + @Override + public int hashCode() { + return Objects.hash(name, id); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class SubscribedApplicationGetModel {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/factories/ApiResourcesApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/factories/ApiResourcesApiServiceFactory.java new file mode 100644 index 0000000000..b7ac9f5961 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/factories/ApiResourcesApiServiceFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1.factories; + +import org.wso2.carbon.identity.api.server.api.resource.v1.ApiResourcesApiService; +import org.wso2.carbon.identity.api.server.api.resource.v1.impl.ApiResourcesApiServiceImpl; + +public class ApiResourcesApiServiceFactory { + + private final static ApiResourcesApiService service = new ApiResourcesApiServiceImpl(); + + public static ApiResourcesApiService getApiResourcesApi() + { + return service; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/factories/ScopesApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/factories/ScopesApiServiceFactory.java new file mode 100644 index 0000000000..0bbd7bef4f --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/factories/ScopesApiServiceFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1.factories; + +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopesApiService; +import org.wso2.carbon.identity.api.server.api.resource.v1.impl.ScopesApiServiceImpl; + +public class ScopesApiServiceFactory { + + private final static ScopesApiService service = new ScopesApiServiceImpl(); + + public static ScopesApiService getScopesApi() + { + return service; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/constants/ApiResourceMgtEndpointConstants.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/constants/ApiResourceMgtEndpointConstants.java new file mode 100644 index 0000000000..daeb30ec01 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/constants/ApiResourceMgtEndpointConstants.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2023, 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 + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1.constants; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Constants related to API resource management. + */ +public class ApiResourceMgtEndpointConstants { + + public static final String API_RESOURCE_MANAGEMENT_PREFIX = "API-RESOURCE-"; + public static final String API_RESOURCE_PATH_COMPONENT = "/api-resources"; + private static final List allowedAttributeList = new ArrayList<>(); + public static final List ALLOWED_SEARCH_ATTRIBUTES = Collections.unmodifiableList(allowedAttributeList); + public static final Integer DEFAULT_LIMIT = 10; + public static final String ASC_SORT_ORDER = "ASC"; + public static final String DESC_SORT_ORDER = "DESC"; + + static { + allowedAttributeList.add("description"); + allowedAttributeList.add("type"); + allowedAttributeList.add("requires_authorization"); + allowedAttributeList.add("scopes"); + } + + /** + * Enum for error messages. + */ + public enum ErrorMessage { + + // Client errors. + ERROR_CODE_API_RESOURCE_LIMIT_REACHED("60001", + "Unable to create an API resource.", + "Maximum number of allowed API resources have been reached."), + ERROR_CODE_API_RESOURCE_NOT_FOUND("60002", + "Unable to find the API resource.", + "Unable to find the API resource with the id: %s in the tenant domain."), + ERROR_CODE_INVALID_API_RESOURCE_NAME("60003", + "Invalid API resource name provided.", "API resource name is required."), + ERROR_CODE_INVALID_API_RESOURCE_IDENTIFIER("60004", + "Invalid API resource identifier provided.", "API resource identifier is required."), + ERROR_CODE_INVALID_SCOPE_NAME("60005", + "Invalid scope name provided.", "Scope name is required."), + ERROR_CODE_REMOVED_SCOPES_PATCH_NOT_SUPPORTED("60004", + "Removed scopes patching is not supported yet.", + "Removed scopes patching is not supported yet for API resources."), + ERROR_CODE_INVALID_SEARCH_ATTRIBUTE("60005", + "Invalid search attribute.", + "Invalid search attribute: %s."), + + + // Server errors. + ERROR_CODE_ADD_API_RESOURCE("65001", "Error while adding api resource.", "Server encountered an error while " + + "adding the api resource."), + + ERROR_CODE_GET_API_RESOURCES("65002", "Error while retrieving api resources.", "Server encountered an error " + + "while retrieving api resources."), + ERROR_CODE_DELETE_API_RESOURCE("65003", "Error while deleting api resource.", "Server encountered an error " + + "while deleting the api resource."), + + ERROR_CODE_GET_API_RESOURCE("65004", "Error while retrieving api resource.", "Server encountered an error " + + "while retrieving the api resource by the id: %s."), + ERROR_CODE_GET_SCOPES_BY_API_ID("65005", "Error while retrieving scopes by api id.", "Server encountered an " + + "error while retrieving scopes by the api id: %s."), + ERROR_CODE_DELETE_SCOPE_BY_ID("65006", "Error while deleting scope by id.", "Server encountered an error " + + "while deleting the scope by the id: %s."), + ERROR_CODE_SEARCH_API_RESOURCES("65007", "Error while searching api resources.", "Server encountered an " + + "error while searching api resources."), + ERROR_CODE_PUT_SCOPES_BY_API_ID("65008", "Error while updating scopes by api id.", "Server encountered an " + + "error while updating scopes by the api id: %s."), + ERROR_CODE_PATCH_API_RESOURCE("65009", "Error while updating api resource.", "Server encountered an error " + + "while updating the api resource by the id: %s."), + ERROR_CODE_GET_SCOPES_BY_TENANT("65010", "Error while retrieving scopes by tenant domain.", + "Server encountered an error while retrieving scopes by the tenant domain: %s."), + ; + private final String code; + private final String message; + private final String description; + + ErrorMessage(String code, String message, String description) { + + this.code = code; + this.message = message; + this.description = description; + } + + public String getCode() { + + return API_RESOURCE_MANAGEMENT_PREFIX + code; + } + + public String getMessage() { + + return message; + } + + public String getDescription() { + + return description; + } + + @Override + public String toString() { + + return code + " | " + message; + } + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerApiResourceManagementService.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerApiResourceManagementService.java new file mode 100644 index 0000000000..a99da39193 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerApiResourceManagementService.java @@ -0,0 +1,473 @@ +/* + * Copyright (c) 2023, 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 + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1.core; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.identity.api.resource.mgt.ApiResourceManagementException; +import org.wso2.carbon.identity.api.resource.mgt.model.ApiResourceSearchResult; +import org.wso2.carbon.identity.api.server.api.resource.common.ApiResourceManagementServiceHolder; +import org.wso2.carbon.identity.api.server.api.resource.v1.ApiResourceCreationModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.ApiResourceListItem; +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.PaginationLink; +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.constants.ApiResourceMgtEndpointConstants; +import org.wso2.carbon.identity.api.server.api.resource.v1.constants.ApiResourceMgtEndpointConstants.ErrorMessage; +import org.wso2.carbon.identity.api.server.api.resource.v1.util.ApiResourceManagementEndpointUtil; +import org.wso2.carbon.identity.api.server.common.ContextLoader; +import org.wso2.carbon.identity.application.common.model.ApiResource; +import org.wso2.carbon.identity.application.common.model.Scope; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.ApiResourceMgtEndpointConstants.ASC_SORT_ORDER; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.ApiResourceMgtEndpointConstants.DEFAULT_LIMIT; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.ApiResourceMgtEndpointConstants.DESC_SORT_ORDER; +import static org.wso2.carbon.identity.api.server.common.Constants.V1_API_PATH_COMPONENT; + +/** + * Server Api Resource Management Service. + */ +public class ServerApiResourceManagementService { + + private static final ServerApiResourceManagementService instance = new ServerApiResourceManagementService(); + + private static final Log log = LogFactory.getLog(ServerApiResourceManagementService.class); + + private ServerApiResourceManagementService() { + + } + + public static ServerApiResourceManagementService getInstance() { + + return instance; + } + + /** + * Add Api resource. + * + * @param apIResourceCreationModel Api resource creation model. + * @return Response. + */ + public ApiResourceResponse addApiResourceWithResourceId(ApiResourceCreationModel apIResourceCreationModel) { + + if (log.isDebugEnabled()) { + log.debug("Adding Api resource with resource id: " + apIResourceCreationModel.getIdentifier()); + } + ApiResource createdApiResource; + try { + ApiResource apiResource = createApiResource(apIResourceCreationModel); + createdApiResource = ApiResourceManagementServiceHolder.getApiResourceManager() + .addApiResource(apiResource, ContextLoader.getTenantDomainFromContext()); + + if (createdApiResource == null) { + log.error(ErrorMessage.ERROR_CODE_ADD_API_RESOURCE.getDescription()); + throw ApiResourceManagementEndpointUtil.handleException(Response.Status.INTERNAL_SERVER_ERROR, + ErrorMessage.ERROR_CODE_ADD_API_RESOURCE); + } + } catch (ApiResourceManagementException e) { + throw ApiResourceManagementEndpointUtil.handleApiResourceMgtException(e); + } + return buildApiResourceResponse(createdApiResource); + } + + /** + * Build ApiResourceResponse from ApiResource. + * + * @param apiResource ApiResource object. + * @return ApiResourceResponse object. + */ + private ApiResourceResponse buildApiResourceResponse(ApiResource apiResource) { + + ApiResourceResponse apiResourceResponse = new ApiResourceResponse(); + apiResourceResponse.setId(apiResource.getId()); + apiResourceResponse.setName(apiResource.getName()); + apiResourceResponse.setIdentifier(apiResource.getIdentifier()); + apiResourceResponse.setDescription(apiResource.getDescription()); + apiResourceResponse.setScopes(apiResource.getScopes().stream().map(this::buildScopeGetResponse) + .collect(Collectors.toList())); + apiResourceResponse.setRequiresAuthorization(apiResource.isRequiresAuthorization()); + return apiResourceResponse; + } + + /** + * Build ScopeGetModel from Scope. + * + * @param scope Scope object. + * @return ScopeGetModel object. + */ + private ScopeGetModel buildScopeGetResponse(Scope scope) { + + ScopeGetModel scopeGetModel = new ScopeGetModel(); + scopeGetModel.setId(scope.getId()); + scopeGetModel.setDisplayName(scope.getName()); + scopeGetModel.setDescription(scope.getDescription()); + return scopeGetModel; + } + + /** + * Create Api resource from the Api resource creation model. + * + * @param apIResourceCreationModel Api resource creation model. + * @return Api resource. + */ + private ApiResource createApiResource(ApiResourceCreationModel apIResourceCreationModel) + throws ApiResourceManagementException { + + ApiResource apiResource = new ApiResource(); + apiResource.setName(apIResourceCreationModel.getName()); + apiResource.setIdentifier(apIResourceCreationModel.getIdentifier()); + apiResource.setDescription(apIResourceCreationModel.getDescription()); + apiResource.setScopes(createScopes(apIResourceCreationModel.getScopes())); + apiResource.setRequiresAuthorization(apIResourceCreationModel.getRequiresAuthorization()); + ApiResourceManagementEndpointUtil.validateApiResource(apiResource); + return apiResource; + } + + /** + * Create scopes from the scope creation models. + * + * @param scopeCreationModels Scope creation models. + * @return List of scopes. + */ + private List createScopes(List scopeCreationModels) + throws ApiResourceManagementException { + + List scopes = new ArrayList<>(); + if (scopeCreationModels == null) { + return scopes; + } + for (ScopeCreationModel scopeCreationModel : scopeCreationModels) { + Scope scope = new Scope(); + scope.setName(scopeCreationModel.getName()); + scope.setDisplayName(scopeCreationModel.getDisplayName()); + scope.setDescription(scopeCreationModel.getDescription()); + scopes.add(scope); + } + ApiResourceManagementEndpointUtil.validateScopes(scopes); + return scopes; + } + + /** + * Get Api Resources. + * + * @param before - before parameter for cursor based pagination. + * @param after - after parameter for cursor based pagination. + * @param filter - filter parameter. + * @return Response with Api Resources list. + */ + public ApiResourceListResponse getApiResources(String before, String after, String filter, Integer limit) { + + ApiResourceListResponse apiResourceListResponse = new ApiResourceListResponse(); + + try { + // Set default values if the parameters are not set. + limit = limit == null ? DEFAULT_LIMIT : limit; + + // Set the pagination sort order. + String paginationSortOrder = StringUtils.isNotBlank(before) ? DESC_SORT_ORDER : ASC_SORT_ORDER; + + ApiResourceSearchResult apiResourceSearchResult = ApiResourceManagementServiceHolder.getApiResourceManager() + .getApiResources(before, after, limit + 1, filter, paginationSortOrder, + ContextLoader.getTenantDomainFromContext()); + List apiResources = apiResourceSearchResult.getApiResources(); + + if (limit != 0 && CollectionUtils.isNotEmpty(apiResources)) { + boolean hasMoreItems = apiResources.size() > limit; + boolean needsReverse = StringUtils.isNotBlank(before); + boolean isFirstPage = (StringUtils.isBlank(before) && StringUtils.isBlank(after)) || + (StringUtils.isNotBlank(before) && !hasMoreItems); + boolean isLastPage = !hasMoreItems && (StringUtils.isNotBlank(after) || StringUtils.isBlank(before)); + + String url = "?limit=" + limit; + + if (StringUtils.isNotBlank(filter)) { + try { + url += "&filter=" + URLEncoder.encode(filter, StandardCharsets.UTF_8.name()); + } catch (UnsupportedEncodingException e) { + log.error("Server encountered an error while building pagination URL for the response.", e); + } + } + + if (hasMoreItems) { + apiResources.remove(apiResources.size() - 1); + } + if (needsReverse) { + Collections.reverse(apiResources); + } + if (!isFirstPage) { + String encodedString = Base64.getEncoder().encodeToString(apiResources.get(0).getCursorKey() + .toString().getBytes(StandardCharsets.UTF_8)); + apiResourceListResponse.addLinksItem(buildPaginationLink(url + "&before=" + encodedString, + "previous")); + } + if (!isLastPage) { + String encodedString = Base64.getEncoder().encodeToString(apiResources.get(apiResources.size() - 1) + .getCursorKey().toString().getBytes(StandardCharsets.UTF_8)); + apiResourceListResponse.addLinksItem(buildPaginationLink(url + "&after=" + encodedString, "next")); + } + } + + if (apiResources == null || apiResources.isEmpty()) { + apiResourceListResponse.setTotalResults(0); + apiResourceListResponse.setApiResources(new ArrayList<>()); + return apiResourceListResponse; + } + apiResourceListResponse.setTotalResults(apiResourceSearchResult.getTotalCount()); + apiResourceListResponse.setApiResources(apiResourceSearchResult.getApiResources().stream() + .map(this::buildApiResourceListItem).collect(Collectors.toList())); + + } catch (ApiResourceManagementException e) { + throw ApiResourceManagementEndpointUtil.handleApiResourceMgtException(e); + } + return apiResourceListResponse; + } + + /** + * Build Api Resource List Item from Api Resource. + * + * @param apiResource Api Resource. + * @return Api Resource List Item. + */ + private ApiResourceListItem buildApiResourceListItem(ApiResource apiResource) { + + ApiResourceListItem apiResourceListItem = new ApiResourceListItem(); + apiResourceListItem.setId(apiResource.getId()); + apiResourceListItem.setName(apiResource.getName()); + apiResourceListItem.setIdentifier(apiResource.getIdentifier()); + apiResourceListItem.setType(apiResource.getType()); + apiResourceListItem.setRequiresAuthorization(apiResource.isRequiresAuthorization()); + apiResourceListItem.setSelf(V1_API_PATH_COMPONENT + ApiResourceMgtEndpointConstants.API_RESOURCE_PATH_COMPONENT + + "/" + apiResource.getId()); + return apiResourceListItem; + } + + /** + * Build Pagination Link. + * + * @param url URL + * @param rel Rel + * @return Pagination Link + */ + private PaginationLink buildPaginationLink(String url, String rel) { + + PaginationLink paginationLink = new PaginationLink(); + paginationLink.setHref(ContextLoader.buildURIForHeader(V1_API_PATH_COMPONENT + + ApiResourceMgtEndpointConstants.API_RESOURCE_PATH_COMPONENT + url).toString()); + paginationLink.setRel(rel); + return paginationLink; + } + + /** + * Get Api Resource by ID. + * + * @param apiResourceID API Resource ID. + * @return API Resource. + */ + public ApiResource getApiResourceById(String apiResourceID) { + + try { + ApiResource apiResource = ApiResourceManagementServiceHolder.getApiResourceManager() + .getApiResourceById(apiResourceID, ContextLoader.getTenantDomainFromContext()); + if (apiResource == null) { + if (log.isDebugEnabled()) { + log.debug("API Resource not found for ID: " + apiResourceID); + } + throw ApiResourceManagementEndpointUtil.handleException(Response.Status.NOT_FOUND, + ApiResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_API_RESOURCE_NOT_FOUND, apiResourceID); + } + return apiResource; + } catch (ApiResourceManagementException e) { + throw ApiResourceManagementEndpointUtil.handleApiResourceMgtException(e); + } + } + + /** + * Patch Api Resource by ID. + * + * @param apiResourceID API Resource ID. + * @param apiResourcePatchModel API Resource Patch Model. + */ + public void patchApiResourceById(String apiResourceID, ApiResourcePatchModel apiResourcePatchModel) { + + try { + ApiResource currentApiResource = getApiResourceById(apiResourceID); + + if (apiResourcePatchModel.getRemovedScopes() != null) { + log.debug("Removed scopes field is not supported in patch operation."); + throw ApiResourceManagementEndpointUtil.handleException(Response.Status.NOT_IMPLEMENTED, + ApiResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_REMOVED_SCOPES_PATCH_NOT_SUPPORTED); + } + + String displayName = apiResourcePatchModel.getName() == null ? currentApiResource.getName() : + apiResourcePatchModel.getName(); + String description = apiResourcePatchModel.getDescription() == null ? currentApiResource.getDescription() : + apiResourcePatchModel.getDescription(); + List addedScopes = createScopes(apiResourcePatchModel.getAddedScopes()); + // Creating an empty list of removed scope names since operation is not supported. + List removedScopeNames = new ArrayList<>(); + + ApiResource apiResource = new ApiResource(); + apiResource.setName(displayName); + apiResource.setId(apiResourceID); + apiResource.setDescription(description); + ApiResourceManagementServiceHolder.getApiResourceManager().updateApiResource(apiResource, addedScopes, + removedScopeNames, ContextLoader.getTenantDomainFromContext()); + } catch (ApiResourceManagementException e) { + throw ApiResourceManagementEndpointUtil.handleApiResourceMgtException(e); + } + } + + /** + * Delete Api Resource by ID. + * + * @param apiResourceID API Resource ID. + */ + public void deleteApiResource(String apiResourceID) { + + try { + if (log.isDebugEnabled()) { + log.debug("Deleting API Resource with ID: " + apiResourceID); + } + ApiResourceManagementServiceHolder.getApiResourceManager().deleteApiResourceById(apiResourceID, + ContextLoader.getTenantDomainFromContext()); + } catch (ApiResourceManagementException e) { + throw ApiResourceManagementEndpointUtil.handleApiResourceMgtException(e); + } + } + + /** + * Get scopes by API ID. + * + * @param apiResourceId API resource id. + * @return List of scopes. + */ + public List getScopesByApiId(String apiResourceId) { + + try { + ApiResource apiResource = ApiResourceManagementServiceHolder.getApiResourceManager() + .getApiResourceById(apiResourceId, ContextLoader.getTenantDomainFromContext()); + if (apiResource == null) { + if (log.isDebugEnabled()) { + log.debug("API Resource not found for ID: " + apiResourceId); + } + throw ApiResourceManagementEndpointUtil.handleException(Response.Status.NOT_FOUND, + ApiResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_API_RESOURCE_NOT_FOUND, apiResourceId); + } + return apiResource.getScopes(); + } catch (ApiResourceManagementException e) { + throw ApiResourceManagementEndpointUtil.handleApiResourceMgtException(e); + } + } + + /** + * Put scopes by API ID. This replaces existing scopes. + * + * @param apiResourceId API resource id. + * @param scopeCreationModels Scope creation models. + */ + public void putScopesByApiId(String apiResourceId, List scopeCreationModels) { + + try { + ApiResource apiResource = ApiResourceManagementServiceHolder.getApiResourceManager() + .getApiResourceById(apiResourceId, ContextLoader.getTenantDomainFromContext()); + if (apiResource == null) { + if (log.isDebugEnabled()) { + log.debug("API Resource not found for ID: " + apiResourceId); + } + throw ApiResourceManagementEndpointUtil.handleException(Response.Status.NOT_FOUND, + ApiResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_API_RESOURCE_NOT_FOUND, apiResourceId); + } + List scopes = createScopes(scopeCreationModels); + ApiResourceManagementServiceHolder.getApiResourceManager().putScopes(apiResourceId, apiResource.getScopes(), + scopes, ContextLoader.getTenantDomainFromContext()); + } catch (ApiResourceManagementException e) { + throw ApiResourceManagementEndpointUtil.handleApiResourceMgtException(e); + } + } + + /** + * Delete scopes by the scope ID. + * + * @param apiResourceId API Resource ID. + * @param scopeId Scope ID. + */ + public void deleteScopeByScopeId(String apiResourceId, String scopeId) { + + try { + if (log.isDebugEnabled()) { + log.debug("Deleting scope with ID: " + scopeId + " of API Resource ID: " + apiResourceId); + } + ApiResourceManagementServiceHolder.getApiResourceManager() + .deleteApiScopeByScopeId(apiResourceId, scopeId, ContextLoader.getTenantDomainFromContext()); + } catch (ApiResourceManagementException e) { + throw ApiResourceManagementEndpointUtil.handleApiResourceMgtException(e); + } + } + + /** + * Search API Resources. + * + * @param apiResourceIds List of API Resource IDs to be searched. + * @param attributes List of attributes to be returned. + * @return List of API Resources. + */ + public List searchApiResources(List apiResourceIds, List attributes) { + + try { + List validatedAttributes = + ApiResourceManagementEndpointUtil.validateAndConvertToLowerCase(attributes); + return ApiResourceManagementServiceHolder.getApiResourceManager().searchApiResources(apiResourceIds, + validatedAttributes, ContextLoader.getTenantDomainFromContext()); + } catch (ApiResourceManagementException e) { + throw ApiResourceManagementEndpointUtil.handleApiResourceMgtException(e); + } + } + + /** + * Search Scopes registered in the tenant. + * + * @param filter Filter query. + * @return List of scopes. + */ + public List getScopesByTenant(String filter) { + + try { + return ApiResourceManagementServiceHolder.getApiResourceManager() + .getScopesByTenantId(ContextLoader.getTenantDomainFromContext(), filter); + } catch (ApiResourceManagementException e) { + throw ApiResourceManagementEndpointUtil.handleApiResourceMgtException(e); + } + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/exception/ApiResourceMgtEndpointException.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/exception/ApiResourceMgtEndpointException.java new file mode 100644 index 0000000000..018a9dc2fe --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/exception/ApiResourceMgtEndpointException.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023, 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 + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1.exception; + +import org.wso2.carbon.identity.api.server.api.resource.v1.Error; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +/** + * Exception class for API resource management endpoint. + */ +public class ApiResourceMgtEndpointException extends WebApplicationException { + + public ApiResourceMgtEndpointException(Response.Status status, Error error) { + + super(Response.status(status).entity(error).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .build()); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ApiResourcesApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ApiResourcesApiServiceImpl.java new file mode 100644 index 0000000000..e7e8ad07ec --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ApiResourcesApiServiceImpl.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2023, 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 + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.wso2.carbon.identity.api.server.api.resource.v1.ApiResourceCreationModel; +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.ApiResourceSearchPayload; +import org.wso2.carbon.identity.api.server.api.resource.v1.ApiResourcesApiService; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeCreationModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.constants.ApiResourceMgtEndpointConstants; +import org.wso2.carbon.identity.api.server.api.resource.v1.core.ServerApiResourceManagementService; +import org.wso2.carbon.identity.api.server.common.ContextLoader; + +import java.net.URI; +import java.util.List; + +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.server.common.Constants.V1_API_PATH_COMPONENT; + +/** + * Implementation of the Api resources REST Api. + */ +public class ApiResourcesApiServiceImpl implements ApiResourcesApiService { + + @Autowired + ServerApiResourceManagementService serverApiResourceManagementService; + + @Override + public Response addApiResource(ApiResourceCreationModel apIResourceCreationModel) { + + ApiResourceResponse apiResourceResponse = + serverApiResourceManagementService.addApiResourceWithResourceId(apIResourceCreationModel); + URI location = ContextLoader.buildURIForHeader(V1_API_PATH_COMPONENT + + ApiResourceMgtEndpointConstants.API_RESOURCE_PATH_COMPONENT + "/" + apiResourceResponse.getId()); + return Response.created(location).entity(apiResourceResponse).build(); + } + + @Override + public Response apiResourcesApiResourceIdDelete(String apiResourceId) { + + serverApiResourceManagementService.deleteApiResource(apiResourceId); + return Response.noContent().build(); + } + + @Override + public Response apiResourcesApiResourceIdGet(String apiResourceId) { + + return Response.ok().entity(serverApiResourceManagementService.getApiResourceById(apiResourceId)).build(); + } + + @Override + public Response apiResourcesApiResourceIdPatch(String apiResourceId, ApiResourcePatchModel apIResourcePatchModel) { + + serverApiResourceManagementService.patchApiResourceById(apiResourceId, apIResourcePatchModel); + return Response.noContent().build(); + } + + @Override + public Response apiResourcesApiResourceIdScopesGet(String apiResourceId) { + + return Response.ok().entity(serverApiResourceManagementService.getScopesByApiId(apiResourceId)).build(); + } + + @Override + public Response apiResourcesApiResourceIdScopesPut(String apiResourceId, + List scopeCreationModel) { + + serverApiResourceManagementService.putScopesByApiId(apiResourceId, scopeCreationModel); + return Response.noContent().build(); + } + + @Override + public Response apiResourcesApiResourceIdScopesScopeIdDelete(String apiResourceId, String scopeId) { + + serverApiResourceManagementService.deleteScopeByScopeId(apiResourceId, scopeId); + return Response.noContent().build(); + } + + @Override + public Response getApiResources(String before, String after, String filter, Integer limit, String sortOrder) { + + return Response.ok().entity(serverApiResourceManagementService.getApiResources(before, after, filter, limit)) + .build(); + } + + @Override + public Response searchApiResources(ApiResourceSearchPayload apIResourceSearchPayload) { + + return Response.ok().entity(serverApiResourceManagementService.searchApiResources( + apIResourceSearchPayload.getApiResourceIds(), + apIResourceSearchPayload.getRequiredAttributes())).build(); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ScopesApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ScopesApiServiceImpl.java new file mode 100644 index 0000000000..96a0326760 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ScopesApiServiceImpl.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.com). + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1.impl; + +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopesApiService; +import org.wso2.carbon.identity.api.server.api.resource.v1.core.ServerApiResourceManagementService; + +import javax.ws.rs.core.Response; + +/** + * Implementation of scopes API. + */ +public class ScopesApiServiceImpl implements ScopesApiService { + + ServerApiResourceManagementService serverApiResourceManagementService = + ServerApiResourceManagementService.getInstance(); + + @Override + public Response scopesGet(String filter) { + + return Response.ok().entity(serverApiResourceManagementService.getScopesByTenant(filter)).build(); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/util/ApiResourceManagementEndpointUtil.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/util/ApiResourceManagementEndpointUtil.java new file mode 100644 index 0000000000..250422a8ee --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/util/ApiResourceManagementEndpointUtil.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2023, 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 + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.api.resource.v1.util; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.identity.api.resource.mgt.ApiResourceManagementClientException; +import org.wso2.carbon.identity.api.resource.mgt.ApiResourceManagementException; +import org.wso2.carbon.identity.api.server.api.resource.v1.Error; +import org.wso2.carbon.identity.api.server.api.resource.v1.constants.ApiResourceMgtEndpointConstants; +import org.wso2.carbon.identity.api.server.api.resource.v1.exception.ApiResourceMgtEndpointException; +import org.wso2.carbon.identity.application.common.model.ApiResource; +import org.wso2.carbon.identity.application.common.model.Scope; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.resource.mgt.constant.ApiResourceManagementConstants.ErrorMessages.ERROR_CODE_API_RESOURCE_ALREADY_EXISTS; +import static org.wso2.carbon.identity.api.resource.mgt.constant.ApiResourceManagementConstants.ErrorMessages.ERROR_CODE_SCOPE_ALREADY_EXISTS; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.ApiResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_INVALID_API_RESOURCE_IDENTIFIER; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.ApiResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_INVALID_API_RESOURCE_NAME; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.ApiResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_INVALID_SCOPE_NAME; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.ApiResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_INVALID_SEARCH_ATTRIBUTE; +import static org.wso2.carbon.identity.api.server.common.Constants.ERROR_CODE_DELIMITER; + +/** + * Utility class for API resource management endpoint. + */ +public class ApiResourceManagementEndpointUtil { + + private static final Log log = LogFactory.getLog(ApiResourceManagementEndpointUtil.class); + + public static void validateApiResource(ApiResource apiResource) { + + if (StringUtils.isBlank(apiResource.getName())) { + throw new ApiResourceMgtEndpointException(Response.Status.BAD_REQUEST, + getError(ERROR_CODE_INVALID_API_RESOURCE_NAME)); + } + if (StringUtils.isBlank(apiResource.getIdentifier())) { + throw new ApiResourceMgtEndpointException(Response.Status.BAD_REQUEST, + getError(ERROR_CODE_INVALID_API_RESOURCE_IDENTIFIER)); + } + } + + public static void validateScopes(List scopes) { + + for (Scope scope : scopes) { + if (StringUtils.isBlank(scope.getName())) { + throw new ApiResourceMgtEndpointException(Response.Status.BAD_REQUEST, + getError(ERROR_CODE_INVALID_SCOPE_NAME)); + } + if (StringUtils.isBlank(scope.getDisplayName())) { + scope.setDisplayName(scope.getName()); + } + } + } + + /** + * Validate the attributes provided for search. + * + * @param attributes List of attributes to be validated. + * @return List of validated attributes. + */ + public static List validateAndConvertToLowerCase(List attributes) { + List validatedAttributes = new ArrayList<>(); + + if (attributes != null && !attributes.isEmpty()) { + for (String attribute : attributes) { + String lowerCaseAttribute = attribute.toLowerCase(Locale.ENGLISH); + if (!ApiResourceMgtEndpointConstants.ALLOWED_SEARCH_ATTRIBUTES.contains(lowerCaseAttribute)) { + throw new ApiResourceMgtEndpointException(Response.Status.BAD_REQUEST, + getError(ERROR_CODE_INVALID_SEARCH_ATTRIBUTE)); + } else { + validatedAttributes.add(lowerCaseAttribute); + } + } + } + return validatedAttributes; + } + + public static ApiResourceMgtEndpointException handleException(Response.Status status, + ApiResourceMgtEndpointConstants.ErrorMessage error) { + + return new ApiResourceMgtEndpointException(status, getError(error.getCode(), error.getMessage(), + error.getDescription())); + } + + public static ApiResourceMgtEndpointException handleException(Response.Status status, + ApiResourceMgtEndpointConstants.ErrorMessage error, + String data) { + + return new ApiResourceMgtEndpointException(status, getError(error.getCode(), error.getMessage(), + String.format(error.getDescription(), data))); + } + + public static ApiResourceMgtEndpointException handleApiResourceMgtException(ApiResourceManagementException e) { + + Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; + if (e instanceof ApiResourceManagementClientException) { + log.debug(e.getMessage(), e); + if (ERROR_CODE_API_RESOURCE_ALREADY_EXISTS.getCode().equals(e.getErrorCode()) || + ERROR_CODE_SCOPE_ALREADY_EXISTS.getCode().equals(e.getErrorCode())) { + status = Response.Status.CONFLICT; + } else { + status = Response.Status.BAD_REQUEST; + } + } else { + log.error(e.getMessage(), e); + } + String errorCode = e.getErrorCode(); + errorCode = errorCode.contains(ERROR_CODE_DELIMITER) ? errorCode : + ApiResourceMgtEndpointConstants.API_RESOURCE_MANAGEMENT_PREFIX + errorCode; + return new ApiResourceMgtEndpointException(status, getError(errorCode, e.getMessage(), e.getDescription())); + } + + /** + * Returns a generic error object from the given ErrorMessage object. + * + * @param errorInfo Error message Information. + * @return A generic error with the specified details. + */ + public static Error getError(ApiResourceMgtEndpointConstants.ErrorMessage errorInfo) { + + Error error = new Error(); + error.setCode(errorInfo.getCode()); + error.setMessage(errorInfo.getMessage()); + error.setDescription(errorInfo.getDescription()); + return error; + } + + /** + * Returns a generic error object. + * + * @param errorCode Error code. + * @param errorMessage Error message. + * @param errorDescription Error description. + * @return A generic error with the specified details. + */ + public static Error getError(String errorCode, String errorMessage, String errorDescription) { + + Error error = new Error(); + error.setCode(errorCode); + error.setMessage(errorMessage); + error.setDescription(errorDescription); + return error; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/resources/META-INF/cxf/api-resource-server-v1-cxf.xml b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/resources/META-INF/cxf/api-resource-server-v1-cxf.xml new file mode 100644 index 0000000000..d23864dd9f --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/resources/META-INF/cxf/api-resource-server-v1-cxf.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/resources/apiResources.yaml b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/resources/apiResources.yaml new file mode 100644 index 0000000000..4fbf7c9809 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/resources/apiResources.yaml @@ -0,0 +1,831 @@ +openapi: 3.0.0 +info: + description: > + This document specifies an **API Resource Management RESTful API** for **WSO2 + Identity Server**. + version: "v1" + title: WSO2 Identity Server - API Resource Management Rest API + termsOfService: 'http://swagger.io/terms/' + contact: + name: WSO2 + url: 'http://wso2.com/products/identity-server/' + email: architecture@wso2.org + license: + name: Apache 2.0 + url: 'http://www.apache.org/licenses/LICENSE-2.0.html' + +security: + - OAuth2: [] + - BasicAuth: [] + +servers: + # Added by API Auto Mocking Plugin + - description: SwaggerHub API Auto Mocking + url: https://virtserver.swaggerhub.com/THAMINDUA_1/api_resource/v1 + - url: 'https://{server-url}/t/{tenant-domain}/api/server/v1' + variables: + tenant-domain: + default: "carbon.super" + server-url: + default: "localhost:9443" + +paths: + /api-resources: + post: + tags: + - Api Resources + operationId: addApiResource + summary: Add a new Api resource + description: Add a new Api resource + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResourceResponse' + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 404: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 409: + description: Conflict + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + application/xml: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResourceCreationModel' + description: This represents the Api resource to be created. + required: true + get: + tags: + - Api Resources + summary: List all Api resources in the server + description: List all Api resources in the server + operationId: getApiResources + parameters: + - $ref: '#/components/parameters/before' + - $ref: '#/components/parameters/after' + - $ref: '#/components/parameters/filter' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/requiredAttributes' + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResourceListResponse' + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + /api-resources/.search: + post: + tags: + - Api Resources + operationId: searchApiResources + summary: Search Api Resources + description: Search Api Resource attributes by Api Resource IDs. RequiredAttributes fields currently supports "scopes" value. Filter and Limit fields are not supported yet. + responses: + 200: + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ApiResourceSearchResult' + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 501: + description: Not Implemented + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResourceSearchPayload' + description: This represents the Api resource IDs and attributes to be searched. + required: true + + /api-resources/{apiResourceId}: + get: + tags: + - Api Resources + summary: Get Api resource specified by the id + description: Get Api resource specified by the id + parameters: + - $ref: '#/components/parameters/apiResourceId' + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResourceResponse' + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + patch: + tags: + - Api Resources + summary: Patch Api resource specified by the id + description: Patch Api resource specified by the id. Patch operation only supports "name", "description" updating and "addedScopes" fields at the moment. + parameters: + - $ref: '#/components/parameters/apiResourceId' + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResourceResponse' + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 404: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 409: + description: Conflict + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + application/xml: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 501: + description: Not Implemented + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResourcePatchModel' + description: This represents the Api resource to be patched. + required: true + delete: + tags: + - Api Resources + summary: Delete Api resource specified by the id + description: Delete Api resource specified by the id + parameters: + - $ref: '#/components/parameters/apiResourceId' + responses: + 204: + description: No Content + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + /api-resources/{apiResourceId}/scopes: + get: + tags: + - Api Resource Scopes + summary: Get Api resource scopes + description: Get Api resource scopes specified by the id + parameters: + - $ref: '#/components/parameters/apiResourceId' + responses: + 200: + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ScopeGetModel' + 401: + description: Unauthorized + 403: + description: Forbidden + 404: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + put: + tags: + - Api Resource Scopes + summary: Add scopes to Api resource + description: Put scopes Api resource specified by the id + parameters: + - $ref: '#/components/parameters/apiResourceId' + responses: + 204: + description: No Content + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 404: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 409: + description: Conflict + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + application/xml: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + requestBody: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ScopeCreationModel' + description: This represents the Api resource to be patched. + required: true + + /api-resources/{apiResourceId}/scopes/{scopeId}: + delete: + tags: + - Api Resource Scopes + summary: Delete Api resource specified by the id + description: Delete Api resource specified by the id + parameters: + - $ref: '#/components/parameters/apiResourceId' + - $ref: '#/components/parameters/scopeId' + responses: + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + /scopes: + get: + tags: + - Api Resource Scopes + summary: Get all scopes in the tenant + description: Get all scopes in the tenant + parameters: + - $ref: '#/components/parameters/filter' + responses: + 200: + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ScopeGetModel' + 401: + description: Unauthorized + 403: + description: Forbidden + 404: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + +components: + parameters: + organizationId: + in: path + name: organizationId + description: uuid of the org. + required: true + schema: + type: string + example: "1234-4567-4567" + + apiResourceId: + name: apiResourceId + in: path + description: ID of the Api Resource. + required: true + schema: + type: string + example: er34-gf23-bv54-vb90 + + scopeId: + name: scopeId + in: path + description: ID of the Scope. + required: true + schema: + type: string + + applicationId: + name: applicationId + in: path + description: ID of the Application. + required: true + schema: + type: string + + authorizationId: + name: authorizationId + in: path + description: ID of the authorization. + required: true + schema: + type: string + + before: + name: before + in: query + required: false + description: | + Base64 encoded cursor value for backward pagination. + schema: + type: string + example: Ng== + + after: + name: after + in: query + required: false + description: | + Base64 encoded cursor value for forward pagination. + schema: + type: string + example: Ng== + + filter: + name: filter + in: query + required: false + description: | + Condition to filter the retrieval of records. Supports 'sw', 'co', 'ew' and 'eq' operations. + schema: + type: string + example: identifier+eq+greetings + + limit: + name: limit + in: query + required: false + description: | + Maximum number of records to return. + schema: + type: integer + example: 10 + + requiredAttributes: + name: requiredAttributes + in: query + required: false + description: Specifies the required parameters in the response. This parameter is not supported yet + schema: + type: string + + schemas: + Error: + type: object + properties: + code: + type: string + example: AAA-00000 + message: + type: string + example: Some Error Message + description: + type: string + example: Some Error Description + traceId: + type: string + example: e0fbcfeb-3617-43c4-8dd0-7b7d38e13047 + + ApiResourceListItem: + type: object + required: + - id + - name + - identifier + - self + properties: + id: + type: string + example: gh43-jk34-vb34-df67 + name: + type: string + example: Greetings Api + identifier: + type: string + example: greetings_api + type: + type: string + example: SYSTEM + requiresAuthorization: + type: boolean + example: true + self: + type: string + example: /t/carbon.super/api/server/v1/api-resources/eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg + + ApiResourceResponse: + type: object + required: + - id + - name + - identifier + - self + properties: + id: + type: string + example: gh43-jk34-vb34-df67 + name: + type: string + example: Greetings Api + description: + type: string + example: Greeting Api representation + identifier: + type: string + example: greetings_api + type: + type: string + example: SYSTEM + requiresAuthorization: + type: boolean + example: true + scopes: + type: array + items: + $ref: '#/components/schemas/ScopeGetModel' + subscribedApplications: + type: array + items: + $ref: '#/components/schemas/SubscribedApplicationGetModel' + self: + type: string + example: /t/carbon.super/api/server/v1/api-resources/eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg + + ApiResourceCreationModel: + type: object + required: + - identifier + - name + properties: + name: + type: string + example: Greetings Api + identifier: + type: string + example: greetings_api + description: + type: string + example: Greetings Api representation + requiresAuthorization: + type: boolean + example: true + scopes: + type: array + items: + $ref: '#/components/schemas/ScopeCreationModel' + + ApiResourceSearchResult: + type: object + required: + - id + properties: + id: + type: string + example: gh43-jk34-vb34-df67 + name: + type: string + example: Greetings Api + description: + type: string + example: Greetings Api representation + identifier: + type: string + example: greetings_api + type: + type: string + example: SYSTEM + scopes: + type: array + items: + $ref: '#/components/schemas/ScopeGetModel' + + ApiResourceSearchPayload: + type: object + required: + - apiResourceIds + - attributes + properties: + apiResourceIds: + type: array + items: + type: string + requiredAttributes: + type: array + items: + type: string + filter: + type: string + example: name+eq+apiName + limit: + type: integer + example: 10 + + + ApiResourcePatchModel: + type: object + properties: + name: + type: string + example: Greetings Api + description: + type: string + example: Greetings Api representation + addedScopes: + type: array + items: + $ref: '#/components/schemas/ScopeCreationModel' + removedScopes: + type: array + items: + type: string + description: This field is not supported yet. + + PaginationLink: + type: object + properties: + rel: + type: string + example: before + href: + type: string + example: /o/orgName/api-resources?after=NDoy + + ApiResourceListResponse: + type: object + required: + - links + properties: + totalResults: + type: integer + example: 1 + links: + type: array + items: + $ref: '#/components/schemas/PaginationLink' + apiResources: + type: array + items: + $ref: '#/components/schemas/ApiResourceListItem' + + ScopeGetModel: + type: object + required: + - id + - displayName + - name + properties: + id: + type: string + example: sf23-fg34-fy53-hj23 + displayName: + type: string + example: Write + name: + type: string + example: greetings:write + description: + type: string + example: Allow writing greetings + + ScopeCreationModel: + type: object + required: + - name + properties: + name: + type: string + example: 'greetings:write' + displayName: + type: string + example: "Write Greetings" + description: + type: string + example: "Allows writing greetings" + + SubscribedApplicationGetModel: + type: object + properties: + name: + type: string + example: Application1 + id: + type: string + example: 23fd-23gd-54vv-sdhf + + responses: + BadRequest: + description: Bad Request. Invalid request or validation error. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 400 + message: Bad Request + description: Invalid request or validation error + + Conflict: + description: Conflict. Specified resource already exists. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 409 + message: Conflict + description: Specified resource already exists + moreInfo: '' + error: [] + Forbidden: + description: >- + Forbidden. The request must be conditional but no condition has been + specified. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 403 + message: Forbidden + description: >- + The request must be conditional but no condition has been + specified + InternalServerError: + description: Internal Server Error. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 500 + message: Internal Server Error + description: >- + The server encountered an internal error. Please contact + administrator. + moreInfo: '' + error: [] + NotFound: + description: Not Found. The specified resource does not exist. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 404 + message: Not Found + description: The specified resource does not exist + moreInfo: '' + error: [] + + Unauthorized: + description: Unauthorized. The user is not authorized. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 401 + message: Unauthorized + description: The user is not authorized + moreInfo: '' + error: [] + + securitySchemes: + BasicAuth: + type: http + scheme: basic + OAuth2: + type: oauth2 + flows: + authorizationCode: + authorizationUrl: 'https://localhost:9443/oauth2/authorize' + tokenUrl: 'http://localhost:9443/oauth2/token' + scopes: {} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/pom.xml b/components/org.wso2.carbon.identity.api.server.api.resource/pom.xml new file mode 100644 index 0000000000..f08d975853 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/pom.xml @@ -0,0 +1,38 @@ + + + + 4.0.0 + + + identity-api-server + org.wso2.carbon.identity.server.api + 1.2.67-SNAPSHOT + ../../pom.xml + + + org.wso2.carbon.identity.api.server.api.resource + 1.2.67-SNAPSHOT + pom + + + org.wso2.carbon.identity.api.server.api.resource.common + org.wso2.carbon.identity.api.server.api.resource.v1 + + + diff --git a/pom.xml b/pom.xml index 4b5baf34dd..07ba194d18 100644 --- a/pom.xml +++ b/pom.xml @@ -173,6 +173,12 @@ ${carbon.identity.framework.version} provided + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.api.resource.mgt + ${carbon.identity.framework.version} + provided + org.wso2.carbon.identity.framework org.wso2.carbon.identity.application.mgt @@ -689,6 +695,7 @@ components/org.wso2.carbon.identity.api.server.idv.provider components/org.wso2.carbon.identity.api.server.organization.management components/org.wso2.carbon.identity.api.server.organization.role.management + components/org.wso2.carbon.identity.api.server.api.resource