Search in sources :

Example 41 with Message

use of com.google.api.generator.gapic.model.Message in project gapic-generator-java by googleapis.

the class TestProtoLoader method parseShowcaseMessaging.

public GapicContext parseShowcaseMessaging() {
    FileDescriptor fileDescriptor = MessagingOuterClass.getDescriptor();
    ServiceDescriptor messagingService = fileDescriptor.getServices().get(0);
    assertEquals(messagingService.getName(), "Messaging");
    Map<String, Message> messageTypes = Parser.parseMessages(fileDescriptor);
    Map<String, ResourceName> resourceNames = Parser.parseResourceNames(fileDescriptor);
    Set<ResourceName> outputResourceNames = new HashSet<>();
    List<Service> services = Parser.parseService(fileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames);
    return GapicContext.builder().setMessages(messageTypes).setResourceNames(resourceNames).setServices(services).setHelperResourceNames(outputResourceNames).setTransport(transport).build();
}
Also used : Message(com.google.api.generator.gapic.model.Message) ServiceDescriptor(com.google.protobuf.Descriptors.ServiceDescriptor) ResourceName(com.google.api.generator.gapic.model.ResourceName) Service(com.google.api.generator.gapic.model.Service) FileDescriptor(com.google.protobuf.Descriptors.FileDescriptor) HashSet(java.util.HashSet)

Example 42 with Message

use of com.google.api.generator.gapic.model.Message in project gapic-generator-java by googleapis.

the class TestProtoLoader method parseExplicitDynamicRoutingHeaderTesting.

public GapicContext parseExplicitDynamicRoutingHeaderTesting() {
    FileDescriptor testingFileDescriptor = ExplicitDynamicRoutingHeaderTestingOuterClass.getDescriptor();
    ServiceDescriptor testingService = testingFileDescriptor.getServices().get(0);
    assertEquals(testingService.getName(), "ExplicitDynamicRoutingHeaderTesting");
    Map<String, Message> messageTypes = Parser.parseMessages(testingFileDescriptor);
    Map<String, ResourceName> resourceNames = Parser.parseResourceNames(testingFileDescriptor);
    Set<ResourceName> outputResourceNames = new HashSet<>();
    List<Service> services = Parser.parseService(testingFileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames);
    return GapicContext.builder().setMessages(messageTypes).setResourceNames(resourceNames).setServices(services).setHelperResourceNames(outputResourceNames).setTransport(transport).build();
}
Also used : Message(com.google.api.generator.gapic.model.Message) ServiceDescriptor(com.google.protobuf.Descriptors.ServiceDescriptor) ResourceName(com.google.api.generator.gapic.model.ResourceName) Service(com.google.api.generator.gapic.model.Service) FileDescriptor(com.google.protobuf.Descriptors.FileDescriptor) HashSet(java.util.HashSet)

Example 43 with Message

use of com.google.api.generator.gapic.model.Message in project gapic-generator-java by googleapis.

the class TestProtoLoader method parseShowcaseIdentity.

public GapicContext parseShowcaseIdentity() {
    FileDescriptor fileDescriptor = IdentityOuterClass.getDescriptor();
    ServiceDescriptor identityService = fileDescriptor.getServices().get(0);
    assertEquals(identityService.getName(), "Identity");
    Map<String, Message> messageTypes = Parser.parseMessages(fileDescriptor);
    Map<String, ResourceName> resourceNames = Parser.parseResourceNames(fileDescriptor);
    Set<ResourceName> outputResourceNames = new HashSet<>();
    List<Service> services = Parser.parseService(fileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames);
    return GapicContext.builder().setMessages(messageTypes).setResourceNames(resourceNames).setServices(services).setHelperResourceNames(outputResourceNames).setTransport(transport).build();
}
Also used : Message(com.google.api.generator.gapic.model.Message) ServiceDescriptor(com.google.protobuf.Descriptors.ServiceDescriptor) ResourceName(com.google.api.generator.gapic.model.ResourceName) Service(com.google.api.generator.gapic.model.Service) FileDescriptor(com.google.protobuf.Descriptors.FileDescriptor) HashSet(java.util.HashSet)

Example 44 with Message

use of com.google.api.generator.gapic.model.Message in project gapic-generator-java by googleapis.

the class TestProtoLoader method parsePubSubPublisher.

