How to use origins method in wpt

Best JavaScript code snippet using wpt

ListApprovedOriginsCommand.ts

Source: ListApprovedOriginsCommand.ts Github

copy

Full Screen

1/​/​ smithy-typescript generated code2import { getSerdePlugin } from "@aws-sdk/​middleware-serde";3import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/​protocol-http";4import { Command as $Command } from "@aws-sdk/​smithy-client";5import {6 FinalizeHandlerArguments,7 Handler,8 HandlerExecutionContext,9 HttpHandlerOptions as __HttpHandlerOptions,10 MetadataBearer as __MetadataBearer,11 MiddlewareStack,12 SerdeContext as __SerdeContext,13} from "@aws-sdk/​types";14import { ConnectClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../​ConnectClient";15import {16 ListApprovedOriginsRequest,17 ListApprovedOriginsRequestFilterSensitiveLog,18 ListApprovedOriginsResponse,19 ListApprovedOriginsResponseFilterSensitiveLog,20} from "../​models/​models_0";21import {22 deserializeAws_restJson1ListApprovedOriginsCommand,23 serializeAws_restJson1ListApprovedOriginsCommand,24} from "../​protocols/​Aws_restJson1";25export interface ListApprovedOriginsCommandInput extends ListApprovedOriginsRequest {}26export interface ListApprovedOriginsCommandOutput extends ListApprovedOriginsResponse, __MetadataBearer {}27/​**28 * <p>This API is in preview release for Amazon Connect and is subject to change.</​p>29 * <p>Returns a paginated list of all approved origins associated with the instance.</​p>30 * @example31 * Use a bare-bones client and the command you need to make an API call.32 * ```javascript33 * import { ConnectClient, ListApprovedOriginsCommand } from "@aws-sdk/​client-connect"; /​/​ ES Modules import34 * /​/​ const { ConnectClient, ListApprovedOriginsCommand } = require("@aws-sdk/​client-connect"); /​/​ CommonJS import35 * const client = new ConnectClient(config);36 * const command = new ListApprovedOriginsCommand(input);37 * const response = await client.send(command);38 * ```39 *40 * @see {@link ListApprovedOriginsCommandInput} for command's `input` shape.41 * @see {@link ListApprovedOriginsCommandOutput} for command's `response` shape.42 * @see {@link ConnectClientResolvedConfig | config} for ConnectClient's `config` shape.43 *44 */​45export class ListApprovedOriginsCommand extends $Command<46 ListApprovedOriginsCommandInput,47 ListApprovedOriginsCommandOutput,48 ConnectClientResolvedConfig49> {50 /​/​ Start section: command_properties51 /​/​ End section: command_properties52 constructor(readonly input: ListApprovedOriginsCommandInput) {53 /​/​ Start section: command_constructor54 super();55 /​/​ End section: command_constructor56 }57 /​**58 * @internal59 */​60 resolveMiddleware(61 clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,62 configuration: ConnectClientResolvedConfig,63 options?: __HttpHandlerOptions64 ): Handler<ListApprovedOriginsCommandInput, ListApprovedOriginsCommandOutput> {65 this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));66 const stack = clientStack.concat(this.middlewareStack);67 const { logger } = configuration;68 const clientName = "ConnectClient";69 const commandName = "ListApprovedOriginsCommand";70 const handlerExecutionContext: HandlerExecutionContext = {71 logger,72 clientName,73 commandName,74 inputFilterSensitiveLog: ListApprovedOriginsRequestFilterSensitiveLog,75 outputFilterSensitiveLog: ListApprovedOriginsResponseFilterSensitiveLog,76 };77 const { requestHandler } = configuration;78 return stack.resolve(79 (request: FinalizeHandlerArguments<any>) =>80 requestHandler.handle(request.request as __HttpRequest, options || {}),81 handlerExecutionContext82 );83 }84 private serialize(input: ListApprovedOriginsCommandInput, context: __SerdeContext): Promise<__HttpRequest> {85 return serializeAws_restJson1ListApprovedOriginsCommand(input, context);86 }87 private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<ListApprovedOriginsCommandOutput> {88 return deserializeAws_restJson1ListApprovedOriginsCommand(output, context);89 }90 /​/​ Start section: command_body_extra91 /​/​ End section: command_body_extra...

Full Screen

Full Screen

origins.ts

Source: origins.ts Github

copy

Full Screen

