Search in sources :

Example 1 with ApiInstance

use of org.finos.symphony.toolkit.spring.api.factories.ApiInstance in project spring-bot by finos.

the class TestOboCall method doSomethingOBORSA.

@Test
public void doSomethingOBORSA() throws Exception {
    ApiInstance ai = oboInstanceFactory.createApiInstance(1234l, "1000");
    MessagesApi messagesApi = ai.getAgentApi(MessagesApi.class);
    messagesApi.v4MessageBlastPost(STREAM_IDS, MESSAGE_CONTENT, null, null, null, null, null, null);
}
Also used : MessagesApi(com.symphony.api.agent.MessagesApi) ApiInstance(org.finos.symphony.toolkit.spring.api.factories.ApiInstance) Test(org.junit.jupiter.api.Test) AbstractTest(org.finos.symphony.toolkit.spring.app.AbstractTest)

Example 2 with ApiInstance

use of org.finos.symphony.toolkit.spring.api.factories.ApiInstance in project spring-bot by finos.

the class KoreAIBridgeFactoryImpl method buildBridge.

@Override
public SymphonyStreamHandler buildBridge(KoreAIInstanceProperties props) {
    String email = "--no email--";
    try {
        // build KoreAI pipeline
        ApiInstance apiInstance = symphonyAPIInstance(props);
        email = apiInstance.getIdentity().getEmail();
        KoreAIResponseBuilder koreAIResponseBuilder = koreAIResponseBuilder();
        KoreAIResponseHandler koreAIResponseHandler = responseMessageAdapter(apiInstance, props);
        KoreAIRequester requester = koreAIRequester(props, koreAIResponseHandler, koreAIResponseBuilder);
        List<StreamEventConsumer> consumers = new ArrayList<StreamEventConsumer>();
        consumers.add(koreAIEventHandler(requester, apiInstance, props));
        if (props.isSendWelcomeMessage()) {
            consumers.add(new RoomWelcomeEventConsumer(apiInstance.getAgentApi(MessagesApi.class), apiInstance.getPodApi(UsersApi.class), apiInstance.getIdentity(), props.getWelcomeMessageML()));
        }
        // wire this up to a shared stream
        SymphonyStreamHandler out = sshf.createBean(apiInstance, consumers);
        return out;
    } catch (Exception e) {
        LOG.error("Couldn't construct Kore/Symphony bridge bean for " + email, e);
        return null;
    }
}
Also used : SymphonyStreamHandler(org.finos.symphony.toolkit.stream.handler.SymphonyStreamHandler) KoreAIResponseBuilder(org.finos.symphony.toolkit.koreai.response.KoreAIResponseBuilder) RoomWelcomeEventConsumer(org.finos.symphony.toolkit.stream.welcome.RoomWelcomeEventConsumer) ArrayList(java.util.ArrayList) ApiInstance(org.finos.symphony.toolkit.spring.api.factories.ApiInstance) KoreAIResponseHandler(org.finos.symphony.toolkit.koreai.output.KoreAIResponseHandler) StreamEventConsumer(org.finos.symphony.toolkit.stream.StreamEventConsumer) KoreAIRequester(org.finos.symphony.toolkit.koreai.request.KoreAIRequester) IOException(java.io.IOException)

Example 3 with ApiInstance

use of org.finos.symphony.toolkit.spring.api.factories.ApiInstance in project spring-bot by finos.

the class SymphonyAdminController method getAPI.

protected <X> X getAPI(Class<X> x) throws IOException, Exception {
    Config config = getConfig();
    SymphonyIdentity identity = IdentityProperties.instantiateIdentityFromDetails(rl, config.getIdentityProperties(), getObjectMapper());
    ApiBuilderFactory abf = new ApiBuilderFactory() {

        @Override
        public boolean isSingleton() {
            return false;
        }

        @Override
        public Class<?> getObjectType() {
            return ApiBuilder.class;
        }

        @Override
        public ConfigurableApiBuilder getObject() throws Exception {
            return new CXFApiBuilder();
        }
    };
    ApiInstanceFactory apiInstanceFactory = new TokenManagingApiInstanceFactory(abf);
    ApiInstance instance = apiInstanceFactory.createApiInstance(identity, config.getPodProperties(), null);
    X out = instance.getAgentApi(x);
    return out;
}
Also used : CXFApiBuilder(com.symphony.api.bindings.cxf.CXFApiBuilder) TokenManagingApiInstanceFactory(org.finos.symphony.toolkit.spring.api.factories.TokenManagingApiInstanceFactory) SymphonyIdentity(com.symphony.api.id.SymphonyIdentity) ApiInstance(org.finos.symphony.toolkit.spring.api.factories.ApiInstance) ApiBuilderFactory(org.finos.symphony.toolkit.spring.api.builders.ApiBuilderFactory) ApiInstanceFactory(org.finos.symphony.toolkit.spring.api.factories.ApiInstanceFactory) TokenManagingApiInstanceFactory(org.finos.symphony.toolkit.spring.api.factories.TokenManagingApiInstanceFactory) CXFApiBuilder(com.symphony.api.bindings.cxf.CXFApiBuilder) ApiBuilder(com.symphony.api.bindings.ApiBuilder) ConfigurableApiBuilder(com.symphony.api.bindings.ConfigurableApiBuilder)

