internal static async Task HttpGetContainers(RequestMetadata md) { string header = _Header + md.Http.Request.Source.IpAddress + ":" + md.Http.Request.Source.Port + " "; if (md.User == null) { _Logging.Warn(header + "HttpGetContainers no authentication material"); md.Http.Response.StatusCode = 401; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(Common.SerializeJson(new ErrorResponse(3, 401, null, null), true)); return; } if (!md.Params.UserGUID.ToLower().Equals(md.User.GUID.ToLower())) { _Logging.Warn(header + "HttpGetContainers user " + md.User.GUID + " attempting to retrieve container list for user " + md.Params.UserGUID); md.Http.Response.StatusCode = 401; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(Common.SerializeJson(new ErrorResponse(3, 401, null, null), true)); return; } List <Container> containers = _ContainerMgr.GetContainersByUser(md.Params.UserGUID); md.Http.Response.StatusCode = 200; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(Common.SerializeJson(containers, true)); return; }
public bool ReadKeyValues( RequestMetadata md, ContainerClient client, string objectName, out Dictionary <string, string> dict, out ErrorCode error) { error = ErrorCode.None; dict = new Dictionary <string, string>(); if (md == null) { throw new ArgumentNullException(nameof(md)); } if (client == null) { throw new ArgumentNullException(nameof(client)); } if (String.IsNullOrEmpty(objectName)) { throw new ArgumentNullException(nameof(objectName)); } string logMessage = md.Http.Request.SourceIp + ":" + md.Http.Request.SourcePort + " ReadKeyValues " + client.Container.UserGuid + "/" + client.Container.Name + "/" + objectName + " "; if (!client.ReadObjectKeyValues(objectName, out dict, out error)) { _Logging.Warn(logMessage + "unable to read key values: " + error.ToString()); return(false); } return(true); }
public object GetData([FromBody] RequestMetadata request) { var tableName = request.table.ToLower(); var sql = "select * from " + tableName; return(_connection.GetRestData(sql, request)); }
/* * Read operations cannot continue if the URL is being written, but can continue if being read elsewhere. * */ internal string AddReadLock(RequestMetadata md) { if (md == null) { throw new ArgumentNullException(nameof(md)); } if (WriteLockExists(md.Http.Request.Url.RawWithoutQuery)) { return(null); } UrlLock urlLock = null; DateTime expirationUtc = DateTime.Now.ToUniversalTime().AddSeconds(_Settings.Storage.LockExpirationSeconds); if (md.Params.ExpirationUtc != null) { expirationUtc = md.Params.ExpirationUtc.Value.ToUniversalTime(); } if (md.User != null && !String.IsNullOrEmpty(md.User.GUID)) { urlLock = new UrlLock(LockType.Read, md.Http.Request.Url.RawWithoutQuery, md.User.GUID, expirationUtc); } else { urlLock = new UrlLock(LockType.Read, md.Http.Request.Url.RawWithoutQuery, null, expirationUtc); } urlLock = _ORM.Insert <UrlLock>(urlLock); return(urlLock.GUID); }
private static async Task DeleteIndexDocument(RequestMetadata md) { string header = "[Komodo.Server] " + md.Http.Request.Source.IpAddress + ":" + md.Http.Request.Source.Port + " DeleteIndexDocument "; string indexName = md.Http.Request.Url.Elements[0]; string sourceGuid = md.Http.Request.Url.Elements[1]; if (!_Daemon.IndexExists(indexName)) { _Logging.Warn(header + "index " + indexName + " does not exist"); md.Http.Response.StatusCode = 404; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(new ErrorResponse(404, "Unknown index.", null, null).ToJson(true)); return; } if (!_Daemon.SourceDocumentExists(indexName, sourceGuid)) { _Logging.Warn(header + "document " + indexName + "/" + sourceGuid + " does not exist"); md.Http.Response.StatusCode = 404; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(new ErrorResponse(404, "Unknown document.", null, null).ToJson(true)); return; } _Daemon.RemoveDocument(indexName, sourceGuid); _Logging.Debug(header + "deleted document " + indexName + "/" + sourceGuid); md.Http.Response.StatusCode = 204; await md.Http.Response.Send(); return; }
private static async Task GetIndexStats(RequestMetadata md) { string header = "[Komodo.Server] " + md.Http.Request.Source.IpAddress + ":" + md.Http.Request.Source.Port + " GetIndexStats "; string indexName = md.Http.Request.Url.Elements[0]; IndicesStats stats = _Daemon.GetIndexStats(indexName); if (stats == null) { if (String.IsNullOrEmpty(indexName)) { _Logging.Warn(header + "index " + indexName + " does not exist"); md.Http.Response.StatusCode = 404; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(new ErrorResponse(404, "Unknown index.", null, null).ToJson(true)); } else { _Logging.Warn(header + "no indices found"); md.Http.Response.StatusCode = 404; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(new ErrorResponse(404, "No indices found.", null, null).ToJson(true)); } return; } md.Http.Response.StatusCode = 200; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(Common.SerializeJson(stats, md.Params.Pretty)); return; }
public async Task ResetPasswordAsync(string loginName, string newPassword, UserCredentials userCredentials = null, CancellationToken cancellationToken = default) { if (loginName == null) { throw new ArgumentNullException(nameof(loginName)); } if (newPassword == null) { throw new ArgumentNullException(nameof(newPassword)); } if (loginName == string.Empty) { throw new ArgumentOutOfRangeException(nameof(loginName)); } if (newPassword == string.Empty) { throw new ArgumentOutOfRangeException(nameof(newPassword)); } await _client.ResetPasswordAsync(new ResetPasswordReq { Options = new ResetPasswordReq.Types.Options { NewPassword = newPassword, LoginName = loginName } }, RequestMetadata.Create(userCredentials), cancellationToken : cancellationToken); }
static async Task GetDatabase(RequestMetadata md) { string dbName = md.Http.Request.Url.Elements[0]; Database db = _Settings.GetDatabaseByName(dbName); if (db == null) { md.Http.Response.StatusCode = 404; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(SerializationHelper.SerializeJson(new ErrorResponse(ErrorCodeEnum.NotFound, "The requested object was not found", null), true)); return; } db = Database.Redact(db); string describe = md.Http.Request.RetrieveHeaderValue("_describe"); if (!String.IsNullOrEmpty(describe) && describe.Equals("true")) { db.Tables = _Databases.GetTables(dbName, true); } else { db.TableNames = _Databases.GetTableNames(dbName); } md.Http.Response.StatusCode = 200; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(SerializationHelper.SerializeJson(db, true)); return; }
internal bool Lock( RequestMetadata md, ContainerClient client, out string lockGuid, out ErrorCode error) { lockGuid = null; error = ErrorCode.None; if (md == null) { throw new ArgumentNullException(nameof(md)); } if (client == null) { throw new ArgumentNullException(nameof(client)); } string header = _Header + "Lock " + client.Container.UserGUID + "/" + client.Container.Name + "/" + md.Params.ObjectKey + " "; if (md.Params.ExpirationUtc != null) { if (md.Params.WriteLock) { if (_Locks.LockExists(md.Http.Request.Url.RawWithoutQuery)) { _Logging.Warn(header + "lock already exists"); error = ErrorCode.AlreadyExists; return(false); } lockGuid = _Locks.AddWriteLock(md); } else if (md.Params.ReadLock) { if (_Locks.LockExists(md.Http.Request.Url.RawWithoutQuery)) { _Logging.Warn(header + "already exists"); error = ErrorCode.AlreadyExists; return(false); } lockGuid = _Locks.AddReadLock(md); } } else { _Logging.Warn(header + "no expiration supplied"); error = ErrorCode.OutOfRange; return(false); } if (!String.IsNullOrEmpty(lockGuid)) { return(true); } else { error = ErrorCode.AlreadyExists; return(false); } }
/// <summary> /// Sends a speech recognition request to the speech service /// </summary> /// <param name="audioFile">The audio file.</param> /// <param name="locale">The locale.</param> /// <param name="serviceUrl">The service URL.</param> /// <param name="subscriptionKey">The subscription key.</param> /// <returns> /// A task /// </returns> public async Task Run(string audioFile, string locale, Uri serviceUrl, string subscriptionKey, string resultFile) { // create the preferences object var preferences = new Preferences(locale, serviceUrl, new CognitiveServicesAuthorizationProvider(subscriptionKey)); ResultFile = resultFile; File.CreateText(ResultFile); // Create a a speech client using (var speechClient = new SpeechClient(preferences)) { speechClient.SubscribeToPartialResult(this.OnPartialResult); speechClient.SubscribeToRecognitionResult(this.OnRecognitionResult); // create an audio content and pass it a stream. using (var audio = new FileStream(audioFile, FileMode.Open, FileAccess.Read)) { var deviceMetadata = new DeviceMetadata(DeviceType.Near, DeviceFamily.Desktop, NetworkType.Ethernet, OsName.Windows, "1607", "Dell", "T3600"); var applicationMetadata = new ApplicationMetadata("SampleApp", "1.0.0"); var requestMetadata = new RequestMetadata(Guid.NewGuid(), deviceMetadata, applicationMetadata, "SampleAppService"); await speechClient.RecognizeAsync(new SpeechInput(audio, requestMetadata), this.cts.Token).ConfigureAwait(false); } } }
private async Task Start() { _call = _client.Read(RequestMetadata.Create(_userCredentials), cancellationToken: _disposed.Token); try { await _call.RequestStream.WriteAsync(new ReadReq { Options = _options }); if (!await _call.ResponseStream.MoveNext(_disposed.Token) || _call.ResponseStream.Current.ContentCase != ReadResp.ContentOneofCase.Empty) { throw new InvalidOperationException(); } } catch (Exception ex) { SubscriptionDropped(SubscriptionDroppedReason.ServerError, ex); return; } finally { _started.SetResult(true); } #pragma warning disable 4014 Task.Run(Subscribe); #pragma warning restore 4014 }
public async Task DecodeAudioAsync( Stream stream, string locale, PhraseMode mode, Func <RecognitionStep, Task> partialResult, Func <RecognitionFinalResult, Task> finalResult) { var serviceUrl = (mode == PhraseMode.LongDictation ? LongDictationUrl : ShortPhraseUrl); string subscriptionKey = configuration.GetSection("AudioToTextService.Core.AudioDecoder")["subscriptionKey"]; // create the preferences object var preferences = new Preferences(locale, serviceUrl, new CognitiveServicesAuthorizationProvider(subscriptionKey)); // Create a a speech client using (var speechClient = new SpeechClient(preferences)) { speechClient.SubscribeToPartialResult((args) => { return(partialResult(ToStep(args))); }); speechClient.SubscribeToRecognitionResult((args) => { return(finalResult(ToFinalResult(args))); }); // create an audio content and pass it a stream. var deviceMetadata = new DeviceMetadata(DeviceType.Near, DeviceFamily.Desktop, NetworkType.Ethernet, OsName.Windows, "1607", "Dell", "T3600"); var applicationMetadata = new ApplicationMetadata("SampleApp", "1.0.0"); var requestMetadata = new RequestMetadata(Guid.NewGuid(), deviceMetadata, applicationMetadata, "SampleAppService"); await speechClient.RecognizeAsync(new SpeechInput(stream, requestMetadata), this.cts.Token).ConfigureAwait(false); } }
internal bool ReadKeyValues( RequestMetadata md, ContainerClient client, string objectName, out Dictionary <string, string> dict, out ErrorCode error) { error = ErrorCode.None; dict = new Dictionary <string, string>(); if (md == null) { throw new ArgumentNullException(nameof(md)); } if (client == null) { throw new ArgumentNullException(nameof(client)); } if (String.IsNullOrEmpty(objectName)) { throw new ArgumentNullException(nameof(objectName)); } string header = _Header + "ReadKeyValues " + client.Container.UserGUID + "/" + client.Container.Name + "/" + objectName + " "; if (!client.ReadObjectKeyValues(objectName, out dict, out error)) { _Logging.Warn(header + "unable to read key values: " + error.ToString()); return(false); } return(true); }
// [END custom_attribute_job // [START custom_attribute_filter_string_value] public static void FiltersOnStringValueCustomAttribute() { RequestMetadata requestMetadata = new RequestMetadata() { UserId = "HashedUserId", SessionId = "HashedSessionId", Domain = "www.google.com" }; string customAttributeFilter = "NOT EMPTY(custom_attribute)"; JobQuery jobQuery = new JobQuery() { CustomAttributeFilter = customAttributeFilter }; SearchJobsRequest searchJobsRequest = new SearchJobsRequest() { JobQuery = jobQuery, RequestMetadata = requestMetadata, JobView = "JOB_VIEW_FULL" }; SearchJobsResponse response = jobServiceClient.Projects.Jobs.Search(searchJobsRequest, parent).Execute(); Console.WriteLine("Searched on custom attribute: " + ToJsonString(response)); }
internal bool Exists( RequestMetadata md, ContainerClient client, string objectName) { if (md == null) { throw new ArgumentNullException(nameof(md)); } if (client == null) { throw new ArgumentNullException(nameof(client)); } if (String.IsNullOrEmpty(objectName)) { throw new ArgumentNullException(nameof(objectName)); } string header = _Header + "Exists " + client.Container.UserGUID + "/" + client.Container.Name + "/" + objectName + " "; if (!client.Exists(objectName)) { _Logging.Debug(header + "object does not exist"); return(false); } else { string logData = "Source: " + md.Http.Request.SourceIp + ":" + md.Http.Request.SourcePort + " " + "User: " + md.Params.UserGuid; client.AddAuditLogEntry(objectName, AuditLogEntryType.Exists, logData, false); return(true); } }
// [END custom_attribute_filter_long_value] // [START custom_attribute_filter_multi_attributes public static void FiltersOnMultiCustomAttributes() { RequestMetadata requestMetadata = new RequestMetadata() { UserId = "HashedUserId", SessionId = "HashedSessionId", Domain = "www.google.com" }; string customAttributeFilter = "(someFiledName1 = \"value1\") " + "AND ((255 <= someFieldName2) OR (someFieldName2 <= 213))"; JobQuery jobQuery = new JobQuery() { CustomAttributeFilter = customAttributeFilter }; SearchJobsRequest searchJobsRequest = new SearchJobsRequest() { JobQuery = jobQuery, RequestMetadata = requestMetadata, JobView = "JOB_VIEW_FULL" }; SearchJobsResponse response = jobServiceClient.Projects.Jobs.Search(searchJobsRequest, parent).Execute(); Console.WriteLine("Searched on cross-field-filtering: " + ToJsonString(response)); }
public static async Task HttpHeadContainer(RequestMetadata md) { string header = md.Http.Request.SourceIp + ":" + md.Http.Request.SourcePort + " "; #region Retrieve-Container Container currContainer = _ContainerMgr.GetContainer(md.Params.UserGuid, md.Params.ContainerName); if (currContainer == null) { _Logging.Debug(header + "HttpHeadContainer unable to find container " + md.Params.UserGuid + "/" + md.Params.ContainerName); md.Http.Response.StatusCode = 404; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(Common.SerializeJson(new ErrorResponse(5, 404, null, null), true)); return; } else { md.Http.Response.StatusCode = 200; await md.Http.Response.Send(); return; } #endregion }
/// <summary> /// Create an EnumerationFilter from RequestMetadata. /// </summary> /// <param name="md">RequestMetadata.</param> /// <returns>EnumerationFilter.</returns> public static EnumerationFilter FromRequestMetadata(RequestMetadata md) { if (md == null) { throw new ArgumentNullException(nameof(md)); } EnumerationFilter ret = new EnumerationFilter(); if (md.Params != null) { if (!String.IsNullOrEmpty(md.Params.Prefix)) { ret.Prefix = md.Params.Prefix; } ret.CreatedAfter = md.Params.CreatedAfter; ret.CreatedBefore = md.Params.CreatedBefore; ret.LastAccessAfter = md.Params.LastAccessAfter; ret.LastAccessBefore = md.Params.LastAccessBefore; ret.UpdatedAfter = md.Params.UpdatedAfter; ret.UpdatedBefore = md.Params.UpdatedBefore; ret.Md5 = md.Params.Md5; ret.SizeMax = md.Params.SizeMax; ret.SizeMin = md.Params.SizeMin; if (!String.IsNullOrEmpty(md.Params.Tags)) { ret.Tags = Common.CsvToStringList(md.Params.Tags); } } return(ret); }
public static async Task HttpHeadHandler(RequestMetadata md) { string header = md.Http.Request.SourceIp + ":" + md.Http.Request.SourcePort + " "; if (md.Http.Request.RawUrlEntries.Count == 2) { await HttpHeadContainer(md); return; } else if (md.Http.Request.RawUrlEntries.Count >= 3) { await HttpHeadObject(md); return; } else { _Logging.Warn(header + "HttpHeadHandler container URL does not conform to required structure"); md.Http.Response.StatusCode = 400; md.Http.Response.ContentType = "application.json"; await md.Http.Response.Send(Common.SerializeJson(new ErrorResponse(2, 400, "URL path must be of the form /[user]/[container]/[key].", null), true)); return; } }
/// <summary> /// 通过语音数据识别语音内容 /// </summary> /// <param name="audioBytes">语音数据</param> /// <param name="locale">语种</param> /// <returns></returns> public async Task RunDiscernAsBytes(byte[] audioBytes, string locale) { Uri serviceUrl = ShortUrl; if (GetWavPlayTime(audioBytes) > 15) { serviceUrl = LongUrl; } var preferences = new Preferences(locale, serviceUrl, new AsrCheckKeyProvider(apiKey)); //参数配置类 using (var speechClient = new SpeechClient(preferences)) //创建语音客户端 { speechClient.SubscribeToPartialResult(this.OnPartialResult); speechClient.SubscribeToRecognitionResult(this.OnRecognitionResult); using (Stream stream = new MemoryStream(audioBytes)) { var deviceMetadata = new DeviceMetadata(DeviceType.Near, DeviceFamily.Desktop, NetworkType.Ethernet, OsName.Windows, "1607", "Dell", "T3600"); var applicationMetadata = new ApplicationMetadata("SampleApp", "1.0.0"); var requestMetadata = new RequestMetadata(Guid.NewGuid(), deviceMetadata, applicationMetadata, "SampleAppService"); try { await speechClient.RecognizeAsync(new SpeechInput(stream, requestMetadata), this.cts.Token).ConfigureAwait(false); } catch (Exception ex) { } } } }
internal bool GetLocks( RequestMetadata md, ContainerClient client, out List <UrlLock> locks, out ErrorCode errorCode) { errorCode = ErrorCode.None; locks = new List <UrlLock>(); if (md == null) { throw new ArgumentNullException(nameof(md)); } if (client == null) { throw new ArgumentNullException(nameof(client)); } string header = _Header + "Unlock " + client.Container.UserGUID + "/" + client.Container.Name + "/" + md.Params.ObjectKey + " "; if (md.Params.WriteLock) { locks = _Locks.GetWriteLocks(); return(true); } else if (md.Params.ReadLock) { locks = _Locks.GetReadLocks(); return(true); } else { errorCode = ErrorCode.NotFound; return(false); } }
public async Task <DatabaseScavengeResult> StartScavengeAsync( int threadCount = 1, int startFromChunk = 0, UserCredentials userCredentials = default, CancellationToken cancellationToken = default) { if (threadCount <= 0) { throw new ArgumentOutOfRangeException(nameof(threadCount)); } if (startFromChunk < 0) { throw new ArgumentOutOfRangeException(nameof(startFromChunk)); } var result = await _client.StartScavengeAsync(new StartScavengeReq { Options = new StartScavengeReq.Types.Options { ThreadCount = threadCount, StartFromChunk = startFromChunk } }, RequestMetadata.Create(userCredentials), cancellationToken : cancellationToken); return(result.ScavengeResult switch { ScavengeResp.Types.ScavengeResult.Started => DatabaseScavengeResult.Started(result.ScavengeId), ScavengeResp.Types.ScavengeResult.Stopped => DatabaseScavengeResult.Stopped(result.ScavengeId), ScavengeResp.Types.ScavengeResult.InProgress => DatabaseScavengeResult.InProgress(result.ScavengeId), _ => throw new InvalidOperationException() });
// [END compensation_filter] public static void BasicSearchJobs(string companyName, string query) { RequestMetadata requestMetadata = new RequestMetadata() { // Make sure to hash your userID UserId = "HashedUserId", // Make sure to hash the sessionID SessionId = "HashedSessionId", // Domain of the website where the search is conducted Domain = "www.google.com" }; JobQuery jobQuery = new JobQuery() { Query = query, CompanyNames = new List <string> { companyName } }; SearchJobsRequest searchJobRequest = new SearchJobsRequest() { RequestMetadata = requestMetadata, JobQuery = jobQuery, SearchMode = "JOB_SEARCH" }; SearchJobsResponse searchJobsResponse = jobServiceClient.Projects.Jobs.Search(searchJobRequest, parent).Execute(); Console.WriteLine("Jobs searched: " + ToJsonString(searchJobsResponse)); }
static async Task GetDatabaseClients(RequestMetadata md) { md.Http.Response.StatusCode = 200; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(SerializationHelper.SerializeJson(_Databases.ListDatabasesByName(), true)); return; }
internal static async Task HttpGetConfig(RequestMetadata md) { md.Http.Response.StatusCode = 200; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(Common.SerializeJson(_Settings, true)); return; }
public async Task <OcspHttpResponse> Respond(OcspHttpRequest httpRequest, RequestMetadata metadata) { _logger.LogInformation(EventIds.Request, "OCSP request {Method} {Uri} from {RemoteIP}, length: {Length}", httpRequest.HttpMethod, httpRequest.RequestUri, metadata.RemoteIP, httpRequest.Content?.Length); var response = await _inner.Respond(httpRequest, metadata); _logger.LogInformation(EventIds.Response, "OCSP response {Status}, length: {Length}", response.Status, response.Content.Length); return(response); }
internal static async Task HttpHeadObject(RequestMetadata md) { string header = _Header + md.Http.Request.Source.IpAddress + ":" + md.Http.Request.Source.Port + " "; ContainerClient client = _ContainerMgr.GetContainerClient(md.Params.UserGUID, md.Params.ContainerName); if (client == null) { _Logging.Warn(header + "HttpHeadObject unable to find container " + md.Params.UserGUID + "/" + md.Params.ContainerName); md.Http.Response.StatusCode = 404; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(Common.SerializeJson(new ErrorResponse(5, 404, null, null), true)); return; } if (!client.Container.IsPublicRead) { if (md.User == null || !(md.User.GUID.ToLower().Equals(md.Params.UserGUID.ToLower()))) { _Logging.Warn(header + "HttpHeadObject unauthorized unauthenticated access attempt to object " + md.Params.UserGUID + "/" + md.Params.ContainerName + "/" + md.Params.ObjectKey); md.Http.Response.StatusCode = 401; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(Common.SerializeJson(new ErrorResponse(3, 401, null, null), true)); return; } } if (md.Perm != null) { if (!md.Perm.ReadObject) { _Logging.Warn(header + "HttpHeadObject unauthorized access attempt to object " + md.Params.UserGUID + "/" + md.Params.ContainerName + "/" + md.Params.ObjectKey); md.Http.Response.StatusCode = 401; md.Http.Response.ContentType = "application/json"; await md.Http.Response.Send(Common.SerializeJson(new ErrorResponse(3, 401, null, null), true)); return; } } if (!_ObjectHandler.Exists(md, client)) { _Logging.Debug(header + "HttpHeadObject unable to find object " + md.Params.UserGUID + "/" + md.Params.ContainerName + "/" + md.Params.ObjectKey); md.Http.Response.StatusCode = 404; await md.Http.Response.Send(); return; } else { md.Http.Response.StatusCode = 200; await md.Http.Response.Send(); return; } }
public Request_With_Body(Method Method, RequestMetadata Metadata, byte[] Body) : base(Method, Metadata) { if (!Request_May_Have_Body(Method)) { throw new ArgumentException(); } this.Body = Body; }
/// <summary> /// Initializes a new instance of the <see cref="HolidayApiClient" /> class. /// </summary> /// <param name="apiKey">The API key.</param> /// <param name="httpClient">The HTTP client.</param> public HolidayApiClient(string apiKey, HttpClient httpClient) { _apiKey = new Guid(apiKey); _metadata = new RequestMetadata { Message = "Make at least on request before get the metadata" }; _serviceFactory = new ServiceFactory(httpClient); }
// [END company_display_name_filter] // [START compensation_filter] public static void CompensationSearch(string companyName) { RequestMetadata requestMetadata = new RequestMetadata() { // Make sure to hash your userID UserId = "HashedUserId", // Make sure to hash the sessionID SessionId = "HashedSessionId", // Domain of the website where the search is conducted Domain = "www.google.com" }; JobQuery jobQuery = new JobQuery() { CompensationFilter = new CompensationFilter() { Type = "UNIT_AND_AMOUNT", Units = new List <string> { "HOURLY" }, Range = new CompensationRange() { MaxCompensation = new Money() { CurrencyCode = "USD", Units = 15L }, MinCompensation = new Money() { CurrencyCode = "USD", Units = 10L, Nanos = 500000000 } } } }; if (companyName != null) { jobQuery.CompanyNames = new List <string> { companyName }; } SearchJobsRequest searchJobRequest = new SearchJobsRequest() { RequestMetadata = requestMetadata, JobQuery = jobQuery, SearchMode = "JOB_SEARCH" }; SearchJobsResponse searchJobsResponse = jobServiceClient.Projects.Jobs.Search(searchJobRequest, parent).Execute(); Console.WriteLine("Jobs compensation searched: " + ToJsonString(searchJobsResponse)); }