1import * as Bluebird from 'bluebird';2import { difference } from 'lodash';3import { DAY } from '../​../​common/​constants';4import { fromNow } from '../​../​common/​utils';5import { Account, AccountOrigins, OriginStats, OriginInfo, Origin, ClearOrignsOptions } from '../​../​common/​adminInterfaces';6import { updateAccount } from '../​db';7import { AdminService } from '../​services/​adminService';8export async function getOriginStats(accounts: Account[]): Promise<OriginStats> {9 let totalOrigins = 0;10 let totalOriginsIP4 = 0;11 let totalOriginsIP6 = 0;12 const distribution: number[] = [];13 const uniques = new Set<string>();14 const duplicates = new Set<string>();15 for (const account of accounts) {16 if (account.origins) {17 for (const origin of account.origins) {18 totalOrigins++;19 if (uniques.has(origin.ip)) {20 duplicates.add(origin.ip);21 } else {22 uniques.add(origin.ip);23 }24 if (origin.ip.indexOf(':') !== -1) {25 totalOriginsIP6++;26 } else {27 totalOriginsIP4++;28 }29 }30 }31 const count = account.origins ? account.origins.length : 0;32 while (distribution.length <= count) {33 distribution.push(0);34 }35 distribution[count]++;36 }37 const uniqueOrigins = uniques.size;38 const duplicateOrigins = duplicates.size;39 const singleOrigins = uniqueOrigins - duplicateOrigins;40 return {41 uniqueOrigins, duplicateOrigins, singleOrigins, totalOrigins, totalOriginsIP4, totalOriginsIP6, distribution42 };43}44export function removeAllOrigins(service: AdminService, accountId: string) {45 service.removeOriginsFromAccount(accountId);46 return updateAccount(accountId, { origins: [] });47}48export function removeOrigins(service: AdminService, accountId: string, ips: string[]) {49 service.removeOriginsFromAccount(accountId, ips);50 return updateAccount(accountId, { $pull: { origins: { ip: { $in: ips } } } });51}52export function addOrigin(accountId: string, { ip, country }: OriginInfo) {53 return updateAccount(accountId, { $push: { origins: { ip, country, last: new Date() } } });54}55export async function clearOriginsForAccount(service: AdminService, accountId: string, options: ClearOrignsOptions) {56 const account = service.accounts.get(accountId);57 if (account) {58 const { ips } = getOriginsToRemove(account, options);59 await removeOrigins(service, accountId, ips);60 }61}62export async function clearOriginsForAccounts(service: AdminService, accounts: string[], options: ClearOrignsOptions) {63 await Bluebird.map(accounts, id => clearOriginsForAccount(service, id, options), { concurrency: 4 });64}65export async function clearOrigins(66 service: AdminService, count: number, andHigher: boolean, options: ClearOrignsOptions67) {68 const origins = service.accounts.items69 .filter(a => a.originsRefs && (andHigher ? a.originsRefs.length >= count : a.originsRefs.length === count))70 .map(a => getOriginsToRemove(a, options))71 .filter(({ ips }) => !!ips.length);72 await Bluebird.map(origins, o => removeOrigins(service, o.accountId, o.ips), { concurrency: 4 });73}74const isBanned = (origin: Origin) => origin.ban || origin.mute || origin.shadow;75function getOriginsToRemove(account: Account, { old, singles, trim, veryOld, country }: ClearOrignsOptions): AccountOrigins {76 const date = fromNow((veryOld ? -90 : -14) * DAY).getTime();77 const originsRefs = account.originsRefs || [];78 const filtered = country ?79 originsRefs.filter(({ origin }) => origin.country === country) :80 originsRefs.filter(({ last, origin }) => {81 return (!old || (!last || last.getTime() < date))82 && (!singles || origin.accounts!.length === 1)83 && !isBanned(origin);84 });85 const ips = filtered.map(({ origin }) => origin.ip);86 if (trim) {87 ips.push(...difference(originsRefs.map(({ origin }) => origin.ip), ips).slice(10));88 }89 return { accountId: account._id, ips };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var WebPageTest = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.8c6d7d0e5f5d7e8c8c9e9d2f1a2d2b2e');3 if(err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9var WebPageTest = require('webpagetest');10var wpt = new WebPageTest('www.webpagetest.org', 'A.8c6d7d0e5f5d7e8c8c9e9d2f1a2d2b2e');11wpt.getLocations(function(err, data) {12 if(err) {13 console.log(err);14 } else {15 console.log(data);16 }17});18var WebPageTest = require('webpagetest');19var wpt = new WebPageTest('www.webpagetest.org', 'A.8c6d7d0e5f5d7e8c8c9e9d2f1a2d2b2e');20wpt.getConnectivity(function(err, data) {21 if(err) {22 console.log(err);23 } else {24 console.log(data);25 }26});27var WebPageTest = require('webpagetest');28var wpt = new WebPageTest('www.webpagetest.org', 'A.8c6d7d0e5f5d7e8c8c9e9d2f1a2d2b2e');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org', 'A.3b9c9f2e2c5d5f77e8c5d5e5b5e5b5e5');3var url = 'www.google.com';4wpt.runTest(url, function(err, data) {5 if(err) {6 console.log(err);7 } else {8 console.log(data);9 }10});

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

27 Best Website Testing Tools In 2022

Testing is a critical step in any web application development process. However, it can be an overwhelming task if you don’t have the right tools and expertise. A large percentage of websites still launch with errors that frustrate users and negatively affect the overall success of the site. When a website faces failure after launch, it costs time and money to fix.

Your Favorite Dev Browser Has Evolved! The All New LT Browser 2.0

We launched LT Browser in 2020, and we were overwhelmed by the response as it was awarded as the #5 product of the day on the ProductHunt platform. Today, after 74,585 downloads and 7,000 total test runs with an average of 100 test runs each day, the LT Browser has continued to help developers build responsive web designs in a jiffy.

Difference Between Web And Mobile Application Testing

Smartphones have changed the way humans interact with technology. Be it travel, fitness, lifestyle, video games, or even services, it’s all just a few touches away (quite literally so). We only need to look at the growing throngs of smartphone or tablet users vs. desktop users to grasp this reality.

Putting Together a Testing Team

As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful