public static CreateUsingTokenRequest CreateUsingToken() { string url = ApiUtil.BuildUrl("payment_sources", "create_using_token"); return(new CreateUsingTokenRequest(url, HttpMethod.POST)); }
public static ClaimGiftRequest ClaimGift() { string url = ApiUtil.BuildUrl("hosted_pages", "claim_gift"); return(new ClaimGiftRequest(url, HttpMethod.POST)); }
public static EntityRequest <Type> Acknowledge(string id) { string url = ApiUtil.BuildUrl("hosted_pages", CheckNull(id), "acknowledge"); return(new EntityRequest <Type>(url, HttpMethod.POST)); }
public static CollectNowRequest CollectNow() { string url = ApiUtil.BuildUrl("hosted_pages", "collect_now"); return(new CollectNowRequest(url, HttpMethod.POST)); }
public static ExtendSubscriptionRequest ExtendSubscription() { string url = ApiUtil.BuildUrl("hosted_pages", "extend_subscription"); return(new ExtendSubscriptionRequest(url, HttpMethod.POST)); }
public static CheckoutExistingRequest CheckoutExisting() { string url = ApiUtil.BuildUrl("hosted_pages", "checkout_existing"); return(new CheckoutExistingRequest(url, HttpMethod.POST)); }
public static UpdatePaymentMethodRequest UpdatePaymentMethod() { string url = ApiUtil.BuildUrl("hosted_pages", "update_payment_method"); return(new UpdatePaymentMethodRequest(url, HttpMethod.POST)); }
public static PaymentSourceListRequest List() { string url = ApiUtil.BuildUrl("payment_sources"); return(new PaymentSourceListRequest(url)); }
public static SwitchGatewayAccountRequest SwitchGatewayAccount(string id) { string url = ApiUtil.BuildUrl("payment_sources", CheckNull(id), "switch_gateway_account"); return(new SwitchGatewayAccountRequest(url, HttpMethod.POST)); }
public static UpdateCardRequest UpdateCard(string id) { string url = ApiUtil.BuildUrl("payment_sources", CheckNull(id), "update_card"); return(new UpdateCardRequest(url, HttpMethod.POST)); }
public static VerifyBankAccountRequest VerifyBankAccount(string id) { string url = ApiUtil.BuildUrl("payment_sources", CheckNull(id), "verify_bank_account"); return(new VerifyBankAccountRequest(url, HttpMethod.POST)); }
public static CreateBankAccountRequest CreateBankAccount() { string url = ApiUtil.BuildUrl("payment_sources", "create_bank_account"); return(new CreateBankAccountRequest(url, HttpMethod.POST)); }
public static CreateCardRequest CreateCard() { string url = ApiUtil.BuildUrl("payment_sources", "create_card"); return(new CreateCardRequest(url, HttpMethod.POST)); }
public static CreateUsingPaymentIntentRequest CreateUsingPaymentIntent() { string url = ApiUtil.BuildUrl("payment_sources", "create_using_payment_intent"); return(new CreateUsingPaymentIntentRequest(url, HttpMethod.POST)); }
public static EntityRequest <Type> Retrieve(string id) { string url = ApiUtil.BuildUrl("hosted_pages", CheckNull(id)); return(new EntityRequest <Type>(url, HttpMethod.GET)); }
public static ExportPaymentSourceRequest ExportPaymentSource(string id) { string url = ApiUtil.BuildUrl("payment_sources", CheckNull(id), "export_payment_source"); return(new ExportPaymentSourceRequest(url, HttpMethod.POST)); }
public static HostedPageListRequest List() { string url = ApiUtil.BuildUrl("hosted_pages"); return(new HostedPageListRequest(url)); }
public static CreateRequest Create() { string url = ApiUtil.BuildUrl("coupons"); return(new CreateRequest(url, HttpMethod.POST)); }
public static UpdateCardRequest UpdateCard() { string url = ApiUtil.BuildUrl("hosted_pages", "update_card"); return(new UpdateCardRequest(url, HttpMethod.POST)); }
public static CouponListRequest List() { string url = ApiUtil.BuildUrl("coupons"); return(new CouponListRequest(url)); }
public static ManagePaymentSourcesRequest ManagePaymentSources() { string url = ApiUtil.BuildUrl("hosted_pages", "manage_payment_sources"); return(new ManagePaymentSourcesRequest(url, HttpMethod.POST)); }
public static CopyRequest Copy() { string url = ApiUtil.BuildUrl("coupons", "copy"); return(new CopyRequest(url, HttpMethod.POST)); }
public static AcceptQuoteRequest AcceptQuote() { string url = ApiUtil.BuildUrl("hosted_pages", "accept_quote"); return(new AcceptQuoteRequest(url, HttpMethod.POST)); }
public static EntityRequest <Type> Unarchive(string id) { string url = ApiUtil.BuildUrl("coupons", CheckNull(id), "unarchive"); return(new EntityRequest <Type>(url, HttpMethod.POST)); }
public static CheckoutGiftRequest CheckoutGift() { string url = ApiUtil.BuildUrl("hosted_pages", "checkout_gift"); return(new CheckoutGiftRequest(url, HttpMethod.POST)); }
public async Task <Boolean> CreateSessionAsync(CancellationToken token) { Trace.Entering(); // Settings var configManager = HostContext.GetService <IConfigurationManager>(); _settings = configManager.LoadSettings(); var serverUrl = _settings.ServerUrl; Trace.Info(_settings); // Capabilities. _term.WriteLine(StringUtil.Loc("ScanToolCapabilities")); Dictionary <string, string> systemCapabilities = await HostContext.GetService <ICapabilitiesManager>().GetCapabilitiesAsync(_settings, token); // Create connection. Trace.Verbose("Loading Credentials"); var credMgr = HostContext.GetService <ICredentialManager>(); VssCredentials creds = credMgr.LoadCredentials(); Uri uri = new Uri(serverUrl); VssConnection conn = ApiUtil.CreateConnection(uri, creds); var agent = new TaskAgentReference { Id = _settings.AgentId, Name = _settings.AgentName, Version = Constants.Agent.Version, OSDescription = RuntimeInformation.OSDescription, }; string sessionName = $"{Environment.MachineName ?? "AGENT"}"; var taskAgentSession = new TaskAgentSession(sessionName, agent, systemCapabilities); string errorMessage = string.Empty; bool encounteringError = false; _term.WriteLine(StringUtil.Loc("ConnectToServer")); while (true) { token.ThrowIfCancellationRequested(); Trace.Info($"Attempt to create session."); try { Trace.Info("Connecting to the Agent Server..."); await _agentServer.ConnectAsync(conn); _session = await _agentServer.CreateAgentSessionAsync( _settings.PoolId, taskAgentSession, token); Trace.Info($"Session created."); if (encounteringError) { _term.WriteLine(StringUtil.Loc("QueueConnected", DateTime.UtcNow)); _sessionCreationExceptionTracker.Clear(); encounteringError = false; } return(true); } catch (OperationCanceledException) when(token.IsCancellationRequested) { Trace.Info("Session creation has been cancelled."); throw; } catch (Exception ex) { Trace.Error("Catch exception during create session."); Trace.Error(ex); if (!IsSessionCreationExceptionRetriable(ex)) { _term.WriteError(StringUtil.Loc("SessionCreateFailed", ex.Message)); return(false); } if (!encounteringError) //print the message only on the first error { _term.WriteError(StringUtil.Loc("QueueConError", DateTime.UtcNow, ex.Message, _sessionCreationRetryInterval.TotalSeconds)); encounteringError = true; } Trace.Info("Sleeping for {0} seconds before retrying.", _sessionCreationRetryInterval.TotalSeconds); await HostContext.Delay(_sessionCreationRetryInterval, token); } } }
public static RetrieveAgreementPdfRequest RetrieveAgreementPdf() { string url = ApiUtil.BuildUrl("hosted_pages", "retrieve_agreement_pdf"); return(new RetrieveAgreementPdfRequest(url, HttpMethod.POST)); }
static void RoundTrip(string file) { AssetMapping.GlobalIsThreadLocal = true; AssetMapping.Global.Clear() .RegisterAssetType(typeof(Base.Automap), AssetType.Automap) .RegisterAssetType(typeof(Base.Chest), AssetType.Chest) .RegisterAssetType(typeof(Base.EventSet), AssetType.EventSet) .RegisterAssetType(typeof(Base.Item), AssetType.Item) .RegisterAssetType(typeof(Base.LargeNpc), AssetType.LargeNpcGraphics) .RegisterAssetType(typeof(Base.LargePartyMember), AssetType.LargePartyGraphics) .RegisterAssetType(typeof(Base.Map), AssetType.Map) .RegisterAssetType(typeof(Base.Merchant), AssetType.Merchant) .RegisterAssetType(typeof(Base.Npc), AssetType.Npc) .RegisterAssetType(typeof(Base.PartyMember), AssetType.Party) .RegisterAssetType(typeof(Base.Portrait), AssetType.Portrait) .RegisterAssetType(typeof(Base.SmallNpc), AssetType.SmallNpcGraphics) .RegisterAssetType(typeof(Base.SmallPartyMember), AssetType.SmallPartyGraphics) .RegisterAssetType(typeof(Base.Spell), AssetType.Spell) .RegisterAssetType(typeof(Base.Switch), AssetType.Switch) .RegisterAssetType(typeof(Base.Ticker), AssetType.Ticker); var mapping = AssetMapping.Global; var jsonUtil = new FormatJsonUtil(); var spellManager = new MockSpellManager(); foreach (var school in Enum.GetValues <SpellClass>()) { for (byte i = 0; i < 30; i++) { var id = new SpellId(AssetType.Spell, (int)school * 30 + i); var spell = new SpellData(id, school, i); spellManager.Add(spell); } } // === Load === using var stream = File.Open(file, FileMode.Open, FileAccess.Read); using var br = new BinaryReader(stream); using var annotationReadStream = new MemoryStream(); using var annotationReader = new StreamWriter(annotationReadStream); using var ar = new AnnotationFacadeSerializer(new AlbionReader(br, stream.Length), annotationReader, FormatUtil.BytesFrom850String); var save = SavedGame.Serdes(null, mapping, ar, spellManager); // === Save === using var ms = new MemoryStream(); using var bw = new BinaryWriter(ms); using var annotationWriteStream = new MemoryStream(); using var annotationWriter = new StreamWriter(annotationWriteStream); using var aw = new AnnotationFacadeSerializer(new AlbionWriter(bw), annotationWriter, FormatUtil.BytesFrom850String); SavedGame.Serdes(save, mapping, aw, spellManager); File.WriteAllText(file + ".json", jsonUtil.Serialize(save)); // write out debugging files and compare round-tripped data br.BaseStream.Position = 0; var originalBytes = br.ReadBytes((int)stream.Length); var roundTripBytes = ms.ToArray(); ApiUtil.Assert(originalBytes.Length == roundTripBytes.Length, $"Save game size changed after round trip (delta {roundTripBytes.Length - originalBytes.Length})"); ApiUtil.Assert(originalBytes.SequenceEqual(roundTripBytes)); var diffs = XDelta.Compare(originalBytes, roundTripBytes).ToArray(); if (diffs.Length != 1) {
public void InitializeJob(JobRequestMessage message, CancellationToken token) { // Validation Trace.Entering(); ArgUtil.NotNull(message, nameof(message)); ArgUtil.NotNull(message.Environment, nameof(message.Environment)); ArgUtil.NotNull(message.Environment.SystemConnection, nameof(message.Environment.SystemConnection)); ArgUtil.NotNull(message.Environment.Endpoints, nameof(message.Environment.Endpoints)); ArgUtil.NotNull(message.Environment.Variables, nameof(message.Environment.Variables)); ArgUtil.NotNull(message.Plan, nameof(message.Plan)); _cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token); // Features Features = ApiUtil.GetFeatures(message.Plan); // Endpoints Endpoints = message.Environment.Endpoints; Endpoints.Add(message.Environment.SystemConnection); // SecureFiles SecureFiles = message.Environment.SecureFiles; // Variables (constructor performs initial recursive expansion) List <string> warnings; Variables = new Variables(HostContext, message.Environment.Variables, message.Environment.MaskHints, out warnings); // Prepend Path PrependPath = new List <string>(); // Docker Container = new ContainerInfo() { ContainerImage = Variables.Get("_PREVIEW_VSTS_DOCKER_IMAGE"), ContainerName = $"VSTS_{Variables.System_HostType.ToString()}_{message.JobId.ToString("D")}", }; // Proxy variables var agentWebProxy = HostContext.GetService <IVstsAgentWebProxy>(); if (!string.IsNullOrEmpty(agentWebProxy.ProxyAddress)) { Variables.Set(Constants.Variables.Agent.ProxyUrl, agentWebProxy.ProxyAddress); Environment.SetEnvironmentVariable("VSTS_HTTP_PROXY", string.Empty); if (!string.IsNullOrEmpty(agentWebProxy.ProxyUsername)) { Variables.Set(Constants.Variables.Agent.ProxyUsername, agentWebProxy.ProxyUsername); Environment.SetEnvironmentVariable("VSTS_HTTP_PROXY_USERNAME", string.Empty); } if (!string.IsNullOrEmpty(agentWebProxy.ProxyPassword)) { Variables.Set(Constants.Variables.Agent.ProxyPassword, agentWebProxy.ProxyPassword, true); Environment.SetEnvironmentVariable("VSTS_HTTP_PROXY_PASSWORD", string.Empty); } } // Job timeline record. InitializeTimelineRecord( timelineId: message.Timeline.Id, timelineRecordId: message.JobId, parentTimelineRecordId: null, recordType: ExecutionContextType.Job, displayName: message.JobName, refName: message.JobRefName, order: 1); // The job timeline record must be at order 1. // Logger (must be initialized before writing warnings). _logger = HostContext.CreateService <IPagingLogger>(); _logger.Setup(_mainTimelineId, _record.Id); // Log warnings from recursive variable expansion. warnings?.ForEach(x => this.Warning(x)); // Verbosity (from system.debug). WriteDebug = Variables.System_Debug ?? false; // Hook up JobServerQueueThrottling event, we will log warning on server tarpit. _jobServerQueue.JobServerQueueThrottling += JobServerQueueThrottling_EventReceived; }
public static EntityRequest <Type> DeleteLocal(string id) { string url = ApiUtil.BuildUrl("payment_sources", CheckNull(id), "delete_local"); return(new EntityRequest <Type>(url, HttpMethod.POST)); }