001/* 002Copyright 2022 The OpenFunction Authors. 003 004Licensed under the Apache License, Version 2.0 (the "License"); 005you may not use this file except in compliance with the License. 006You may obtain a copy of the License at 007 008 http://www.apache.org/licenses/LICENSE-2.0 009 010Unless required by applicable law or agreed to in writing, software 011distributed under the License is distributed on an "AS IS" BASIS, 012WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013See the License for the specific language governing permissions and 014limitations under the License. 015*/ 016 017package dev.openfunction.functions; 018 019import io.cloudevents.CloudEvent; 020 021import java.util.Map; 022 023/** 024 * An interface for event function context. 025 */ 026public interface Context { 027 /** 028 * send provides the ability to allow the user to send data to a specified output target. 029 * 030 * @param outputName output target name 031 * @param data Data String 032 * @return Error 033 */ 034 Error send(String outputName, String data); 035 036 /** 037 * getHttpRequest returns the Http request. 038 * 039 * @return HttpRequest 040 */ 041 HttpRequest getHttpRequest(); 042 043 /** 044 * getHttpResponse returns the Http response. 045 * 046 * @return HttpResponse 047 */ 048 HttpResponse getHttpResponse(); 049 050 /** 051 * getBindingEvent returns the binding event. 052 * 053 * @return BindingEvent GetBindingEvent(); 054 */ 055 BindingEvent getBindingEvent(); 056 057 /** 058 * getTopicEvent returns the topic event. 059 * 060 * @return TopicEvent 061 */ 062 TopicEvent getTopicEvent(); 063 064 /** 065 * getCloudEvent returns the cloud Event. 066 * 067 * @return CloudEvent 068 */ 069 CloudEvent getCloudEvent(); 070 071 /** 072 * getName returns the function's name. 073 * 074 * @return Function Name 075 */ 076 String getName(); 077 078 /** 079 * getMode returns the operating environment mode of the function. 080 * 081 * @return Mode 082 */ 083 String getMode(); 084 085 /** 086 * GetOut returns the returned value of function. 087 * 088 * @return Out 089 */ 090 Out getOut(); 091 092 /** 093 * getRuntime returns the Runtime. 094 * 095 * @return String 096 */ 097 String getRuntime(); 098 099 /** 100 * getHttpPattern returns the path of the server listening for http function. 101 * 102 * @return String 103 */ 104 String getHttpPattern(); 105 106 107 /** 108 * getInputs returns the Inputs of function. 109 * 110 * @return Inputs 111 */ 112 Map<String, Component> getInputs(); 113 114 /** 115 * getOutputs returns the Outputs of function. 116 * 117 * @return Outputs 118 */ 119 Map<String, Component> getOutputs(); 120 121 /** 122 * getPodName returns the name of the pod the function is running on. 123 * 124 * @return name of pod 125 */ 126 String getPodName(); 127 128 /** 129 * getPodNamespace returns the namespace of the pod the function is running on. 130 * 131 * @return namespace of pod 132 */ 133 String getPodNamespace(); 134 135 /** 136 * @return pre plugins 137 */ 138 Map<String, Plugin> getPrePlugins(); 139 140 /** 141 * @return post plugin 142 */ 143 Map<String, Plugin> getPostPlugins(); 144}