bamboohr

package
v0.1.0 Latest Latest
Warning

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

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

README

Overview

This is a reference Pomerium data provider that returns employee data from BambooHR. It has to be configured to connect to your BambooHR account, and would provide Pomerium with subset of information that may be used to configure access policies.

Use Cases

Limit Access By Employee Properties

There may be business rules that require that employees access to certain resources may be limited:

  • status to deactivate access if an employee is terminated
  • department, division, jobTitle
  • country, state, city, location, nationality

Configuration

For security reasons, all requests to BambooHR are runtime parameters and may not be customized.

Restricted fields

Fields national_id, sin, ssn, nin are restricted and may not be exported for security reasons.

API

A Token HTTP header must be provided in each request, matching api-token runtime parameter.

GET /employees

Returns list of current employees, with fields provided, as JSON array.

GET /employees/out

Returns list of employees that are currently out.

Documentation

Index

Constants

View Source
const BambooDateLayout = "2006-01-02"

Variables

This section is empty.

Functions

func NewServer

func NewServer(emplReq EmployeeRequest, client *http.Client, log zerolog.Logger) *mux.Router

NewServer implements new BambooHR limited data exporter

func WhoIsOut

func WhoIsOut(ctx context.Context, client *http.Client, param WhoIsOutRequest) (map[string][]Period, error)

WhoIsOut retrieves list of employees who are currently marked as out

Types

type Auth

type Auth struct {
	// APIKey see https://documentation.bamboohr.com/docs#section-authentication
	APIKey string `validate:"required"`
	// Subdomain is BambooHR customer identifier
	// If you access BambooHR at https://mycompany.bamboohr.com, then the subdomain is "mycompany"
	Subdomain string `validate:"required"`
	// Base is API URL, nil for default
	BaseURL *url.URL
}

Auth is API server auth parameters

func (Auth) RequestURL

func (a Auth) RequestURL(rel string) *url.URL

type Employee

type Employee struct {
	ID         json.Number `json:"bamboo_id" mapstructure:"id"`
	Email      string      `json:"id" mapstructure:"workEmail"`
	Department string      `json:"department" mapstructure:"department"`
	Divison    string      `json:"division" mapstructure:"division"`
	Status     string      `json:"status" mapstructure:"status"`
	FirstName  string      `json:"first_name" mapstructure:"firstName"`
	LastName   string      `json:"last_name" mapstructure:"lastName"`
	Country    string      `json:"country" mapstructure:"country"`
	State      string      `json:"state" mapstructure:"state"`
}

Employee represents BambooHR employee record

func GetAllEmployees

func GetAllEmployees(ctx context.Context, client *http.Client, param EmployeeRequest) ([]Employee, error)

GetAllEmployees returns full list of employees in active status

func GetAvailableEmployees

func GetAvailableEmployees(ctx context.Context, client *http.Client, param EmployeeRequest) ([]Employee, error)

GetAvailableEmployees only returns employees that are marked as active and are not on vacation or absense leave

type EmployeeRequest

type EmployeeRequest struct {
	Auth
	Location *time.Location
}

EmployeeRequest requests employees

func (EmployeeRequest) RequestURL

func (req EmployeeRequest) RequestURL() *url.URL

type Period

type Period struct {
	Start time.Time
	End   time.Time
}

type WhoIsOutRequest

type WhoIsOutRequest struct {
	Auth
	// Location is required as BambooHR only returns date, and it must be converted into timestamp
	// Timezone is an installation specific setting that does not seem to be available via API
	// but may only be accessed from the BambooHR Admin UI
	Location   *time.Location
	Start, End time.Time
}

func (WhoIsOutRequest) RequestURL

func (req WhoIsOutRequest) RequestURL() *url.URL

Jump to

Keyboard shortcuts

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