Skip to main content

ResourceApi

Struct ResourceApi 

Source
pub struct ResourceApi<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> ResourceApi<'a>

Sub-API for resource endpoints.

Source

pub async fn add_alternative_file( &self, request: AddAlternativeFileRequest, ) -> Result<Value, RsError>

Add a new alternative file to a resource.

§Arguments
§Returns

The ID of the new alternative file, or false on failure.

§TODO: Errors
§TODO: Examples
Source

pub async fn copy_resource( &self, request: CopyResourceRequest, ) -> Result<Value, RsError>

Copy a resource. Note that attached files are not copied — this is a metadata and property copy only.

§Arguments
§Returns

The ID of the newly created resource, or false if the operation failed.

§TODO: Errors
§TODO: Examples
Source

pub async fn create_resource( &self, request: CreateResourceRequest, ) -> Result<Value, RsError>

Create a new resource.

§Arguments
§Returns

The ID of the newly created resource.

§TODO: Errors
§TODO: Examples
Source

pub async fn delete_alternative_file( &self, request: DeleteAlternativeFile, ) -> Result<Value, RsError>

Deletes an alternative file.

§Arguments
§Returns

The success of the operation (true/false).

§TODO: Errors
§TODO: Examples
Source

pub async fn delete_comment() -> Result<Value, RsError>

Source

pub async fn delete_resource( &self, request: DeleteResourceRequest, ) -> Result<Value, RsError>

Delete a resource.

§Arguments
§Returns

True or false depending on operation success.

§TODO: Errors
§TODO: Examples
Source

pub async fn get_alternative_files( &self, request: GetAlternativeFilesRequest, ) -> Result<Value, RsError>

Returns a list of alternative files for a resource.

§Arguments
§Returns

A list of alternative files.

§TODO: Errors
§TODO: Examples
Source

pub async fn get_edit_access( &self, request: GetEditAccessRequest, ) -> Result<Value, RsError>

Check if the current user has edit access to a resource.

§Arguments
§Returns

True if the user has edit access, false otherwise.

§TODO: Errors
§TODO: Examples

Returns a list of resources related to a resource.

§Arguments
§TODO: Errors
§TODO: Examples
Source

pub async fn get_resource_access( &self, request: GetResourceAccessRequest, ) -> Result<Value, RsError>

Retrieves the access level for the current user for a specified resource.

Returns 0 (full), 1 (restricted), 2 (confidential), 99 (not found), or false (invalid ID).

§Arguments
§TODO: Errors
§TODO: Examples
Source

pub async fn get_resource_all_image_sizes( &self, request: GetResourceAllImageSizesRequest, ) -> Result<Value, RsError>

Get all preview sizes available for a specific resource.

Multi-page resources will include each page size in the response.

§Arguments
§Returns

JSON containing the resource’s available sizes.

§TODO: Errors
§TODO: Examples
Source

pub async fn get_resource_comments( &self, _request: GetResourceCommentsRequest, ) -> Result<Value, RsError>

Retrieve comments for a resource.

Available from RS 11.0+.

§Arguments
§Returns

Array of comments in tree view by default, or flat list if requested. Returns an empty array if the user lacks permission or commenting is disabled.

§TODO: Errors
§TODO: Examples
Source

pub async fn get_resource_data( &self, request: GetResourceDataRequest, ) -> Result<Value, RsError>

Returns the top level property data for a resource, including truncated summary metadata.

For full non-truncated metadata use get_resource_field_data.

§Arguments
§Returns

The resource properties. Actual values depend on system configuration.

§TODO: Errors
§TODO: Examples
Source

pub async fn get_resource_field_data( &self, request: GetResourceFieldDataRequest, ) -> Result<Value, RsError>

Return all field data for a given resource.

§Arguments
§Returns

JSON containing the resource metadata.

§TODO: Errors
§TODO: Examples
Source

pub async fn get_resource_log( &self, request: GetResourceLogRequest, ) -> Result<Value, RsError>

Returns the full log for a resource.

§Arguments
§Returns

The resource log entries.

§TODO: Errors
§TODO: Examples
Source

pub async fn get_resource_path( &self, request: GetResourcePathRequest, ) -> Result<Value, RsError>

Returns a temporary URL for downloading a resource file.

The URL is valid for 24 hours by default (configurable via $api_resource_path_expiry_hours).

§Arguments
§Returns

A temporary URL for the requested resource file, or false on failure.

§TODO: Errors
§TODO: Examples
Source

pub async fn get_resource_types(&self) -> Result<Value, RsError>

Returns all configured resource types available to the current user.

From RS v10.2, the associated resource type field IDs are also returned.

§TODO: Errors
§TODO: Examples
Source

pub async fn put_resource_data( &self, request: PutResourceDataRequest, ) -> Result<Value, RsError>

Update resource properties (not metadata fields).

Valid columns: resource_type, creation_date, rating, user_rating, archive, access, created_by, mapzoom, modified, geo_lat, geo_long.

§Arguments
§TODO: Errors
§TODO: Examples
Source

pub async fn relate_all_resources( &self, request: RelateAllResourcesRequest, ) -> Result<Value, RsError>

