26
26
import com .google .cloud .pubsub .v1 .MessageReceiver ;
27
27
import com .google .cloud .pubsub .v1 .Subscriber ;
28
28
import com .google .cloud .pubsub .v1 .SubscriptionAdminClient ;
29
+ import com .google .containeranalysis .v1beta1 .NoteName ;
30
+ import com .google .containeranalysis .v1beta1 .ProjectName ;
29
31
import com .google .pubsub .v1 .ProjectSubscriptionName ;
30
32
import com .google .pubsub .v1 .ProjectTopicName ;
31
33
import com .google .pubsub .v1 .PubsubMessage ;
@@ -66,7 +68,7 @@ public static Note createNote(GrafeasV1Beta1Client client, String noteId, String
66
68
noteBuilder .setVulnerability (vulBuilder );
67
69
Note newNote = noteBuilder .build ();
68
70
69
- final String projectName = client . formatProjectName (projectId );
71
+ final ProjectName projectName = ProjectName . format (projectId );
70
72
return client .createNote (projectName , noteId , newNote );
71
73
}
72
74
// [END create_note]
@@ -85,8 +87,8 @@ public static Note createNote(GrafeasV1Beta1Client client, String noteId, String
85
87
*/
86
88
public static Occurrence createOccurrence (GrafeasV1Beta1Client client , String imageUrl ,
87
89
String noteId , String occProjectId , String noteProjectId ) {
88
- final String noteName = client . formatNoteName (noteProjectId , noteId );
89
- final String occProjectName = client . formatProjectName (occProjectId );
90
+ final NoteName noteName = NoteName . of (noteProjectId , noteId );
91
+ final ProjectName occProjectName = ProjectName . format (occProjectId );
90
92
91
93
Occurrence .Builder occBuilder = Occurrence .newBuilder ();
92
94
occBuilder .setNoteName (noteName );
@@ -112,7 +114,7 @@ public static Occurrence createOccurrence(GrafeasV1Beta1Client client, String im
112
114
*/
113
115
public static Note updateNote (GrafeasV1Beta1Client client , Note updated , String noteId ,
114
116
String projectId ) {
115
- final String noteName = client . formatNoteName (projectId , noteId );
117
+ final NoteName noteName = NoteName . of (projectId , noteId );
116
118
UpdateNoteRequest request = UpdateNoteRequest .newBuilder ()
117
119
.setName (noteName )
118
120
.setNote (updated )
@@ -147,7 +149,7 @@ public static Occurrence updateOccurrence(GrafeasV1Beta1Client client, String oc
147
149
* @param projectId the GCP project the Note belongs to
148
150
*/
149
151
public static void deleteNote (GrafeasV1Beta1Client client , String noteId , String projectId ) {
150
- final String noteName = client . formatNoteName (projectId , noteId );
152
+ final NoteName noteName = NoteName . of (projectId , noteId );
151
153
client .deleteNote (noteName );
152
154
}
153
155
// [END delete_note]
@@ -189,7 +191,7 @@ public static Occurrence getOccurrence(GrafeasV1Beta1Client client, String occur
189
191
* @return the requested Note object
190
192
*/
191
193
public static Note getNote (GrafeasV1Beta1Client client , String noteId , String projectId ) {
192
- final String noteName = client . formatNoteName (projectId , noteId );
194
+ final NoteName noteName = NoteName . of (projectId , noteId );
193
195
194
196
Note n = client .getNote (noteName );
195
197
System .out .println (n );
@@ -209,7 +211,7 @@ public static Note getNote(GrafeasV1Beta1Client client, String noteId, String pr
209
211
public static void getDiscoveryInfo (GrafeasV1Beta1Client client , String imageUrl ,
210
212
String projectId ) {
211
213
String filterStr = "kind=\" DISCOVERY\" AND resourceUrl=\" " + imageUrl + "\" " ;
212
- final String projectName = client . formatProjectName (projectId );
214
+ final ProjectName projectName = ProjectName . format (projectId );
213
215
214
216
for (Occurrence o : client .listOccurrences (projectName , filterStr ).iterateAll ()) {
215
217
System .out .println (o );
@@ -228,7 +230,7 @@ public static void getDiscoveryInfo(GrafeasV1Beta1Client client, String imageUrl
228
230
*/
229
231
public static int getOccurrencesForNote (GrafeasV1Beta1Client client , String noteId ,
230
232
String projectId ) {
231
- final String noteName = client . formatNoteName (projectId , noteId );
233
+ final NoteName noteName = NoteName . of (projectId , noteId );
232
234
int i = 0 ;
233
235
234
236
ListNoteOccurrencesRequest request = ListNoteOccurrencesRequest .newBuilder ()
@@ -257,7 +259,7 @@ public static int getOccurrencesForNote(GrafeasV1Beta1Client client, String note
257
259
public static int getOccurrencesForImage (GrafeasV1Beta1Client client , String imageUrl ,
258
260
String projectId ) {
259
261
final String filterStr = "resourceUrl=\" " + imageUrl + "\" " ;
260
- final String projectName = client . formatProjectName (projectId );
262
+ final ProjectName projectName = ProjectName . format (projectId );
261
263
int i = 0 ;
262
264
263
265
for (Occurrence o : client .listOccurrences (projectName , filterStr ).iterateAll ()) {
0 commit comments