Documentation ¶
Index ¶
- Variables
- type APIError
- type Attribute
- type Author
- type Client
- func (c *Client) CreateActivity(req CreateActivityRequest) (*mcmodel.Activity, error)
- func (c *Client) CreateDataset(projectID int, req CreateOrUpdateDatasetRequest) (*mcmodel.Dataset, error)
- func (c *Client) CreateDirectoryByPath(projectID int, path string) (*mcmodel.File, error)
- func (c *Client) CreateEntity(req CreateEntityRequest) (*mcmodel.Entity, error)
- func (c *Client) CreateEntityState(projectID, entityID, activityID int, req CreateEntityStateRequest) (*mcmodel.Entity, error)
- func (c *Client) CreateExperiment(request CreateExperimentRequest) (*mcmodel.Experiment, error)
- func (c *Client) CreateProject(req CreateProjectRequest) (*mcmodel.Project, error)
- func (c *Client) DeleteProject(id int) error
- func (c *Client) DepositDataset(projectID int, req DepositDatasetRequest) (*mcmodel.Dataset, error)
- func (c *Client) GetDataset(projectID int, datasetID int) (*mcmodel.Dataset, error)
- func (c *Client) GetFileByPath(projectID int, path string) (*mcmodel.File, error)
- func (c *Client) GetProject(id int) (*mcmodel.Project, error)
- func (c *Client) ListDatasets(projectID int) ([]mcmodel.Dataset, error)
- func (c *Client) ListProjects() ([]mcmodel.Project, error)
- func (c *Client) MintDOIForDataset(projectID, datasetID int) (*mcmodel.Dataset, error)
- func (c *Client) PublishDataset(projectID int, datasetID int) (*mcmodel.Dataset, error)
- func (c *Client) SetDebug(on bool)
- func (c *Client) UnpublishDataset(projectID int, datasetID int) (*mcmodel.Dataset, error)
- func (c *Client) UpdateDataset(projectID int, datasetID int, req CreateOrUpdateDatasetRequest) (*mcmodel.Dataset, error)
- func (c *Client) UpdateDatasetFileSelection(projectID, datasetID int, fileSelection DatasetFileSelection) (*mcmodel.Dataset, error)
- func (c *Client) UploadFile(projectID, directoryID int, filePath string) (*mcmodel.File, error)
- func (c *Client) UploadFileTo(projectID int, filePath string, projectPath string) (*mcmodel.File, error)
- type ClientArgs
- type CreateActivityRequest
- type CreateEntityRequest
- type CreateEntityStateRequest
- type CreateExperimentRequest
- type CreateOrUpdateDatasetRequest
- type CreateProjectRequest
- type DataWrapper
- type DatasetFileSelection
- type DatasetFileUpload
- type DatasetMetadata
- type DepositDatasetRequest
- type ErrorResponse
- type Paper
- type Tag
Constants ¶
This section is empty.
Variables ¶
var DatasetLicenseAttribution = "Attribution License (ODC-By)"
var DatasetLicenseOpenDataset = "Open Database License (ODC-ODbL)"
var DatasetLicensePublicDomain = "Public Domain Dedication and License (PDDL)"
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError is an error that stores the StatusCode and Status from the response.
func NewAPIError ¶
func NewAPIError(resp *resty.Response) *APIError
NewAPIError creates an instance of APIError from a resty.Response. It extracts the StatusCode and Status from the response.
type Client ¶
Client is REST client for the Materials Commons API.
func NewClient ¶
func NewClient(args *ClientArgs) *Client
NewClient creates a new client, sets the Accept and Content-Type headers to "application/json", and sets the Authorization header to the token. It does a small amount of cleaning on the BaseURL by removing the trailing slashes in the baseURL so the API can construct paths easier.
func (*Client) CreateActivity ¶
func (c *Client) CreateActivity(req CreateActivityRequest) (*mcmodel.Activity, error)
CreateActivity creates a new activity based on the provided CreateActivityRequest struct.
func (*Client) CreateDataset ¶
func (c *Client) CreateDataset(projectID int, req CreateOrUpdateDatasetRequest) (*mcmodel.Dataset, error)
CreateDataset creates a new dataset within the specified project. It takes a projectID and a CreateOrUpdateDatasetRequest as parameters. It returns a pointer to the created Dataset object or an error, if any occurs.
func (*Client) CreateDirectoryByPath ¶ added in v0.0.3
CreateDirectoryByPath creates a directory at the specified path within the given project. If the directory already exists, it returns the existing directory. It takes a project ID and a path as parameters and returns the created directory or an error.
func (*Client) CreateEntity ¶
func (c *Client) CreateEntity(req CreateEntityRequest) (*mcmodel.Entity, error)
CreateEntity creates a new entity based on the provided request and returns the created entity or an error. The category in the request must be either 'experimental' or 'computational'. Defaults to 'experimental'.
func (*Client) CreateEntityState ¶
func (c *Client) CreateEntityState(projectID, entityID, activityID int, req CreateEntityStateRequest) (*mcmodel.Entity, error)
CreateEntityState creates a new entity state associated with the provided project, entity, and activity IDs.
func (*Client) CreateExperiment ¶ added in v0.0.3
func (c *Client) CreateExperiment(request CreateExperimentRequest) (*mcmodel.Experiment, error)
CreateExperiment creates a new experiment based on the given CreateExperimentRequest.
func (*Client) CreateProject ¶
func (c *Client) CreateProject(req CreateProjectRequest) (*mcmodel.Project, error)
CreateProject creates a new project with the specified parameters in CreateProjectRequest and returns the created project.
func (*Client) DeleteProject ¶ added in v0.0.3
DeleteProject deletes a project identified by the provided ID. It makes a DELETE request to the API endpoint corresponding to the given project ID. Returns an error if the project could not be deleted or if there is any issue with the request.
func (*Client) DepositDataset ¶ added in v0.0.3
DepositDataset deposits a dataset in a specified project given the project ID and request details. It creates the dataset, uploads files into a unique directory, and sets file selection for the dataset.
func (*Client) GetDataset ¶
func (*Client) GetFileByPath ¶ added in v0.0.3
GetFileByPath fetches a file from a project given the specified project ID and file path. It returns a pointer to the file and an error if the fetch operation fails.
func (*Client) GetProject ¶
GetProject retrieves the project details for the given project ID. It returns a pointer to the Project object and an error, if any.
func (*Client) ListDatasets ¶ added in v0.0.4
ListDatasets lists all the datasets in a project
func (*Client) ListProjects ¶ added in v0.0.4
ListProjects lists all the projects a user is a member of
func (*Client) MintDOIForDataset ¶ added in v0.0.4
MintDOIForDataset mints a new (findable) DOI for the dataset and assigns the DOI to it.
func (*Client) PublishDataset ¶
PublishDataset publishes a specified dataset by its datasetID in a particular project identified by projectID. Returns the published Dataset object or an error if the operation fails.
func (*Client) UnpublishDataset ¶
UnpublishDataset unpublishes a dataset associated with a specified project and dataset ID, returning the updated dataset or an error if the operation fails.
func (*Client) UpdateDataset ¶
func (c *Client) UpdateDataset(projectID int, datasetID int, req CreateOrUpdateDatasetRequest) (*mcmodel.Dataset, error)
UpdateDataset updates an existing dataset for the given project. Takes in a projectID, datasetID, and a CreateOrUpdateDatasetRequest object. Returns the updated Dataset object or an error if the update fails.
func (*Client) UpdateDatasetFileSelection ¶ added in v0.0.3
func (c *Client) UpdateDatasetFileSelection(projectID, datasetID int, fileSelection DatasetFileSelection) (*mcmodel.Dataset, error)
UpdateDatasetFileSelection updates the file selection criteria for a specified dataset within a project. It includes and excludes specified files and directories based on the DatasetFileSelection object.
func (*Client) UploadFile ¶
UploadFile uploads a file to the specified project and directory. Parameters: - projectID: ID of the project to which the file will be uploaded. - directoryID: ID of the directory within the project where the file will be stored. - filePath: Local path of the file to be uploaded. Returns: - *mcmodel.File: Uploaded file metadata if the operation is successful. - error: Describes the error encountered during file upload.
func (*Client) UploadFileTo ¶ added in v0.0.3
func (c *Client) UploadFileTo(projectID int, filePath string, projectPath string) (*mcmodel.File, error)
UploadFileTo uploads a file to a specified project directory path. If the project directory path is blank then it uploads the file to the project root. If the directory does not exist, it creates it.
type ClientArgs ¶
ClientArgs are the arguments when creating the client. You specify the URL to the server and the API Key for the user. If BaseURL is blank then it defaults to https://materialscommons.org/api.
type CreateActivityRequest ¶
type CreateEntityRequest ¶
type CreateEntityRequest struct { Name string `json:"name"` Category string `json:"category"` Description string `json:"description"` Summary string `json:"summary"` ExperimentID int `json:"experiment_id"` ProjectID int `json:"project_id"` ActivityID int `json:"activity_id"` Attributes []Attribute `json:"attributes"` }
type CreateExperimentRequest ¶ added in v0.0.3
type CreateOrUpdateDatasetRequest ¶
type CreateOrUpdateDatasetRequest struct { Name string `json:"name"` Description string `json:"description"` Summary string `json:"summary"` License string `json:"license"` Funding string `json:"funding"` Experiments []int `json:"experiments"` Communities []int `json:"communities"` Tags []Tag `json:"tags"` Authors []Author `json:"ds_authors"` }
type CreateProjectRequest ¶
type DataWrapper ¶
type DataWrapper struct {
Data any `json:"data"`
}
DataWrapper wraps json responses that have a data key before getting to the data, eg {"data": {"id": 1,... }}. It is used to get at the underlying data object.
type DatasetFileSelection ¶ added in v0.0.3
type DatasetFileUpload ¶ added in v0.0.3
type DatasetMetadata ¶ added in v0.0.3
type DatasetMetadata struct { Name string `json:"name"` Description string `json:"description"` Summary string `json:"summary"` License string `json:"license"` Funding string `json:"funding"` Communities []int `json:"communities"` Authors []Author `json:"authors"` Tags []Tag `json:"tags"` DOI string `json:"doi"` Papers []Paper `json:"papers"` Attributes []Attribute `json:"attributes"` }
type DepositDatasetRequest ¶ added in v0.0.3
type DepositDatasetRequest struct { Files []DatasetFileUpload `json:"files"` Metadata DatasetMetadata `json:"metadata"` }
type ErrorResponse ¶ added in v0.0.3
type ErrorResponse struct {
Error string `json:"error"`
}