Relate all the provided resources with each other.

§Arguments
§Returns

True or false depending on operation success.

§TODO: Errors
§TODO: Examples
Source

pub async fn replace_resource_file( &self, request: ReplaceResourceFileRequest, ) -> Result<Value, RsError>

Replaces the primary resource file for a given resource.

The file location must be accessible without authentication from the RS server — either a local path or a publicly accessible URL.

§Arguments
§Returns

A JSON encoded array with Status (SUCCESS/FAILED) and Message.

§TODO: Errors
§TODO: Examples
Source

pub async fn resource_file_readonly( &self, request: ResourceFileReadonlyRequest, ) -> Result<Value, RsError>

Check if a resource file is read-only due to filestore template threshold configuration.

Available from RS 10.5+.

§Arguments
§Returns

A 200 HTTP status will be returned with a payload detailing if successful or a 400 status otherwise.

§TODO: Errors
§TODO: Examples
Source

pub async fn resource_log_last_rows( &self, request: ResourceLogLastRowsRequest, ) -> Result<Value, RsError>

Retrieve recent entries from the resource log

§Arguments
§Returns

Log entries in JSON format, including date, ref, resource, type (type of log entry), resource_type_field, user ID, notes, diff and usageoption value

§TODO: Errors
§TODO: Examples
Source

pub async fn upload_file( &self, request: UploadFileRequest, ) -> Result<Value, RsError>

Uploads a file from a local server path to an existing resource.

The path must be local to the RS server. See $valid_upload_paths in RS config if using a custom upload path.

§Arguments
§Returns

True or false depending on operation success.

§TODO: Errors
§TODO: Examples
Source

pub async fn upload_file_by_url( &self, request: UploadFileByUrlRequest, ) -> Result<Value, RsError>

Uploads a remote file to an existing resource by URL.

RS fetches the file server-side. The URL hostname must be allowed via $api_upload_urls in RS config.

§Arguments
§Returns

True or false depending on operation success.

§TODO: Errors
§TODO: Examples
Source

pub async fn upload_multipart( &self, request: UploadMultipartRequest, file: impl AsRef<Path>, ) -> Result<Value, RsError>

Uploads files using HTTP multipart to an existing resource, replacing any file that is already attached.

§Arguments
§Returns

204 if succesful other status codes (413, 400, 500) if not

§TODO: Errors
§TODO: Examples
Examples found in repository?
examples/upload.rs (lines 26-29)
7async fn main() {
8    dotenvy::from_path("examples/.env").ok();
9
10    let base_url = std::env::var("RS_BASE_URL").expect("RS_BASE_URL not set");
11    let user = std::env::var("RS_USER").expect("RS_USER not set");
12    let _password = std::env::var("RS_PASS").expect("RS_PASS not set");
13    let key = std::env::var("RS_KEY").expect("RS_KEY not set");
14
15    let client = Client::builder()
16        .base_url(&base_url)
17        .expect("Error when setting base_url")
18        .user_key(&user, &key)
19        // .session_key(&user, &password)
20        .build()
21        .await
22        .expect("Error when building client");
23
24    let result = client
25        .resource()
26        .upload_multipart(
27            UploadMultipartRequest::new(91287, false, false),
28            Path::new("pexels.jpg"),
29        )
30        .await;
31
32    match result {
33        Ok(response) => println!("{:#?}", response),
34        Err(e) => println!("Error: {}", e),
35    }
36}

Add or remove resource relationships.

§Arguments
§Returns

True or false depending on operation success.

§TODO: Errors
§TODO: Examples
Source

pub async fn update_resource_type( &self, request: UpdateResourceTypeRequest, ) -> Result<Value, RsError>

Change the resource type of a resource.

§Arguments
§Returns

True or false depending on operation success.

§TODO: Errors
§TODO: Examples
Source

pub async fn get_resource_collections( &self, request: GetResourceCollectionsRequest, ) -> Result<Value, RsError>

Retrieves a list of collections that a resource is used in for the specified resource reference.

§Arguments
§Returns

Array of collections with the collection ID, name and description. False on failure.

§TODO: Errors
§TODO: Examples
Source

pub async fn validate_upload_url( &self, request: ValidateUploadUrlRequest, ) -> Result<Value, RsError>

Validate a URL supplied in the create_resource or upload_file_by_url API calls.

Requires the URL hostname to be added in the config option $api_upload_urls, for example: $api_upload_urls = array('resourcespace.com', 'localhost');

§Arguments
§Returns

Returns true if a valid URL is found, false otherwise.

§TODO: Errors
§TODO: Examples

Trait Implementations§

Source§

impl<'a> Debug for ResourceApi<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ResourceApi<'a>

§

impl<'a> !RefUnwindSafe for ResourceApi<'a>

§

impl<'a> Send for ResourceApi<'a>

§

impl<'a> Sync for ResourceApi<'a>

§

impl<'a> Unpin for ResourceApi<'a>

§

impl<'a> UnsafeUnpin for ResourceApi<'a>

§

impl<'a> !UnwindSafe for ResourceApi<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more