datasheet

package
v0.0.0-...-baadd90 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package datasheet provides the operations about datasheet

Index

Constants

View Source
const (
	ViewType_Grid    = "Grid"
	ViewType_Gallery = "Gallery"
	ViewType_Kanban  = "Kanban"
	ViewType_Gantt   = "Gantt"
)

All of view types

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	// attachment unique identification
	Token *string `json:"token,omitempty" name:"token"`
	// attachment original name
	Name *string `json:"name,omitempty" name:"name"`
	// attachment size
	Size *int64 `json:"size,omitempty" name:"size"`
	// when the attachment is a picture, the width of the picture.
	Width *int64 `json:"width,omitempty" name:"width"`
	// when the attachment is a picture, the height of the picture.
	Height *int64 `json:"height,omitempty" name:"height"`
	// attachment type, such as:image/jpeg
	MimeType *string `json:"mimeType,omitempty" name:"mimeType"`
	// pdf preview image, only pdf format will be returned
	Preview *string `json:"preview,omitempty" name:"preview"`
	// attachment access path
	Url *string `json:"url,omitempty" name:"url"`
}

type AttachmentValue

type AttachmentValue struct {
	Token string `json:"token,omitempty" name:"token"`
	Name  string `json:"name,omitempty" name:"name"`
}

type BaseRecord

type BaseRecord struct {
	// such: `rec*****`
	RecordId *string `json:"recordId,omitempty" name:"recordId"`
	// key/value corresponding to column
	Fields *Field `json:"fields,omitempty" name:"fields" map`
}

type CheckboxFieldProperty

type CheckboxFieldProperty struct {
	Icon *string `json:"icon,omitempty" name:"icon"`
}

CheckboxFieldProperty describe checkbox field property

type CreateRecordsRequest

type CreateRecordsRequest struct {
	*athttp.BaseRequest
	// key/value corresponding to column
	Records []*Fields `json:"records,omitempty" name:"records" map`
}

func NewCreateRecordsRequest

func NewCreateRecordsRequest() (request *CreateRecordsRequest)

type CurrencyFieldFormat

type CurrencyFieldFormat struct {
	Precision *int `json:"precision,omitempty" name:"precision"`
	Symbol    *int `json:"symbol,omitempty" name:"symbol"`
}

CurrencyFieldFormat the format for make the value just like the currency filed shows

type CurrencyFieldProperty

type CurrencyFieldProperty struct {
	DefaultValue *string `json:"defaultValue,omitempty" name:"defaultValue"`
	Precision    *int    `json:"precision,omitempty" name:"precision"`
	Symbol       *string `json:"symbol,omitempty" name:"symbol"`
}

CurrencyFieldProperty describe currency field property

type Datasheet

type Datasheet struct {
	common.Client
	DatasheetId string
}

func NewDatasheet

func NewDatasheet(credential *common.Credential, datasheetId string, clientProfile *profile.ClientProfile) (datasheet *Datasheet, err error)

NewDatasheet init datasheet instance

func (*Datasheet) CreateRecords

func (c *Datasheet) CreateRecords(request *CreateRecordsRequest) (records []*Record, err error)

CreateRecords used to create multiple records

func (*Datasheet) DeleteRecords

func (c *Datasheet) DeleteRecords(request *DeleteRecordsRequest) (err error)

DeleteRecords used to delete multiple records

func (*Datasheet) DescribeAllRecords

func (c *Datasheet) DescribeAllRecords(request *DescribeRecordRequest) (records []*Record, err error)

DescribeAllRecords use to query the details of all records.

* according to `ViewId`, column name, `FieldId` or other information to query the record detailed information. * For details of filtering information please see `RecordRequest`。 * If the parameter is empty, all records in the current datasheet are returned.

func (*Datasheet) DescribeFields

func (c *Datasheet) DescribeFields(request *DescribeFieldsRequest) (fields []*DatasheetField, err error)

func (*Datasheet) DescribeRecord

func (c *Datasheet) DescribeRecord(request *DescribeRecordRequest) (record *Record, err error)

DescribeRecord used to obtain a single record * according to `ViewId`, column name, `FieldId` or other information to query the record detailed information. * For details of filtering information please see `RecordRequest`。 * returns the first record queried

func (*Datasheet) DescribeRecords

func (c *Datasheet) DescribeRecords(request *DescribeRecordRequest) (pagination *RecordPagination, err error)

DescribeRecords use to query paging records' details.

* according to `ViewId`, column name, `FieldId` or other information to query the record detailed information. * For details of filtering information please see `RecordRequest`。 * If the parameter is empty, return paging according to the default. The default is 100 records per page.

func (*Datasheet) DescribeViews

func (c *Datasheet) DescribeViews(request *DescribeViewsRequest) (views []*DatasheetView, err error)

func (*Datasheet) ModifyRecords

func (c *Datasheet) ModifyRecords(request *ModifyRecordsRequest) (records []*Record, err error)

ModifyRecords used to modify multiple records

func (*Datasheet) UploadFile

func (c *Datasheet) UploadFile(request *UploadRequest) (attachment *Attachment, err error)

UploadFile used to upload attachments

type DatasheetField

type DatasheetField struct {
	// field id
	Id *string `json:"id,omitempty" name:"id"`
	// field name
	Name *string `json:"name,omitempty" name:"name"`
	// field type
	Type *FieldType `json:"type,omitempty" name:"type"`
	// field permissions, that is, column permissions. true is editable and false is read-only.
	Editable *bool `json:"editable,omitempty" name:"editable"`
	// field properties. different fields have different attributes.
	Property *json.RawMessage `json:"property,omitempty" name:"property"`
}

DatasheetField describe the fields of table

func (*DatasheetField) CheckboxFieldProperty

func (field *DatasheetField) CheckboxFieldProperty() *CheckboxFieldProperty

func (*DatasheetField) CurrencyFieldProperty

func (field *DatasheetField) CurrencyFieldProperty() *CurrencyFieldProperty

func (*DatasheetField) DateTimeFieldProperty

func (field *DatasheetField) DateTimeFieldProperty() *DateTimeFieldProperty

func (*DatasheetField) FormulaFieldProperty

func (field *DatasheetField) FormulaFieldProperty() *FormulaFieldProperty

func (*DatasheetField) MagicLinkFieldProperty

func (field *DatasheetField) MagicLinkFieldProperty() *MagicLinkFieldProperty

func (*DatasheetField) MagicLookUpFieldProperty

func (field *DatasheetField) MagicLookUpFieldProperty() *MagicLookUpFieldProperty

func (*DatasheetField) MemberFieldProperty

func (field *DatasheetField) MemberFieldProperty() *MemberFieldProperty

func (*DatasheetField) NumberFieldProperty

func (field *DatasheetField) NumberFieldProperty() *NumberFieldProperty

func (*DatasheetField) PercentFieldProperty

func (field *DatasheetField) PercentFieldProperty() *PercentFieldProperty

func (*DatasheetField) RatingFieldProperty

func (field *DatasheetField) RatingFieldProperty() *RatingFieldProperty

func (*DatasheetField) SelectFieldProperty

func (field *DatasheetField) SelectFieldProperty() *SelectFieldProperty

func (*DatasheetField) SingleTextFieldProperty

func (field *DatasheetField) SingleTextFieldProperty() *SingleTextFieldProperty

func (*DatasheetField) UserFieldProperty

func (field *DatasheetField) UserFieldProperty() *UserFieldProperty

type DatasheetView

type DatasheetView struct {
	// Id view id
	Id *string `json:"id,omitempty" name:"id"`
	// Name view name
	Name *string `json:"name,omitempty" name:"name"`
	// Type view type
	Type *ViewType `json:"type,omitempty" name:"type"`
}

DatasheetView describe the views of table

type DateTimeFieldFormat

type DateTimeFieldFormat struct {
	DateFormat  *string `json:"dateFormat,omitempty" name:"dateFormat"`
	TimeFormat  *string `json:"timeFormat,omitempty" name:"timeFormat"`
	IncludeTime *bool   `json:"includeTime,omitempty" name:"includeTime"`
}

DateTimeFieldFormat the format for make the value just like the datetime filed shows

