-
Notifications
You must be signed in to change notification settings - Fork 290
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
Failed to create note by Java-client api #429
Comments
@wkozlik could you please TAL? |
Hi @AliredDevils, thank you for finding this issue. The library |
@wkozlik Thanks for your reply.Can you give some suggestion to create client-java api for the latest source code of master branch? And i find the Java Client for Grafeas,so if i want to know :
2.The "Java Client for Grafeas" library will be the one i could use for client-Java, is it possible that i build it myself?If so, how to do that? BR |
You can generate java client with Swagger yourself. As an example you can follow this script. However, as you noticed, the generated code is not fully working due to several known issues related to the differences in defining resources in Google API and the OpenAPI spec used by Swagger. As an alternative to Swagger you could try package example;
import io.grafeas.v1beta1.vulnerability.Severity;
import io.grafeas.v1beta1.vulnerability.Vulnerability;
import io.grpc.*;
import io.grafeas.v1beta1.*;
class ClientExample {
public static void main(String args[]){
CreateNoteRequest noteRequest =
CreateNoteRequest.newBuilder()
.setParent("projects/myproject")
.setNoteId("note100")
.setNote(
Note.newBuilder()
.setName("projects/myproject/notes/note100")
.setKind(NoteKind.VULNERABILITY)
.setVulnerability(Vulnerability.newBuilder()
.setSeverity(Severity.LOW)
.setCvssScore(0.5f))
)
.build();
final ManagedChannel channel = ManagedChannelBuilder.forTarget("localhost:8080")
.usePlaintext()
.build();
GrafeasV1Beta1Grpc.GrafeasV1Beta1BlockingStub stub = GrafeasV1Beta1Grpc.newBlockingStub(channel);
Note note = stub.createNote(noteRequest);
System.out.println(note);
}
} |
@wkozlik Can you some suggestion about command line to create java client api ? 1.How to make full proto to java client? Thanks |
This script works for me (adjust path values): #!/bin/sh
function protoc {
/usr/local/bin/protoc --plugin=protoc-gen-grpc-java=/path/to/protoc-gen-grpc-java-<arch>.exe --grpc-java_out=/path/to/output -I . -I /path/to/googleapis --java_out=/path/to/output proto/v1beta1/$@
}
protoc attestation.proto
protoc build.proto
protoc common.proto
protoc cvss.proto
protoc deployment.proto
protoc discovery.proto
protoc grafeas.proto
protoc image.proto
protoc package.proto
protoc project.proto
protoc provenance.proto
protoc source.proto
protoc vulnerability.proto In my case the command is like this (when run from within grafeas repo): /usr/local/bin/protoc --plugin=protoc-gen-grpc-java=/<path-to-home>/protoc-gen-grpc-java-1.28.0-linux-x86_64.exe --grpc-java_out=/<path-to-home>/go/src/github.com/grafeas/grafeas/java/v1beta1 -I . -I /<path-to-home>/go/src/github.com/googleapis --java_out=java/v1beta1 proto/v1beta1/$@ In my example I did not use the jar file, but I believe you can create it with this command: $ jar cvf grafeas-0.24.0.jar -C ./java/v1beta1 . Once you have the library generated, it is important to have a correct version of java libraries that correspond to the version of protoc that was used to generate the code. In my case, protoc is 3.11.4, and the java libraries are:
|
@wkozlik I have generated the java client api successfully follow your reference.
Thanks a lot. |
Steps to Reproduce the Problem
1.Start grafeas server
cd go/v1beta1
go run main/main.go
2.Create grafeas client api
https://github.com/grafeas/client-java/tree/master/0.1.0
3.Create grafeas client project to create note
`ApiNote noteBody = new ApiNote();
When i creat note,i get erros:
But i could not find the api or method to add "noteId" or "note_id",is there something wrong with the client api of mine?
Environment, commands
BR
The text was updated successfully, but these errors were encountered: