Browse Source
Added new Resource endpoints for ScanRequests and ScanRequest Start fleshing out invoke parameters to pass to scanrefactor_future_hack
5 changed files with 119 additions and 3 deletions
@ -0,0 +1,18 @@
|
||||
package com.redhat.pctsec.model.jpa; |
||||
|
||||
|
||||
import com.redhat.pctsec.model.ScanRequest; |
||||
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase; |
||||
import io.smallrye.mutiny.Uni; |
||||
import jakarta.enterprise.context.ApplicationScoped; |
||||
|
||||
import java.util.UUID; |
||||
|
||||
@ApplicationScoped |
||||
public class ScanRequestRepository implements PanacheRepositoryBase<ScanRequest, UUID> { |
||||
public Uni<ScanRequest> findByProduct(String product) |
||||
{ |
||||
return find("product", product).firstResult(); |
||||
} |
||||
} |
||||
|
||||
@ -1,4 +1,18 @@
|
||||
package com.redhat.pctsec.model.jpa; |
||||
|
||||
public class ScanRequestsRepository { |
||||
import com.redhat.pctsec.model.Scan; |
||||
import com.redhat.pctsec.model.ScanRequests; |
||||
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase; |
||||
import io.smallrye.mutiny.Uni; |
||||
import jakarta.enterprise.context.ApplicationScoped; |
||||
|
||||
import java.util.UUID; |
||||
|
||||
@ApplicationScoped |
||||
public class ScanRequestsRepository implements PanacheRepositoryBase<ScanRequests, UUID> { |
||||
public Uni<Scan> findByProduct(String product) |
||||
{ |
||||
return find("product", product).firstResult(); |
||||
} |
||||
} |
||||
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
package com.redhat.pctsec.rest.v1alpha1; |
||||
|
||||
import com.redhat.pctsec.model.Scan; |
||||
import com.redhat.pctsec.model.ScanRequest; |
||||
import com.redhat.pctsec.model.ScanRequests; |
||||
import com.redhat.pctsec.model.jpa.ScanRequestRepository; |
||||
import com.redhat.pctsec.model.osh.paramMapper; |
||||
import jakarta.enterprise.context.ApplicationScoped; |
||||
import jakarta.inject.Inject; |
||||
import jakarta.ws.rs.*; |
||||
import org.eclipse.microprofile.config.inject.ConfigProperty; |
||||
import picocli.CommandLine; |
||||
|
||||
import java.util.UUID; |
||||
@ApplicationScoped |
||||
@Path("/api/v1a/ScanRequest/{id}") |
||||
public class ScanRequestResource { |
||||
@Inject |
||||
ScanRequestRepository sr; |
||||
|
||||
|
||||
@GET |
||||
@Produces({"application/json"}) |
||||
public ScanRequest getScanRequest(String id) |
||||
{ |
||||
ScanRequest scanRequest = sr.findById(UUID.fromString(id)); |
||||
return scanRequest; |
||||
} |
||||
|
||||
@PATCH |
||||
@Path("ScanProperties/{scanProperties}") |
||||
@Consumes({"application/octet-stream"}) |
||||
@Produces({"application/json"}) |
||||
public ScanRequest patchScanRequest(String id, String scanProperties) |
||||
{ |
||||
ScanRequest scanRequest = sr.findById(UUID.fromString(id)); |
||||
|
||||
try { |
||||
paramMapper pm = new paramMapper(scanProperties); |
||||
} catch(CommandLine.UnmatchedArgumentException e) |
||||
{ |
||||
throw new BadRequestException("Invalid OSH Parameter"); |
||||
} |
||||
scanRequest.scanProperties = scanProperties; |
||||
sr.persist(scanRequest); |
||||
return scanRequest; |
||||
} |
||||
|
||||
} |
||||
@ -1,4 +1,33 @@
|
||||
package com.redhat.pctsec.rest.v1alpha1; |
||||
|
||||
import com.redhat.pctsec.model.Scan; |
||||
import com.redhat.pctsec.model.ScanRequest; |
||||
import com.redhat.pctsec.model.ScanRequests; |
||||
import com.redhat.pctsec.model.jpa.ScanRepository; |
||||
import com.redhat.pctsec.model.jpa.ScanRequestsRepository; |
||||
import jakarta.enterprise.context.ApplicationScoped; |
||||
import jakarta.inject.Inject; |
||||
import jakarta.ws.rs.GET; |
||||
import jakarta.ws.rs.Path; |
||||
import jakarta.ws.rs.Produces; |
||||
|
||||
import java.util.UUID; |
||||
|
||||
@ApplicationScoped |
||||
@Path("/api/v1a/ScanRequests") |
||||
public class ScanRequestsResource { |
||||
|
||||
@Inject |
||||
ScanRequestsRepository sr; |
||||
|
||||
|
||||
@GET |
||||
@Path("{id}") |
||||
@Produces({"application/json"}) |
||||
public ScanRequests getScanRequests(String id) |
||||
{ |
||||
ScanRequests scanRequests = sr.findById(UUID.fromString(id)); |
||||
return scanRequests; |
||||
} |
||||
|
||||
} |
||||
|
||||
Loading…
Reference in new issue