type DateTimeFieldProperty

type DateTimeFieldProperty struct {
	Format      *string `json:"format,omitempty" name:"format"`
	IncludeTime *bool   `json:"includeTime,omitempty" name:"includeTime"`
	AutoFill    *bool   `json:"autoFill,omitempty" name:"autoFill"`
}

DateTimeFieldProperty describe date time field property

type DeleteRecordsRequest

type DeleteRecordsRequest struct {
	*athttp.BaseRequest
	// key/value corresponding to column
	RecordIds []*string `json:"recordIds,omitempty" name:"recordIds" list`
}

func NewDeleteRecordsRequest

func NewDeleteRecordsRequest() (request *DeleteRecordsRequest)

type DescribeFieldsRequest

type DescribeFieldsRequest struct {
	*athttp.BaseRequest
	// filter by view. value such as: viw*****. required: no.
	ViewId *string `json:"viewId,omitempty" name:"viewId"`
}

func NewDescribeFieldsRequest

func NewDescribeFieldsRequest() (request *DescribeFieldsRequest)

type DescribeFieldsResponse

type DescribeFieldsResponse struct {
	*athttp.BaseResponse
	// api response data
	Data *FieldsResponse `json:"data"`
}

type DescribeRecordRequest

type DescribeRecordRequest struct {
	*athttp.BaseRequest

	// query by one or more record id. record id such as:`rec*****`.
	//(For the specific format of this parameter, please refer to the api [developer documentation](https://help.apitable.com/api-get-records/))。
	// The maximum number of instances per request is 100.
	// The parameter does not support specifying both 'Record Ids' and 'Filters'.
	RecordIds []*string `json:"recordIds,omitempty" name:"recordIds" list`

	// filter by view. value such as: viw*****. required: no.
	ViewId *string `json:"viewId,omitempty" name:"viewId"`

	// filter by field. value such as: fld*****. required: no.
	Fields []*string `json:"fields,omitempty" name:"fields"`

	// filter by formula. value such as: max({field}). required: no.
	// [one minute hands on formula](https://help.apitable.com/tutorial-getting-started-with-formulas/).
	FilterByFormula *string `json:"filterByFormula,omitempty" name:"filterByFormula"`

	// filter by [cell value type], the default is json. When specified as string, all values will be automatically converted to string format. such as: json. required: no.
	CellFormat *string `json:"cellFormat,omitempty" name:"cellFormat"`

	// filter by column identification. By default, the column name is used.value such as: name. required: no.
	FieldKey *string `json:"fieldKey,omitempty" name:"fieldKey"`

	// The parameter does not support specifying both 'Record Ids' and 'Filters'.
	// filter by sort. such as:{field: ‘field_name’, order: ‘asc/desc’}. required: no.
	Sort []*Sort `json:"sort,omitempty" name:"sort" list`

	// Specifies the page number of the page. The default is 1. It is used in conjunction with the parameter page size. [more see](https://help.apitable.com/api-get-records/)
	PageNum *int64 `json:"pageNum,omitempty" name:"pageNum"`

	// The number page returned. The default value is 100. The maximum value is 1000. [more see](https://help.apitable.com/api-get-records/).
	PageSize *int64 `json:"pageSize,omitempty" name:"pageSize"`

	// The number record returned. [more see](https://help.apitable.com/api-get-records/)
	MaxRecords *int64 `json:"maxRecords,omitempty" name:"maxRecords"`
}

func NewDescribeRecordRequest

func NewDescribeRecordRequest() (request *DescribeRecordRequest)

NewDescribeRecordRequest init datasheet record request instance

func (*DescribeRecordRequest) FromJsonString

func (r *DescribeRecordRequest) FromJsonString(s string) error

func (*DescribeRecordRequest) ToJsonString

func (r *DescribeRecordRequest) ToJsonString() string

type DescribeRecordResponse

type DescribeRecordResponse struct {
	*athttp.BaseResponse
	// api response data
	Data *RecordPagination `json:"data"`
}

func NewDescribeRecordResponse

func NewDescribeRecordResponse() (response *DescribeRecordResponse)

type DescribeViewsRequest

