azure

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StorageAccountEventSource = "microsoft.storage/storageaccounts"
	FunctionEventSource       = "microsoft.web/sites"
	TagsEventSource           = "microsoft.resources/tags"
)

Variables

View Source
var (
	ErrAzureClientSecretCredential = errors.New("failed to create an Azure client secret credential")
	ErrAzureDefaultCredential      = errors.New("failed to create a default Azure credential")

	ErrMissingSubscriptionID               = errors.New("subscriptionId is required")
	ErrIncompleteAuthConfigForTenantID     = errors.New("both clientId and clientSecret are required when tenantId is provided")
	ErrIncompleteAuthConfigForClientID     = errors.New("both tenantId and clientSecret are required when clientId is provided")
	ErrIncompleteAuthConfigForClientSecret = errors.New("both tenantId and clientId are required when clientSecret is provided")

	ErrEventHubNamespaceRequired              = errors.New("eventHubNamespace is required")
	ErrEventHubNameRequired                   = errors.New("eventHubName is required")
	ErrCheckpointStorageAccountNameRequired   = errors.New("checkpointStorageAccountName is required")
	ErrCheckpointStorageContainerNameRequired = errors.New("checkpointStorageContainerName is required")
)
View Source
var (
	ErrClientInitialization = errors.New("failed to initialize Azure client")
)

Functions

func EventFromRecord

func EventFromRecord(record *ActivityLogEventRecord) *entities.Event

func EventIsForSource

func EventIsForSource(event *ActivityLogEventRecord, resourceType string) bool

func RelationshipFromID

func RelationshipFromID(id string) []string

Types

type ActivityLogAuthorization

type ActivityLogAuthorization struct {
	Scope    string                `json:"scope,omitempty"`
	Action   string                `json:"action,omitempty"`
	Evidence AuthorizationEvidence `json:"evidence,omitempty"`
}

type ActivityLogEventData

type ActivityLogEventData struct {
	Records []*ActivityLogEventRecord `json:"records,omitempty"`
}

type ActivityLogEventIdentity

type ActivityLogEventIdentity struct {
	Authorization *ActivityLogAuthorization `json:"authorization,omitempty"`
	Claims        map[string]string         `json:"claims,omitempty"`
}

type ActivityLogEventRecord

type ActivityLogEventRecord struct {
	RoleLocation    string                    `json:"RoleLocation,omitempty"`   //nolint:tagliatelle
	Stamp           string                    `json:"Stamp,omitempty"`          //nolint:tagliatelle
	ReleaseVersion  string                    `json:"ReleaseVersion,omitempty"` //nolint:tagliatelle
	Time            string                    `json:"time,omitempty"`
	ResourceID      string                    `json:"resourceId,omitempty"`
	OperationName   string                    `json:"operationName,omitempty"`
	Category        string                    `json:"category,omitempty"`
	ResultType      string                    `json:"resultType,omitempty"`
	ResultSignature string                    `json:"resultSignature,omitempty"`
	DurationMs      string                    `json:"durationMs,omitempty"`
	CallerIPAddress string                    `json:"callerIpAddress,omitempty"`
	CorrelationID   string                    `json:"correlationId,omitempty"`
	Identity        *ActivityLogEventIdentity `json:"identity,omitempty"`
	Level           string                    `json:"level,omitempty"`
	Properties      map[string]any            `json:"properties,omitempty"`
}

type AuthConfig

type AuthConfig struct {
	SubscriptionID string              `json:"subscriptionId,omitempty"`
	TenantID       string              `json:"tenantId,omitempty"`
	ClientID       config.SecretSource `json:"clientId,omitempty"`
	ClientSecret   config.SecretSource `json:"clientSecret,omitempty"`
}

func (*AuthConfig) AzureTokenProvider

func (c *AuthConfig) AzureTokenProvider() (azcore.TokenCredential, error)

func (*AuthConfig) Validate

func (c *AuthConfig) Validate() error

type AuthorizationEvidence

type AuthorizationEvidence struct {
	Role                string `json:"role,omitempty"`
	RoleAssignmentScope string `json:"roleAssignmentScope,omitempty"`
	RoleAssignmentID    string `json:"roleAssignmentId,omitempty"`
	RoleDefinitionID    string `json:"roleDefinitionId,omitempty"`
	PrincipalID         string `json:"principalId,omitempty"`
	PrincipalType       string `json:"principalType,omitempty"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) GetByID

func (c *Client) GetByID(ctx context.Context, resourceID, apiVersion string) (*Resource, error)

type ClientInterface

type ClientInterface interface {
	GetByID(ctx context.Context, resourceID, apiVersion string) (*Resource, error)
}

func NewClient

func NewClient(config AuthConfig) (ClientInterface, error)

type EventConsumer

type EventConsumer func(event *azeventhubs.ReceivedEventData) error

type EventHubConfig

type EventHubConfig struct {
	AuthConfig

	EventHubNamespace              string        `json:"eventHubNamespace,omitempty"`
	EventHubName                   string        `json:"eventHubName,omitempty"`
	CheckpointStorageAccountName   string        `json:"checkpointStorageAccountName,omitempty"`
	CheckpointStorageContainerName string        `json:"checkpointStorageContainerName,omitempty"`
	EventConsumer                  EventConsumer `json:"-"`
}

func (*EventHubConfig) Validate

func (c *EventHubConfig) Validate() error

type EventType

type EventType int
const (
	EventTypeRecordFromEventHub EventType = iota
	EventTypeFromLiveLoad
)

func (EventType) String

func (i EventType) String() string

type GraphClient

type GraphClient struct {
	// contains filtered or unexported fields
}

func (*GraphClient) Resources

func (c *GraphClient) Resources(ctx context.Context, typesToFilter []string) ([]*entities.Event, error)

type GraphClientInterface

type GraphClientInterface interface {
	Resources(ctx context.Context, typesToFilter []string) ([]*entities.Event, error)
}

func NewGraphClient

func NewGraphClient(config AuthConfig) (GraphClientInterface, error)

type GraphLiveData

type GraphLiveData struct {
	ID       string            `json:"id"`
	Name     string            `json:"name"`
	Type     string            `json:"type"`
	Location string            `json:"location"`
	Tags     map[string]string `json:"tags"`
}

type Resource

type Resource struct {
	Name     string
	Tags     commons.Tags
	Type     string
	Location string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL