Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add API endpoint for patching multiple governance connectors #476

Merged
merged 5 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public enum ErrorMessage {
ERROR_CODE_INCORRECT_CONNECTOR_NAME("50011", "Invalid connector name",
"Unable to find a connector with the name %s."),
ERROR_CODE_UNSUPPORTED_PROPERTY_NAME("50012", "Unsupported property is requested.",
"The property %s is not supported by this API.");
"The property %s is not supported by this API."),
ERROR_CODE_CONNECTOR_CATEGORY_MISMATCH("50013", "Connector category mismatch.",
"The connector %s is not found in the category %s.");

private final String code;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed 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.
*/
* Copyright (c) 2019, 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.identity.governance.v1;

Expand All @@ -23,6 +25,7 @@
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.ConnectorsPatchReq;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.Error;
import java.util.List;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.MultipleConnectorsPatchReq;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.PreferenceResp;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.PreferenceSearchAttribute;
import org.wso2.carbon.identity.api.server.identity.governance.v1.IdentityGovernanceApiService;
Expand Down Expand Up @@ -176,4 +179,27 @@ public Response patchConnector(@ApiParam(value = "Id of the connector category."
return delegate.patchConnector(categoryId, connectorId, connectorsPatchReq );
}

@Valid
@PATCH
@Path("/{category-id}/connectors")
@Consumes({ "application/json" })
@Produces({ "*/*" })
@ApiOperation(value = "Patch governance connectors of a category.", notes = "Patch governance connectors of a category.<br> <b>Permission required:</b> <br> * /permission/admin/manage/identity/idpmgt/update <br> <b>Scope required:</b> <br> * internal_idp_update ", response = Void.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

})
}, tags={ "Management" })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK.", response = Void.class),
@ApiResponse(code = 400, message = "Bad Request.", response = Error.class),
@ApiResponse(code = 401, message = "Unauthorized.", response = Void.class),
@ApiResponse(code = 404, message = "Not Found.", response = Error.class),
@ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class)
})
public Response patchConnectorsOfCategory(@ApiParam(value = "Id of the connector category.",required=true) @PathParam("category-id") String categoryId, @ApiParam(value = "Governance connectors and properties to update" ,required=true) @Valid MultipleConnectorsPatchReq multipleConnectorsPatchReq) {
Lakshan-Banneheke marked this conversation as resolved.
Show resolved Hide resolved

return delegate.patchConnectorsOfCategory(categoryId, multipleConnectorsPatchReq );
}

}
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
/*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed 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.
*/
* Copyright (c) 2019, 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.identity.governance.v1;

import org.wso2.carbon.identity.api.server.identity.governance.v1.model.ConnectorsPatchReq;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.PreferenceSearchAttribute;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.MultipleConnectorsPatchReq;

import java.util.List;

Expand All @@ -37,4 +40,6 @@ public interface IdentityGovernanceApiService {
public Response getPreferenceByPost(List<PreferenceSearchAttribute> preferenceSearchAttribute);

public Response patchConnector(String categoryId, String connectorId, ConnectorsPatchReq connectorsPatchReq);

public Response patchConnectorsOfCategory(String categoryId, MultipleConnectorsPatchReq multipleConnectorsPatchReq);
Lakshan-Banneheke marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* 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.identity.governance.v1.model;

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.identity.governance.v1.model.PropertyReq;
import javax.validation.constraints.*;

/**
* Governance connector to patch
**/

import io.swagger.annotations.*;
Lakshan-Banneheke marked this conversation as resolved.
Show resolved Hide resolved
import java.util.Objects;
import javax.validation.Valid;
import javax.xml.bind.annotation.*;
@ApiModel(description = "Governance connector to patch")
public class ConnectorReq {

private String id;
private List<PropertyReq> properties = new ArrayList<>();


/**
* Connector id.
Lakshan-Banneheke marked this conversation as resolved.
Show resolved Hide resolved
**/
public ConnectorReq id(String id) {

this.id = id;
return this;
}

@ApiModelProperty(example = "c3VzcGVuc2lvbi5ub3RpZmljYXRpb24", required = true, value = "Connector id.")
@JsonProperty("id")
@Valid
@NotNull(message = "Property id cannot be null.")

public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}

/**
* Governance connector properties to patch.
**/
public ConnectorReq properties(List<PropertyReq> properties) {

this.properties = properties;
return this;
}

@ApiModelProperty(required = true, value = "Governance connector properties to patch.")
@JsonProperty("properties")
@Valid
@NotNull(message = "Property properties cannot be null.")

public List<PropertyReq> getProperties() {
return properties;
}
public void setProperties(List<PropertyReq> properties) {
this.properties = properties;
}

public ConnectorReq addPropertiesItem(PropertyReq propertiesItem) {
this.properties.add(propertiesItem);
return this;
}



@Override
public boolean equals(java.lang.Object o) {

if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ConnectorReq connectorReq = (ConnectorReq) o;
return Objects.equals(this.id, connectorReq.id) &&
Objects.equals(this.properties, connectorReq.properties);
}

@Override
public int hashCode() {
return Objects.hash(id, properties);
}

@Override
public String toString() {

StringBuilder sb = new StringBuilder();
sb.append("class ConnectorReq {\n");

sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" properties: ").append(toIndentedString(properties)).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");
}
}

Loading
Loading