type DescribeViewsRequest struct {
	*athttp.BaseRequest
}

func NewDescribeViewsRequest

func NewDescribeViewsRequest() (request *DescribeViewsRequest)

type DescribeViewsResponse

type DescribeViewsResponse struct {
	*athttp.BaseResponse
	// api response data
	Data *ViewsResponse `json:"data"`
}

type Field

type Field map[string]FieldValue

type FieldFormat

FieldFormat the format of the field set for the record value to show

type FieldType

type FieldType string

FieldType the apitable datasheet field type

const (
	FieldType_SingleText       FieldType = "SingleText"
	FieldType_Text             FieldType = "Text"
	FieldType_SingleSelect     FieldType = "SingleSelect"
	FieldType_MultiSelect      FieldType = "MultiSelect"
	FieldType_Number           FieldType = "Number"
	FieldType_Currency         FieldType = "Currency"
	FieldType_Percent          FieldType = "Percent"
	FieldType_DateTime         FieldType = "DateTime"
	FieldType_Attachment       FieldType = "Attachment"
	FieldType_Member           FieldType = "Member"
	FieldType_Checkbox         FieldType = "Checkbox"
	FieldType_Rating           FieldType = "Rating"
	FieldType_URL              FieldType = "URL"
	FieldType_Phone            FieldType = "Phone"
	FieldType_MagicLink        FieldType = "MagicLink"
	FieldType_MagicLookUp      FieldType = "MagicLookUp"
	FieldType_Formula          FieldType = "Formula"
	FieldType_AutoNumber       FieldType = "AutoNumber"
	FieldType_CreatedTime      FieldType = "CreatedTime"
	FieldType_LastModifiedTime FieldType = "LastModifiedTime"
	FieldType_CreatedBy        FieldType = "CreatedBy"
	FieldType_LastModifiedBy   FieldType = "LastModifiedBy"
)

all apitable datasheet field types

type FieldValue

type FieldValue interface{}

type Fields

type Fields struct {
	Fields *Field `json:"fields,omitempty" name:"fields" map`
}

type FieldsResponse

type FieldsResponse struct {
	Fields []*DatasheetField `json:"fields"`
}

type FormulaFieldProperty

type FormulaFieldProperty struct {
	Expression *string      `json:"expression,omitempty" name:"expression"`
	ValueType  *ValueType   `json:"valueType,omitempty" name:"valueType"`
	HasError   *bool        `json:"hasError,omitempty" name:"hasError"`
	Format     *FieldFormat `json:"format,omitempty" name:"format"`
}

FormulaFieldProperty describe formula field property

type IDatasheetField

type IDatasheetField interface {
	SingleTextFieldProperty() *SingleTextFieldProperty
	SelectFieldProperty() *SelectFieldProperty
	PercentFieldProperty() *PercentFieldProperty
	FormulaFieldProperty() *FormulaFieldProperty
	UserFieldProperty() *UserFieldProperty
	MagicLinkFieldProperty() *MagicLinkFieldProperty
	MagicLookUpFieldProperty() *MagicLookUpFieldProperty
	RatingFieldProperty() *RatingFieldProperty
	CheckboxFieldProperty() *CheckboxFieldProperty
	DateTimeFieldProperty() *DateTimeFieldProperty
	MemberFieldProperty() *MemberFieldProperty
	CurrencyFieldProperty() *CurrencyFieldProperty
	NumberFieldProperty() *NumberFieldProperty
}

IDatasheetField define how to obtain the field properties

type LookUpFieldEntity

type LookUpFieldEntity struct {
	DatasheetId *string         `json:"datasheetId,omitempty" name:"datasheetId"`
	Field       *DatasheetField `json:"field,omitempty" name:"field"`
}

type LookUpFieldFormat

type LookUpFieldFormat struct {
	Type   *string         `json:"type,omitempty" name:"type"`
	Format *DatasheetField `json:"field,omitempty" name:"field"`
}

type MagicLinkFieldProperty

