Skip to main content

FilesResource

Struct FilesResource 

Source
pub struct FilesResource<'a> { /* private fields */ }
Expand description

client.files()

Implementations§

Source§

impl<'a> FilesResource<'a>

Source

pub fn create( &self, domain_type: impl Display, domain_identifier: impl Display, files: &[Upload], ) -> Result<Vec<FileUploadResult>>

Upload files

POST /files/{domainType}/{domainIdentifier}

Uploads files to a domain object. Requires update permission. The attachment category controls file multiplicity, image dimensions and category-specific processing.

Use Self::create_with to pass query parameters.

§Example
let file = Upload::from_path("gemeindebrief.pdf")?;
for file in client.files().create(serde_json::json!("agenda_PRO_PRESENTER_6"), "42", &[file])? {
    println!("{}", file.name);
}
Source

pub fn create_with( &self, domain_type: impl Display, domain_identifier: impl Display, files: &[Upload], form: &PostFilesDomainTypeDomainIdentifierForm, ) -> Result<Vec<FileUploadResult>>

Upload files

Like Self::create, with form fields.

POST /files/{domainType}/{domainIdentifier}

Uploads files to a domain object. Requires update permission. The attachment category controls file multiplicity, image dimensions and category-specific processing.

Source

pub fn delete(&self, id: impl Display) -> Result<()>

Delete a file by ID

DELETE /files/{id}

Deletes one file or URL attachment. Requires update permission for its owning object and runs category-specific delete hooks.

§Example
client.files().delete(1)?;
Source

pub fn delete_for_object( &self, domain_type: impl Display, domain_identifier: impl Display, ) -> Result<()>

Delete all files for a domain object

DELETE /files/{domainType}/{domainIdentifier}

Deletes every file and URL attachment of the domain object. Requires update permission for the object and runs category-specific delete hooks.

§Example
client.files().delete_for_object(serde_json::json!("agenda_PRO_PRESENTER_6"), "42")?;
Source

pub fn get_meta(&self, id: impl Display) -> Result<CtFile>

Get file metadata by ID

GET /files/{id}/meta

Returns normalized metadata for a file or URL attachment. Requires view permission for the file. Anonymous access depends on the attachment category.

§Example
let meta = client.files().get_meta(1)?;
println!("{}", meta.name);
Source

pub fn get_metadata(&self, file_id: impl Display) -> Result<LegacyFileMetadata>

👎Deprecated:

GET /files/{fileId}/metadata is deprecated in the ChurchTools API. Use GET /files/{id}/meta for normalized file metadata.

Get legacy file metadata

GET /files/{fileId}/metadata

Returns the raw file database record without a response envelope. Use GET /files/{id}/meta for normalized file metadata.

§Example
let metadata = client.files().get_metadata(42)?;
println!("{}", metadata.id);

Add a link attachment

POST /files/{domainType}/{domainIdentifier}/link

Creates a URL attachment without fetching its target. Requires update permission and runs the selected category’s file-save hooks.

§Example
let body = models::FileLinkCreate {
    url: "https://example.org/service-notes".into(),
    ..Default::default()
};
let file = client.files().link(serde_json::json!("agenda_PRO_PRESENTER_6"), "42", &body)?;
println!("{}", file.name);
Source

pub fn list( &self, domain_type: impl Display, domain_identifier: impl Display, ) -> Result<Vec<CtFile>>

Get all files for a specific domain object

GET /files/{domainType}/{domainIdentifier}

Returns metadata for files and URL attachments of one domain object. Files hidden by view permissions or showOnlyWhenEditable are omitted. Anonymous access depends on the selected attachment category.

§Example
for file in client.files().list(serde_json::json!("agenda_PRO_PRESENTER_6"), "42")? {
    println!("{}", file.name);
}
Source

pub fn list_for_type(&self, domain_type: impl Display) -> Result<Value>

Get all files for a domain type

GET /files/{domainType}

Returns file and URL-attachment metadata for one attachment category. Files hidden by view permissions or showOnlyWhenEditable are omitted.

§Example
let result = client.files().list_for_type(serde_json::json!("agenda_PRO_PRESENTER_6"))?;
println!("{:?}", result);
Source

pub fn patch(&self, id: impl Display, body: &FileUpdate) -> Result<()>

Update file metadata by ID

PATCH /files/{id}

Updates a file’s display metadata and optionally copies it to another attachment context. Updating requires source update permission; copying requires source view permission and target update permission.

§Example
let body = models::FileUpdate {
    name: Some(Some("Service notes.pdf".into())),
    ..Default::default()
};
client.files().patch(1, &body)?;
Source

pub fn update_for_object( &self, domain_type: impl Display, domain_identifier: impl Display, body: &FileDomainUpdate, ) -> Result<()>

Update files for a domain object

PATCH /files/{domainType}/{domainIdentifier}

Updates the display name and sort key of every attachment of the domain object. Requires update permission and runs category-specific metadata hooks for each affected file.

§Example
let body = models::FileDomainUpdate {
    name: Some(Some("Service notes.pdf".into())),
    ..Default::default()
};
client.files().update_for_object(serde_json::json!("agenda_PRO_PRESENTER_6"), "42", &body)?;

Trait Implementations§

Source§

impl<'a> Clone for FilesResource<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for FilesResource<'a>

Auto Trait Implementations§

§

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

§

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

§

impl<'a> Freeze for FilesResource<'a>

§

impl<'a> Send for FilesResource<'a>

§

impl<'a> Sync for FilesResource<'a>

§

impl<'a> Unpin for FilesResource<'a>

§

impl<'a> UnsafeUnpin for FilesResource<'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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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: Sized + 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: Sized + 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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