// NewWebhookSideEffectsWithLogger creates a new WebhookSideEffect
482693
func NewWebhookSideEffectsWithLogger(w Webhook, l *log.Logger) (*WebhookSideEffect, error) {
	if w.Method == "" {
		return nil, fmt.Errorf("Supply method")
	}
	_, err := url.Parse(w.URL)
	if err != nil {
		return nil, err
	}

	return &WebhookSideEffect{w: w, log: l}, nil
}
951640
func CreateWebhook(c *messagebird.Client, req *WebhookCreateRequest) (*Webhook, error) {
	webhook := &Webhook{}
	if err := request(c, webhook, http.MethodPost, webhooksPath, req); err != nil {
		return nil, err
	}

	return webhook, nil
}
1023482
func (t *Token) GetWebhooks(args Arguments) (webhooks []*Webhook, err error) {
	path := fmt.Sprintf("tokens/%s/webhooks", t.ID)
	err = t.client.Get(path, args, &webhooks)
	return
}
303812
func (s *WebhooksService) CreateWebhook(accountID string, webhookAttributes Webhook) (*webhookResponse, error) {
	path := versioned(webhookPath(accountID, 0))
	webhookResponse := &webhookResponse{}

	resp, err := s.client.post(path, webhookAttributes, webhookResponse)
	if err != nil {
		return nil, err
	}

	webhookResponse.HttpResponse = resp
	return webhookResponse, nil
}
677436
func (c oauthClient) Webhook(webhookID uint) (wl.Webhook, error) {
	allWebhooks, err := c.Webhooks()
	for _, w := range allWebhooks {
		if w.ID == webhookID {
			return w, err
		}
	}

	return wl.Webhook{}, fmt.Errorf("webhook not found")
}
209922
func (c *Client) CreateWebhook(webhook *Webhook) error {
	path := "webhooks"
	args := Arguments{"idModel": webhook.IDModel, "description": webhook.Description, "callbackURL": webhook.CallbackURL}
	err := c.Post(path, args, webhook)
	if err == nil {
		webhook.client = c
	}
	return err
}
1241261
func GetWebhooksByOrgID(orgID int64) (ws []*Webhook, err error) {
	err = x.Find(&ws, &Webhook{OrgID: orgID})
	return ws, err
}
197685
func NewSentryHook(DSN string, levels []logrus.Level) (*SentryHook, error) {
	client, err := raven.New(DSN)
	if err != nil {
		return nil, err
	}
	return NewWithClientSentryHook(client, levels)
}
1316440
func NewBrowser() *browser.Browser {
	bow := &browser.Browser{}
	bow.SetUserAgent(DefaultUserAgent)
	bow.SetState(&jar.State{})
	bow.SetCookieJar(jar.NewMemoryCookies())
	bow.SetBookmarksJar(jar.NewMemoryBookmarks())
	hist := jar.NewMemoryHistory()
	hist.SetMax(DefaultMaxHistoryLength)
	bow.SetHistoryJar(hist)
	bow.SetHeadersJar(jar.NewMemoryHeaders())
	bow.SetAttributes(browser.AttributeMap{
		browser.SendReferer:         DefaultSendReferer,
		browser.MetaRefreshHandling: DefaultMetaRefreshHandling,
		browser.FollowRedirects:     DefaultFollowRedirects,
	})

	return bow
}
790899
func ListWebhooks(c *messagebird.Client, options *ListOptions) (*WebhookList, error) {
	query := paginationQuery(options)

	webhookList := &WebhookList{}
	if err := request(c, webhookList, http.MethodGet, webhooksPath+"?"+query, nil); err != nil {
		return nil, err
	}

	return webhookList, nil
}
1129733
func (v *version) MutatingWebhookConfigurations() MutatingWebhookConfigurationInformer {
	return &mutatingWebhookConfigurationInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
}
1290214
func NewMutatingWebhook(configFile io.Reader) (*Plugin, error) {
	handler := admission.NewHandler(admission.Connect, admission.Create, admission.Delete, admission.Update)
	p := &Plugin{}
	var err error
	p.Webhook, err = generic.NewWebhook(handler, configFile, configuration.NewMutatingWebhookConfigurationManager, newMutatingDispatcher(p))
	if err != nil {
		return nil, err
	}

	return p, nil
}
548973
func (s *Service) AppWebhookUpdate(ctx context.Context, appIdentity string, appWebhookIdentity string, o AppWebhookUpdateOpts) (*AppWebhookUpdateResult, error) {
	var appWebhook AppWebhookUpdateResult
	return &appWebhook, s.Patch(ctx, &appWebhook, fmt.Sprintf("/apps/%v/webhooks/%v", appIdentity, appWebhookIdentity), o)
}
1108920
func NewValidatingAdmissionWebhook(configFile io.Reader) (*Plugin, error) {
	handler := admission.NewHandler(admission.Connect, admission.Create, admission.Delete, admission.Update)
	webhook, err := generic.NewWebhook(handler, configFile, configuration.NewValidatingWebhookConfigurationManager, newValidatingDispatcher)
	if err != nil {
		return nil, err
	}
	return &Plugin{webhook}, nil
}
22614
func NewLogger(stdoutThreshold, logThreshold jww.Threshold, outHandle, logHandle io.Writer, saveErrors bool) *Logger {
	return newLogger(stdoutThreshold, logThreshold, outHandle, logHandle, saveErrors)
}
975011
func (a *Plugin) webhookError(pod *api.Pod, attributes admission.Attributes, err error) error {
	if err != nil {
		klog.V(2).Infof("error contacting webhook backend: %s", err)
		if a.defaultAllow {
			attributes.AddAnnotation(AuditKeyPrefix+ImagePolicyFailedOpenKeySuffix, "true")
			// TODO(wteiken): Remove the annotation code for the 1.13 release
			annotations := pod.GetAnnotations()
			if annotations == nil {
				annotations = make(map[string]string)
			}
			annotations[api.ImagePolicyFailedOpenKey] = "true"
			pod.ObjectMeta.SetAnnotations(annotations)

			klog.V(2).Infof("resource allowed in spite of webhook backend failure")
			return nil
		}
		klog.V(2).Infof("resource not allowed due to webhook backend failure ")
		return admission.NewForbidden(attributes, err)
	}
	return nil
}
1307728
func NewWebhookTarget(id string, args WebhookArgs) *WebhookTarget {
	return &WebhookTarget{
		id:   event.TargetID{ID: id, Name: "webhook"},
		args: args,
		httpClient: &http.Client{
			Transport: &http.Transport{
				TLSClientConfig: &tls.Config{RootCAs: args.RootCAs},
				DialContext: (&net.Dialer{
					Timeout:   5 * time.Second,
					KeepAlive: 5 * time.Second,
				}).DialContext,
				TLSHandshakeTimeout:   3 * time.Second,
				ResponseHeaderTimeout: 3 * time.Second,
				ExpectContinueTimeout: 2 * time.Second,
			},
		},
	}
}