github.com/argoproj/argo-events@v1.9.1/eventsources/sources/bitbucket/types.go (about)

     1  /*
     2  
     3  Licensed under the Apache License, Version 2.0 (the "License");
     4  you may not use this file except in compliance with the License.
     5  You may obtain a copy of the License at
     6  
     7  	http://www.apache.org/licenses/LICENSE-2.0
     8  
     9  Unless required by applicable law or agreed to in writing, software
    10  distributed under the License is distributed on an "AS IS" BASIS,
    11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  See the License for the specific language governing permissions and
    13  limitations under the License.
    14  */
    15  
    16  package bitbucket
    17  
    18  import (
    19  	bitbucketv2 "github.com/ktrysmt/go-bitbucket"
    20  
    21  	"github.com/argoproj/argo-events/eventsources/common/webhook"
    22  	"github.com/argoproj/argo-events/metrics"
    23  	apicommon "github.com/argoproj/argo-events/pkg/apis/common"
    24  	"github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1"
    25  )
    26  
    27  // EventListener implements ConfigExecutor
    28  type EventListener struct {
    29  	EventSourceName      string
    30  	EventName            string
    31  	BitbucketEventSource v1alpha1.BitbucketEventSource
    32  	Metrics              *metrics.Metrics
    33  }
    34  
    35  // GetEventSourceName returns name of event source
    36  func (el *EventListener) GetEventSourceName() string {
    37  	return el.EventSourceName
    38  }
    39  
    40  // GetEventName returns name of event
    41  func (el *EventListener) GetEventName() string {
    42  	return el.EventName
    43  }
    44  
    45  // GetEventSourceType return type of event server
    46  func (el *EventListener) GetEventSourceType() apicommon.EventSourceType {
    47  	return apicommon.BitbucketEvent
    48  }
    49  
    50  // Router contains the configuration information for a route
    51  type Router struct {
    52  	// route contains information about a API endpoint
    53  	route *webhook.Route
    54  	// client to connect to Bitbucket
    55  	client *bitbucketv2.Client
    56  	// bitbucketEventSource is the event source that holds information to consume events from Bitbucket
    57  	bitbucketEventSource *v1alpha1.BitbucketEventSource
    58  	// hookIDs is a map of webhook IDs
    59  	// (owner+","+repoSlug) -> hook ID
    60  	// Bitbucket API docs:
    61  	// https://developer.atlassian.com/cloud/bitbucket/rest/
    62  	hookIDs map[string]string
    63  }
    64  
    65  type WebhookSubscription struct {
    66  	// Uuid holds the webhook's ID
    67  	Uuid string `json:"uuid"`
    68  	// The Url events get delivered to.
    69  	Url string `json:"url"`
    70  	// Description holds a user-defined description of the webhook.
    71  	Description string `json:"description,omitempty"`
    72  	// Subject holds metadata about the subject of the webhook (repository, etc.)
    73  	Subject map[string]interface{} `json:"subject,omitempty"`
    74  	// Active refers to status of the webhook for event deliveries.
    75  	Active bool `json:"active,omitempty"`
    76  	// The Events this webhook is subscribed to.
    77  	Events []string `json:"events"`
    78  }
    79  
    80  // AuthStrategy is implemented by the different Bitbucket auth strategies that are supported
    81  type AuthStrategy interface {
    82  	// BitbucketClient returns a bitbucket client initialized with the specific auth strategy
    83  	BitbucketClient() *bitbucketv2.Client
    84  }