type MagicLinkFieldProperty struct {
	ForeignDatasheetId *string `json:"foreignDatasheetId,omitempty" name:"foreignDatasheetId"`
	BrotherFieldId     *string `json:"brotherFieldId,omitempty" name:"brotherFieldId"`
	LimitToViewId      *string `json:"limitToViewId,omitempty" name:"limitToViewId"`
	LimitSingleRecord  *bool   `json:"limitSingleRecord,omitempty" name:"limitSingleRecord"`
}

MagicLinkFieldProperty describe magic link field property

type MagicLookUpFieldProperty

type MagicLookUpFieldProperty struct {
	RelatedLinkFieldId *string            `json:"relatedLinkFieldId,omitempty" name:"relatedLinkFieldId"`
	TargetFieldId      *string            `json:"targetFieldId,omitempty" name:"targetFieldId"`
	RollupFunction     *RollupFunction    `json:"rollupFunction,omitempty" name:"rollupFunction"`
	ValueType          *ValueType         `json:"valueType,omitempty" name:"valueType"`
	EntityField        *LookUpFieldEntity `json:"entityField,omitempty" name:"entityField"`
	Format             *FieldFormat       `json:"format,omitempty" name:"format"`
}

MagicLookUpFieldProperty describe magic lookup field property

type MemberFieldOption

type MemberFieldOption struct {
	Id     *string     `json:"id,omitempty" name:"id"`
	Name   *string     `json:"name,omitempty" name:"name"`
	Type   *MemberType `json:"type,omitempty" name:"type"`
	Avatar *string     `json:"avatar,omitempty" name:"avatar"`
}

MemberFieldOption describe the member field option property

type MemberFieldProperty

type MemberFieldProperty struct {
	Options       []*MemberFieldOption `json:"options,omitempty" name:"options"`
	IsMulti       *bool                `json:"isMulti,omitempty" name:"isMulti"`
	ShouldSendMsg *bool                `json:"shouldSendMsg,omitempty" name:"shouldSendMsg"`
}

MemberFieldProperty describe member field property

type MemberType

type MemberType string

MemberType the apitable datasheet member field type

const (
	MemberType_Member MemberType = "Member"
	MemberType_Team   MemberType = "Team"
)

all datasheet member field types

type ModifyRecordsRequest

type ModifyRecordsRequest struct {
	*athttp.BaseRequest
	// key/value corresponding to column
	Records []*BaseRecord `json:"records,omitempty" name:"records" map`
}

func NewModifyRecordsRequest

func NewModifyRecordsRequest() (request *ModifyRecordsRequest)

type NumberFieldFormat

type NumberFieldFormat struct {
	Precision *int `json:"precision,omitempty" name:"precision"`
}

NumberFieldFormat the format for make the value just like the number filed shows

type NumberFieldProperty

type NumberFieldProperty struct {
	DefaultValue *string `json:"defaultValue,omitempty" name:"defaultValue"`
	Precision    *int    `json:"precision,omitempty" name:"precision"`
}

NumberFieldProperty describe number field property

type NumberFieldValue

type NumberFieldValue int64

type PercentFieldProperty

type PercentFieldProperty struct {
	DefaultValue *string `json:"defaultValue,omitempty" name:"defaultValue"`
	Precision    *int    `json:"precision,omitempty" name:"precision"`
}

PercentFieldProperty describe percent field property

type RatingFieldProperty

type RatingFieldProperty struct {
	Icon *string `json:"icon,omitempty" name:"icon"`
	Max  *int    `json:"max,omitempty" name:"max"`
}

RatingFieldProperty describe rating field property

type Record

type Record struct {
	*BaseRecord
	// record creation time. such as: timestamp
	CreatedAt *int64 `json:"createdAt,omitempty" name:"createdAt"`
}

type RecordPagination

type RecordPagination struct {
	// current number of pages
	PageNum *int64 `json:"pageNum,omitempty" name:"pageNum"`

	PageSize *int64 `json:"pageSize,omitempty" name:"pageSize"`

	Total *int64 `json:"total,omitempty" name:"total"`

	Records []*Record `json:"records"`
}

type RollupFunction

type RollupFunction string

RollupFunction the apitable datasheet supported customize function