public GapicContext parsePubSubPublisher() {
    FileDescriptor serviceFileDescriptor = PubsubProto.getDescriptor();
    FileDescriptor commonResourcesFileDescriptor = CommonResources.getDescriptor();
    ServiceDescriptor serviceDescriptor = serviceFileDescriptor.getServices().get(0);
    assertEquals("Publisher", serviceDescriptor.getName());
    Map<String, ResourceName> resourceNames = new HashMap<>();
    resourceNames.putAll(Parser.parseResourceNames(serviceFileDescriptor));
    resourceNames.putAll(Parser.parseResourceNames(commonResourcesFileDescriptor));
    Map<String, Message> messageTypes = Parser.parseMessages(serviceFileDescriptor);
    Set<ResourceName> outputResourceNames = new HashSet<>();
    List<Service> services = Parser.parseService(serviceFileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames);
    String filename = "pubsub_gapic.yaml";
    Path path = Paths.get(getTestFilesDirectory(), filename);
    Optional<List<GapicBatchingSettings>> batchingSettingsOpt = BatchingSettingsConfigParser.parse(Optional.of(path.toString()));
    assertTrue(batchingSettingsOpt.isPresent());
    String jsonFilename = "pubsub_grpc_service_config.json";
    Path jsonPath = Paths.get(getTestFilesDirectory(), jsonFilename);
    Optional<GapicServiceConfig> configOpt = ServiceConfigParser.parse(jsonPath.toString());
    assertTrue(configOpt.isPresent());
    GapicServiceConfig config = configOpt.get();
    config.setBatchingSettings(batchingSettingsOpt);
    return GapicContext.builder().setMessages(messageTypes).setResourceNames(resourceNames).setServices(services).setServiceConfig(config).setHelperResourceNames(outputResourceNames).setTransport(transport).build();
}
Also used : Path(java.nio.file.Path) Message(com.google.api.generator.gapic.model.Message) HashMap(java.util.HashMap) ResourceName(com.google.api.generator.gapic.model.ResourceName) Service(com.google.api.generator.gapic.model.Service) GapicServiceConfig(com.google.api.generator.gapic.model.GapicServiceConfig) FileDescriptor(com.google.protobuf.Descriptors.FileDescriptor) ServiceDescriptor(com.google.protobuf.Descriptors.ServiceDescriptor) List(java.util.List) HashSet(java.util.HashSet)

Example 45 with Message

use of com.google.api.generator.gapic.model.Message in project gapic-generator-java by googleapis.

the class TestProtoLoader method parseBookshopService.

public GapicContext parseBookshopService() {
    FileDescriptor fileDescriptor = BookshopProto.getDescriptor();
    ServiceDescriptor serviceDescriptor = fileDescriptor.getServices().get(0);
    assertEquals(serviceDescriptor.getName(), "Bookshop");
    Map<String, Message> messageTypes = Parser.parseMessages(fileDescriptor);
    Map<String, ResourceName> resourceNames = new HashMap<>();
    Set<ResourceName> outputResourceNames = new HashSet<>();
    List<Service> services = Parser.parseService(fileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames);
    String jsonFilename = "bookshop_grpc_service_config.json";
    Path jsonPath = Paths.get(testFilesDirectory, jsonFilename);
    Optional<GapicServiceConfig> configOpt = ServiceConfigParser.parse(jsonPath.toString());
    assertTrue(configOpt.isPresent());
    GapicServiceConfig config = configOpt.get();
    return GapicContext.builder().setMessages(messageTypes).setResourceNames(resourceNames).setServices(services).setServiceConfig(config).setHelperResourceNames(outputResourceNames).setTransport(transport).build();
}
Also used : Path(java.nio.file.Path) Message(com.google.api.generator.gapic.model.Message) HashMap(java.util.HashMap) ResourceName(com.google.api.generator.gapic.model.ResourceName) Service(com.google.api.generator.gapic.model.Service) GapicServiceConfig(com.google.api.generator.gapic.model.GapicServiceConfig) FileDescriptor(com.google.protobuf.Descriptors.FileDescriptor) ServiceDescriptor(com.google.protobuf.Descriptors.ServiceDescriptor) HashSet(java.util.HashSet)

Aggregations

Message (com.google.api.generator.gapic.model.Message)123 ResourceName (com.google.api.generator.gapic.model.ResourceName)85 TypeNode (com.google.api.generator.engine.ast.TypeNode)74 Test (org.junit.Test)68 Method (com.google.api.generator.gapic.model.Method)60 FileDescriptor (com.google.protobuf.Descriptors.FileDescriptor)44 HashSet (java.util.HashSet)39 ArrayList (java.util.ArrayList)36 Service (com.google.api.generator.gapic.model.Service)35 List (java.util.List)34 Expr (com.google.api.generator.engine.ast.Expr)32 Field (com.google.api.generator.gapic.model.Field)31 Descriptors (com.google.protobuf.Descriptors)30 VariableExpr (com.google.api.generator.engine.ast.VariableExpr)29 MethodInvocationExpr (com.google.api.generator.engine.ast.MethodInvocationExpr)26 ServiceDescriptor (com.google.protobuf.Descriptors.ServiceDescriptor)26 AssignmentExpr (com.google.api.generator.engine.ast.AssignmentExpr)25 ExprStatement (com.google.api.generator.engine.ast.ExprStatement)25 Statement (com.google.api.generator.engine.ast.Statement)24 HashMap (java.util.HashMap)23