Search in sources :

Example 36 with OrganizationEntry

use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.

the class SecretResourceV2 method update.

@POST
@ApiOperation("Updates an existing secret")
@Path("/{orgName}/secret/{secretName}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@Validate
public GenericOperationResult update(@ApiParam @PathParam("orgName") @ConcordKey String orgName, @ApiParam @PathParam("secretName") @ConcordKey String secretName, @ApiParam MultipartInput input) {
    OrganizationEntry org = orgManager.assertAccess(orgName, true);
    try {
        SecretUpdateParams newSecretParams = SecretUpdateParams.builder().newOrgId(MultipartUtils.getUuid(input, Constants.Multipart.ORG_ID)).newOrgName(MultipartUtils.getString(input, Constants.Multipart.ORG_NAME)).newProjectId(MultipartUtils.getUuid(input, Constants.Multipart.PROJECT_ID)).newProjectName(MultipartUtils.getString(input, Constants.Multipart.PROJECT_NAME)).removeProjectLink(MultipartUtils.getBoolean(input, "removeProjectLink", false)).newOwnerId(MultipartUtils.getUuid(input, "ownerId")).currentPassword(MultipartUtils.getString(input, Constants.Multipart.STORE_PASSWORD)).newPassword(MultipartUtils.getString(input, "newStorePassword")).newSecret(buildSecret(input)).newName(MultipartUtils.getString(input, Constants.Multipart.NAME)).newVisibility(getVisibility(input)).build();
        secretManager.update(org.getId(), secretName, newSecretParams);
    } catch (IOException e) {
        throw new ConcordApplicationException("Error while processing the request: " + e.getMessage(), e);
    }
    return new GenericOperationResult(OperationResult.UPDATED);
}
Also used : GenericOperationResult(com.walmartlabs.concord.server.GenericOperationResult) ConcordApplicationException(com.walmartlabs.concord.server.sdk.ConcordApplicationException) IOException(java.io.IOException) OrganizationEntry(com.walmartlabs.concord.server.org.OrganizationEntry) Validate(org.sonatype.siesta.Validate) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

OrganizationEntry (com.walmartlabs.concord.server.org.OrganizationEntry)36 ApiOperation (io.swagger.annotations.ApiOperation)12 UUID (java.util.UUID)12 ConcordApplicationException (com.walmartlabs.concord.server.sdk.ConcordApplicationException)8 UnauthorizedException (org.apache.shiro.authz.UnauthorizedException)6 GenericOperationResult (com.walmartlabs.concord.server.GenericOperationResult)5 JsonStoreEntry (com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry)5 ValidationErrorsException (org.sonatype.siesta.ValidationErrorsException)5 WithTimer (com.walmartlabs.concord.server.sdk.metrics.WithTimer)3 UserPrincipal (com.walmartlabs.concord.server.security.UserPrincipal)3 Validate (org.sonatype.siesta.Validate)3 Map (java.util.Map)2 OperationResult (com.walmartlabs.concord.server.OperationResult)1 AuditObject (com.walmartlabs.concord.server.audit.AuditObject)1 RawPayloadMode (com.walmartlabs.concord.server.jooq.enums.RawPayloadMode)1 ResourceAccessLevel (com.walmartlabs.concord.server.org.ResourceAccessLevel)1 ProjectEntry (com.walmartlabs.concord.server.org.project.ProjectEntry)1 MetadataFilter (com.walmartlabs.concord.server.process.queue.ProcessFilter.MetadataFilter)1 InvalidRepositoryPathException (com.walmartlabs.concord.server.repository.InvalidRepositoryPathException)1 UserEntry (com.walmartlabs.concord.server.user.UserEntry)1