<commit_before>package lifecycle

import (
	"fmt"
	"net/url"

	"github.com/lxc/lxd/shared/api"
)

// CertificateAction represents a lifecycle event action for Certificates.
type CertificateAction string

// All supported lifecycle events for Certificates.
const (
	CertificateCreated = CertificateAction("created")
	CertificateDeleted = CertificateAction("deleted")
	CertificateUpdated = CertificateAction("updated")
)

// Event creates the lifecycle event for an action on a Certificate.
func (a CertificateAction) Event(fingerprint string, requestor *api.EventLifecycleRequestor, ctx map[string]interface{}) api.EventLifecycle {
	eventType := fmt.Sprintf("certificate-%s", a)

	u := fmt.Sprintf("/1.0/certificates")
	if a != CertificateCreated {
		u = fmt.Sprintf("%s/%s", u, url.PathEscape(fingerprint))
	}

	return api.EventLifecycle{
		Action:    eventType,
		Source:    u,
		Context:   ctx,
		Requestor: requestor,
	}
}<commit_msg>lxd/lifecycle/certificate: include object in source for created lifecycle events<commit_after>package lifecycle

import (
	"fmt"
	"net/url"

	"github.com/lxc/lxd/shared/api"
)

// CertificateAction represents a lifecycle event action for Certificates.
type CertificateAction string

// All supported lifecycle events for Certificates.
const (
	CertificateCreated = CertificateAction("created")
	CertificateDeleted = CertificateAction("deleted")
	CertificateUpdated = CertificateAction("updated")
)

// Event creates the lifecycle event for an action on a Certificate.
func (a CertificateAction) Event(fingerprint string, requestor *api.EventLifecycleRequestor, ctx map[string]interface{}) api.EventLifecycle {
	eventType := fmt.Sprintf("certificate-%s", a)

	u := fmt.Sprintf("/1.0/certificates/%s", url.PathEscape(fingerprint))

	return api.EventLifecycle{
		Action:    eventType,
		Source:    u,
		Context:   ctx,
		Requestor: requestor,
	}
}
{'fraction_non_alphanumeric': 0.1089845826687932, 'fraction_numerical': 0.002126528442317916, 'mean_word_length': 5.150326797385621, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3599804', 'n_tokens_mistral': 579, 'n_tokens_neox': 547, 'n_words': 148}