-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathPublishONS.cs
39 lines (31 loc) · 1.21 KB
/
PublishONS.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Fnproject.Fn.Fdk;
using System.Runtime.CompilerServices;
using System.Collections.Generic;
using System;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Oci.OnsService;
using Oci.OnsService.Models;
namespace PublishONS
{
class Function
{
public string function_handler(InputMessage input)
{
Dictionary<string, List<ObjectDetails>> output = new Dictionary<string, List<ObjectDetails>>();
var object_details_list = new List<ObjectDetails>();
string topic_id = input.topic_id;
string msg_title = input.msg_title;
string msg_body = input.msg_body;
NotificationDataPlaneClient client = ONSClientHelper.GetONSClient();
Task<string> messageIdValue = InvokeONSHelper.SendMessage(client, topic_id, msg_title, msg_body);
var object_detail = new ObjectDetails();
object_detail.result = messageIdValue.Result;
object_details_list.Add(object_detail);
output.Add("results", object_details_list);
return System.Text.Json.JsonSerializer.Serialize(output);
}
static void Main(string[] args) { Fdk.Handle(args[0]); }
}
}