Search in sources :

Example 31 with Event

use of com.google.recaptchaenterprise.v1beta1.Event in project requery by requery.

the class UpsertTest method testUpsertOneToMany.

@Test
public void testUpsertOneToMany() {
    Event event = new Event();
    event.setId(UUID.randomUUID());
    Place place = new Place();
    place.setId(UUID.randomUUID().toString());
    place.setName("place");
    place.getEvents().add(event);
    data.upsert(place);
}
Also used : Event(io.requery.test.model3.Event) Place(io.requery.test.model3.Place) Test(org.junit.Test)

Example 32 with Event

use of com.google.recaptchaenterprise.v1beta1.Event in project requery by requery.

the class UpsertTest method testUpsertInsertOneToMany.

@Test
public void testUpsertInsertOneToMany() {
    Event event = new Event();
    UUID id = UUID.randomUUID();
    event.setId(id);
    data.upsert(event);
    assertNotNull(event);
    Event event1 = new Event();
    event1.setId(id);
    Place place = new Place();
    place.setId(UUID.randomUUID().toString());
    place.setName("place");
    place.getEvents().add(event1);
    data.insert(place);
}
Also used : Event(io.requery.test.model3.Event) UUID(java.util.UUID) Place(io.requery.test.model3.Place) Test(org.junit.Test)

Example 33 with Event

use of com.google.recaptchaenterprise.v1beta1.Event in project requery by requery.

the class UpsertTest method testUpsertOneToManyEmptyCollection.

@Test
public void testUpsertOneToManyEmptyCollection() {
    Event event1 = new Event();
    event1.setId(UUID.randomUUID());
    Place place = new Place();
    place.setId(UUID.randomUUID().toString());
    place.setName("place");
    place.getEvents().add(event1);
    place.getEvents().clear();
    data.upsert(place);
}
Also used : Event(io.requery.test.model3.Event) Place(io.requery.test.model3.Place) Test(org.junit.Test)

Example 34 with Event

use of com.google.recaptchaenterprise.v1beta1.Event in project java-docs-samples by GoogleCloudPlatform.

the class CreateChannelEvent method createChannelEvent.

public static void createChannelEvent(String projectId, String location, String channelId, String eventId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
        var createEventRequest = CreateEventRequest.newBuilder().setParent(ChannelName.of(projectId, location, channelId).toString()).setEventId(eventId).setEvent(Event.newBuilder().setAdBreak(AdBreakTask.newBuilder().setDuration(Duration.newBuilder().setSeconds(30).build()).build()).setExecuteNow(true).build()).build();
        Event response = livestreamServiceClient.createEvent(createEventRequest);
        System.out.println("Channel event: " + response.getName());
    }
}
Also used : Event(com.google.cloud.video.livestream.v1.Event) LivestreamServiceClient(com.google.cloud.video.livestream.v1.LivestreamServiceClient)

Example 35 with Event

use of com.google.recaptchaenterprise.v1beta1.Event in project java-docs-samples by GoogleCloudPlatform.

the class TestUtils method cleanStaleChannels.

public static void cleanStaleChannels(String projectId, String location) {
    try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
        var listChannelsRequest = ListChannelsRequest.newBuilder().setParent(LocationName.of(projectId, location).toString()).build();
        LivestreamServiceClient.ListChannelsPagedResponse response = livestreamServiceClient.listChannels(listChannelsRequest);
        for (Channel channel : response.iterateAll()) {
            if (channel.getCreateTime().getSeconds() < Instant.now().getEpochSecond() - DELETION_THRESHOLD_TIME_HOURS_IN_SECONDS) {
                // Stop the channel
                try {
                    livestreamServiceClient.stopChannelAsync(channel.getName()).get(1, TimeUnit.MINUTES);
                } catch (ExecutionException e) {
                    // Ignore error if the channel isn't stopped or the stop operation times out.
                    e.printStackTrace();
                } catch (NotFoundException | InterruptedException | TimeoutException e) {
                    e.printStackTrace();
                    continue;
                }
                // Delete the channel events
                var listEventsRequest = ListEventsRequest.newBuilder().setParent(channel.getName()).build();
                LivestreamServiceClient.ListEventsPagedResponse eventsResponse = livestreamServiceClient.listEvents(listEventsRequest);
                for (Event event : eventsResponse.iterateAll()) {
                    var deleteEventRequest = DeleteEventRequest.newBuilder().setName(event.getName()).build();
                    livestreamServiceClient.deleteEvent(deleteEventRequest);
                }
                // Delete the channel
                var deleteChannelRequest = DeleteChannelRequest.newBuilder().setName(channel.getName()).build();
                livestreamServiceClient.deleteChannelAsync(deleteChannelRequest).get(1, TimeUnit.MINUTES);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    } catch (NotFoundException | InterruptedException | ExecutionException | TimeoutException e) {
        e.printStackTrace();
    }
}
Also used : Channel(com.google.cloud.video.livestream.v1.Channel) NotFoundException(com.google.api.gax.rpc.NotFoundException) IOException(java.io.IOException) Event(com.google.cloud.video.livestream.v1.Event) ExecutionException(java.util.concurrent.ExecutionException) LivestreamServiceClient(com.google.cloud.video.livestream.v1.LivestreamServiceClient) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

Test (org.junit.Test)18 Event (io.requery.test.model3.Event)9 UUID (java.util.UUID)9 Event (org.apache.skywalking.apm.network.event.v3.Event)9 Test (org.junit.jupiter.api.Test)9 Event (org.eclipse.bpmn2.Event)5 Event (com.google.cloud.video.livestream.v1.Event)4 LivestreamServiceClient (com.google.cloud.video.livestream.v1.LivestreamServiceClient)4 Place (io.requery.test.model3.Place)4 Tag (io.requery.test.model3.Tag)4 AlarmMessage (org.apache.skywalking.oap.server.core.alarm.AlarmMessage)4 ListNamespacedEvent (com.marcnuri.yakc.api.events.v1.EventsV1Api.ListNamespacedEvent)3 Event (com.marcnuri.yakc.model.io.k8s.api.events.v1.Event)3 Event (io.fabric8.kubernetes.api.model.events.v1.Event)3 Event (io.requery.test.model2.Event)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Event (uk.gov.justice.hmpps.prison.api.model.v1.Event)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JsonArray (com.google.gson.JsonArray)2