const (
	RollupFunction_VALUES       RollupFunction = "VALUES"
	RollupFunction_AVERAGE      RollupFunction = "AVERAGE"
	RollupFunction_COUNT        RollupFunction = "COUNT"
	RollupFunction_COUNTA       RollupFunction = "COUNTA"
	RollupFunction_COUNTALL     RollupFunction = "COUNTALL"
	RollupFunction_SUM          RollupFunction = "SUM"
	RollupFunction_MIN          RollupFunction = "MIN"
	RollupFunction_MAX          RollupFunction = "MAX"
	RollupFunction_AND          RollupFunction = "AND"
	RollupFunction_OR           RollupFunction = "OR"
	RollupFunction_XOR          RollupFunction = "XOR"
	RollupFunction_CONCATENATE  RollupFunction = "CONCATENATE"
	RollupFunction_ARRAYJOIN    RollupFunction = "ARRAYJOIN"
	RollupFunction_ARRAYUNIQUE  RollupFunction = "ARRAYUNIQUE"
	RollupFunction_ARRAYCOMPACT RollupFunction = "ARRAYCOMPACT"
)

datasheet supported all rollup functions

type SelectFieldOption

type SelectFieldOption struct {
	Id    *string                 `json:"id,omitempty" name:"id"`
	Name  *string                 `json:"name,omitempty" name:"name"`
	Color *SelectFieldOptionColor `json:"color,omitempty"`
}

SelectFieldOption describe the single select field and multi select field option property

type SelectFieldOptionColor

type SelectFieldOptionColor struct {
	Name  *string `json:"name,omitempty" name:"name"`
	Value *string `json:"value,omitempty" name:"value"`
}

SelectFieldOptionColor describe the single select field and multi select field option's color property

type SelectFieldProperty

type SelectFieldProperty struct {
	Options []*SelectFieldOption `json:"options,omitempty" name:"options"`
}

SelectFieldProperty describe the single select field and multi select field property

type SingleTextFieldProperty

type SingleTextFieldProperty struct {
	DefaultValue string `json:"defaultValue,omitempty" name:"defaultValue"`
}

SingleTextFieldProperty describe the single text field property

type Sort

type Sort struct {

	// the need sorted fields' name
	Field *string `json:"Field,omitempty" name:"field"`

	// sort order desc/asc
	Order *string `json:"Order,omitempty" name:"order"`
}

Sort the need sorted fields

type TextFieldValue

type TextFieldValue string

type UnitFieldValue

type UnitFieldValue struct {
	UnitName string `json:"unitName,omitempty" name:"unitName"`
	UnitType string `json:"unitType,omitempty" name:"unitType"`
	UnitId   string `json:"unitId,omitempty" name:"unitId"`
}

type UploadRequest

type UploadRequest struct {
	*athttp.BaseRequest
	// file path
	FilePath string `json:"filePath,omitempty" name:"filePath" string`
}

func NewUploadRequest

func NewUploadRequest() (request *UploadRequest)

type UploadResponse

type UploadResponse struct {
	*athttp.BaseResponse
	// api response data
	Data *Attachment `json:"data"`
}

func NewUploadResponse

func NewUploadResponse() (response *UploadResponse)

type UserFieldProperty

type UserFieldProperty struct {
	Options []*UserInfo `json:"options,omitempty" name:"options"`
}

UserFieldProperty describe createdBy,lastModifiedBy field property

type UserInfo

type UserInfo struct {
	Id     *string `json:"id,omitempty" name:"id"`
	Name   *string `json:"name,omitempty" name:"name"`
	Avatar *string `json:"avatar,omitempty" name:"avatar"`
}

UserInfo describe the user base info

type ValueType

type ValueType string

ValueType the apitable datasheet basic value type

const (
	ValueType_String   ValueType = "String"
	ValueType_Boolean  ValueType = "Boolean"
	ValueType_Number   ValueType = "Number"
	ValueType_DateTime ValueType = "DateTime"
	ValueType_Array    ValueType = "Array"
)

datasheet supported basic value type

type ViewType

type ViewType string

ViewType the type of the view

type ViewsResponse

type ViewsResponse struct {
	Views []*DatasheetView `json:"views"`
}

Jump to

Keyboard shortcuts

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