Skip to content

Instantly share code, notes, and snippets.

View dimitrispaxinos's full-sized avatar

Dimitris Paxinos dimitrispaxinos

View GitHub Profile
function getConfig(request) {
const config = communityConnector.getConfig();
config.newInfo()
.setId('instructions')
.setText('Enter Country Name to fetch university data.');
config.newTextInput()
.setId('country')
.setName('Country')
{
"timeZone": "Europe/Athens",
"dependencies": {},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"dataStudio": {
"name": "Looker Universities List Connector",
"company": "Apptiva",
"logoUrl": "https://media.licdn.com/dms/image/C4D0BAQFef_MA6VQpeQ/company-logo_100_100/0/1621108560492?e=1698278400&v=beta&t=vXBwKHavpEkU5GFY3Lb-IAS5FwBpI5f0ueTqwIwh8-E",
"addonUrl": "https://www.apptivasoftware.com",
function getData(request) {
let dataSchema = [];
request.fields.forEach(function (field) {
for (const element of schema) {
if (element.name == field.name) {
dataSchema.push(element);
break;
}
}
});
let schema = [
{name: 'alpha_two_code', label: 'Alpha Two Code', dataType: 'STRING', semantics: {conceptType: 'DIMENSION'}},
{name: 'country', label: 'Country', dataType: 'STRING', semantics: {conceptType: 'DIMENSION'}},
{name: 'name', label: 'Name', dataType: 'STRING', semantics: {conceptType: 'DIMENSION'}},
];
// Use of the "new" keyword in order to be able to override non virtual methods
public async new Task<HttpResponseMessage> GetAsync(Uri requestUri)
{
var res = await _httpClient.GetAsync(requestUri);
LogResponseMessage(requestUri, res, "GET");
return res;
}
public SerilogHttpClientWrapper(HttpClient httpClient, ILogger logger)
{
_httpClient = httpClient;
_logger = logger;
}
/// <summary>
/// Implements the log logic of the Wrapper
/// </summary>
/// <param name="requestUri">Uri of the REST call</param>
/// <param name="responseMessage">Response Message</param>
/// <param name="restAction">Rest Action Name (GET,PUT,POST,DELETE)</param>
/// <param name="sentHttpContent">Sent HttpContent</param>
protected virtual void LogResponseMessage(Uri requestUri, HttpResponseMessage responseMessage, string restAction, HttpContent sentHttpContent = null)
{
using (LogContext.PushProperty("Request", sentHttpContent))
@dimitrispaxinos
dimitrispaxinos / SerilogHttpClientWrapper.cs
Last active October 31, 2024 18:43
HttpClient Wrapper with logging functionality using Serilog
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Serilog.Context;
namespace Serilog.RestCallMonitoring
{
public class SerilogHttpClientWrapper : HttpClient
{
private static string _templateString =
@dimitrispaxinos
dimitrispaxinos / UsingEnrichers.cs
Created November 9, 2015 21:09
Serilog: Use Enrichers
using (LogContext.PushProperties(new UserLogEventEnricher(User)))
{
Log.Logger.Information("Properties were added to the context using the enricher");
}
@dimitrispaxinos
dimitrispaxinos / LogEventEnricher.cs
Created November 9, 2015 21:05
Serilog: Add Context using ILogEventEnricher implementations
public class UserLogEventEnricher : ILogEventEnricher
{
private readonly IUser _user;
public UserLogEventEnricher(IUser user)
{
_user = user;
}
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)