Example 4 with ApiInstance

use of org.finos.symphony.toolkit.spring.api.factories.ApiInstance in project spring-bot by finos.

the class KoreAIBridgeFactoryImpl method symphonyAPIInstance.

public ApiInstance symphonyAPIInstance(KoreAIInstanceProperties props) {
    try {
        SymphonyIdentity symphonyBotIdentity = IdentityProperties.instantiateIdentityFromDetails(rl, props.getSymphonyBot(), om);
        TrustManager[] tms = tmf == null ? null : tmf.getTrustManagers();
        ApiInstance apiInstance = apiInstanceFactory.createApiInstance(symphonyBotIdentity, podProperties, tms);
        LOG.info("Constructed API Factory for {} ", props.getName());
        return apiInstance;
    } catch (Exception e) {
        LOG.error("Couldn't create API instance for {} ", props.getName());
        throw new UnsupportedOperationException("Couldn't get api instance: ", e);
    }
}
Also used : SymphonyIdentity(com.symphony.api.id.SymphonyIdentity) ApiInstance(org.finos.symphony.toolkit.spring.api.factories.ApiInstance) IOException(java.io.IOException) TrustManager(javax.net.ssl.TrustManager)

Example 5 with ApiInstance

use of org.finos.symphony.toolkit.spring.api.factories.ApiInstance in project spring-bot by finos.

the class TestOboCall method doSomethingOBOCert.

@Test
public void doSomethingOBOCert() throws Exception {
    ApiInstance ai = oboInstanceFactory.createApiInstance(1234l, "1001");
    MessagesApi messagesApi = ai.getAgentApi(MessagesApi.class);
    messagesApi.v4MessageBlastPost(STREAM_IDS, MESSAGE_CONTENT, null, null, null, null, null, null);
}
Also used : MessagesApi(com.symphony.api.agent.MessagesApi) ApiInstance(org.finos.symphony.toolkit.spring.api.factories.ApiInstance) Test(org.junit.jupiter.api.Test) AbstractTest(org.finos.symphony.toolkit.spring.app.AbstractTest)

Aggregations

ApiInstance (org.finos.symphony.toolkit.spring.api.factories.ApiInstance)6 MessagesApi (com.symphony.api.agent.MessagesApi)3 AbstractTest (org.finos.symphony.toolkit.spring.app.AbstractTest)3 Test (org.junit.jupiter.api.Test)3 SymphonyIdentity (com.symphony.api.id.SymphonyIdentity)2 IOException (java.io.IOException)2 ApiBuilder (com.symphony.api.bindings.ApiBuilder)1 ConfigurableApiBuilder (com.symphony.api.bindings.ConfigurableApiBuilder)1 CXFApiBuilder (com.symphony.api.bindings.cxf.CXFApiBuilder)1 ArrayList (java.util.ArrayList)1 TrustManager (javax.net.ssl.TrustManager)1 KoreAIResponseHandler (org.finos.symphony.toolkit.koreai.output.KoreAIResponseHandler)1 KoreAIRequester (org.finos.symphony.toolkit.koreai.request.KoreAIRequester)1 KoreAIResponseBuilder (org.finos.symphony.toolkit.koreai.response.KoreAIResponseBuilder)1 ApiBuilderFactory (org.finos.symphony.toolkit.spring.api.builders.ApiBuilderFactory)1 ApiInstanceFactory (org.finos.symphony.toolkit.spring.api.factories.ApiInstanceFactory)1 TokenManagingApiInstanceFactory (org.finos.symphony.toolkit.spring.api.factories.TokenManagingApiInstanceFactory)1 StreamEventConsumer (org.finos.symphony.toolkit.stream.StreamEventConsumer)1 SymphonyStreamHandler (org.finos.symphony.toolkit.stream.handler.SymphonyStreamHandler)1 RoomWelcomeEventConsumer (org.finos.symphony.toolkit.stream.welcome.RoomWelcomeEventConsumer)1