// CreateSubscription prevents the creation of the subscription if it not exists
335763
func CreateSubscription(b bool) broker.Option {
	return func(o *broker.Options) {
		if o.Context == nil {
			o.Context = context.Background()
		}

		o.Context = context.WithValue(o.Context, createSubscription{}, b)
	}
}
226046
func (ss *RaftSubStore) CreateSub(sub *spb.SubState) error {
	gss := &ss.genericSubStore

	gss.Lock()
	defer gss.Unlock()

	// This store does not persist subscriptions, since it is done
	// in the actual RAFT log. This is just a wrapper to the streaming
	// sub store. We still need to apply limits.

	// If sub.ID is provided, check if already present, in which case
	// don't check limit.
	if sub.ID > 0 {
		if _, ok := gss.subs[sub.ID]; ok {
			return nil
		}
	}
	// Check limits
	if gss.limits.MaxSubscriptions > 0 && len(gss.subs) >= gss.limits.MaxSubscriptions {
		return ErrTooManySubs
	}

	// With new server, the sub.ID is set before this call is invoked,
	// and if that is the case, this is what we use. But let's support
	// not having one (in case we recover an existing store, or run a
	// mix of servers with different versions where the leader would
	// not be at a version that sets the sub.ID).
	if sub.ID == 0 {
		gss.maxSubID++
		sub.ID = gss.maxSubID
	} else if sub.ID > gss.maxSubID {
		gss.maxSubID = sub.ID
	}
	gss.subs[sub.ID] = emptySub

	return nil
}
21943
func NewSubscription(producer func(<-chan struct{}) error) Subscription {
	s := &funcSub{unsub: make(chan struct{}), err: make(chan error, 1)}
	go func() {
		defer close(s.err)
		err := producer(s.unsub)
		s.mu.Lock()
		defer s.mu.Unlock()
		if !s.unsubscribed {
			if err != nil {
				s.err <- err
			}
			s.unsubscribed = true
		}
	}()
	return s
}
310655
func (ss *SQLSubStore) CreateSub(sub *spb.SubState) error {
	ss.Lock()
	defer ss.Unlock()
	// Check limits only if needed
	if ss.limits.MaxSubscriptions > 0 {
		r := ss.sqlStore.preparedStmts[sqlCheckMaxSubs].QueryRow(ss.channelID)
		count := 0
		if err := r.Scan(&count); err != nil {
			return sqlStmtError(sqlCheckMaxSubs, err)
		}
		if count >= ss.limits.MaxSubscriptions {
			return ErrTooManySubs
		}
	}
	sub.ID = atomic.AddUint64(ss.maxSubID, 1)
	subBytes, _ := sub.Marshal()
	if _, err := ss.sqlStore.preparedStmts[sqlCreateSub].Exec(ss.channelID, sub.ID, subBytes); err != nil {
		sub.ID = 0
		return sqlStmtError(sqlCreateSub, err)
	}
	if ss.hasMarkedAsDel {
		if _, err := ss.sqlStore.preparedStmts[sqlDeleteSubMarkedAsDeleted].Exec(ss.channelID); err != nil {
			return sqlStmtError(sqlDeleteSubMarkedAsDeleted, err)
		}
		ss.hasMarkedAsDel = false
	}
	return nil
}
1168004
func (s *SubscribeOutput) SetSubscriptionArn(v string) *SubscribeOutput {
	s.SubscriptionArn = &v
	return s
}
177780
func (s *UnsubscribeInput) SetSubscriptionArn(v string) *UnsubscribeInput {
	s.SubscriptionArn = &v
	return s
}
589171
func (s *CreateNotificationSubscriptionInput) SetSubscriptionType(v string) *CreateNotificationSubscriptionInput {
	s.SubscriptionType = &v
	return s
}
1226063
func (c Client) New(params *stripe.SubscriptionParams) (*stripe.Subscription, error) {
	sub := &stripe.Subscription{}
	err := c.B.Call(http.MethodPost, "/v1/subscriptions", c.Key, params, sub)
	return sub, err
}
859506
func (h *SMTPAPIHeader) AddSubstitution(key, sub string) {
	if h.Sub == nil {
		h.Sub = make(map[string][]string)
	}
	h.Sub[key] = append(h.Sub[key], sub)
}
861596
func (c Client) AddSubscription(s contract.Subscription) (string, error) {
	conn := c.Pool.Get()
	defer conn.Close()

	err := addSubscription(conn, &s)
	if err != nil {
		return "", err
	}

	return s.ID, nil
}
628157
func (s *SubscriptionProvider) Subscribe() *Subscription {
	s.Lock()
	defer s.Unlock()
	if s.subscriptions == nil {
		s.subscriptions = make(map[string]*Subscription)
	}
	sub := newSubscription(s)
	s.subscriptions[sub.id.String()] = sub

	return sub
}
666261
func (s *DescribeHsmOutput) SetSubscriptionStartDate(v string) *DescribeHsmOutput {
	s.SubscriptionStartDate = &v
	return s
}
305816
func (r *marathonClient) registerSubscription() error {
	switch r.config.EventsTransport {
	case EventsTransportCallback:
		return r.registerCallbackSubscription()
	case EventsTransportSSE:
		return r.registerSSESubscription()
	default:
		return fmt.Errorf("the events transport: %d is not supported", r.config.EventsTransport)
	}
}
87853
func (mc MongoClient) GetSubscriptions() ([]contract.Subscription, error) {
	return mc.getSubscriptions(bson.M{})
}
1071521
func (u *UsersClient) Create(ctx context.Context, userObj *envelope.User,
	signup apitypes.Signup) (envelope.UserInf, error) {

	v := &url.Values{}
	if signup.InviteCode != "" {
		v.Set("code", signup.InviteCode)
	}
	if signup.OrgInvite && signup.OrgName != "" {
		v.Set("org", signup.OrgName)
	}
	if signup.Email != "" {
		v.Set("email", signup.Email)
	}

	e := envelope.Unsigned{}
	err := u.client.RoundTrip(ctx, "POST", "/users", v, &userObj, &e)
	if err != nil {
		return nil, err
	}

	return envelope.ConvertUser(&e)
}
841268
func (s *DescribeSubscriptionOutput) SetSubscription(v *Subscription) *DescribeSubscriptionOutput {
	s.Subscription = v
	return s
}
660775
func CreateService(createRequest ServiceCreateRequest) (Service, error) {

	url := "service/"
	request := "POST"
	var response Service

	newService, err := json.Marshal(createRequest)
	if err != nil {
		return response, err
	}

	data, err := TutumCall(url, request, newService)
	if err != nil {
		return response, err
	}

	err = json.Unmarshal(data, &response)
	if err != nil {
		return response, err
	}

	return response, nil
}