pub struct UnifiedApiKey { /* private fields */ }
Expand description

Represents all metadata for an App Store Connect API Key.

This is a convenience type to aid in the generic representation of all the components of an App Store Connect API Key. The type supports serialization so we save as a single file or payload to enhance usability (so people don’t need to provide all 3 pieces of the API Key for all operations).

Implementations§

Construct an instance from constitute parts and a PEM encoded ECDSA private key.

This is what you want to use if importing a private key from the file downloaded from the App Store Connect web interface.

Construct an instance from serialized JSON.

Examples found in repository?
src/api_key.rs (line 85)
82
83
84
85
86
    pub fn from_json_path(path: impl AsRef<Path>) -> Result<Self> {
        let data = std::fs::read(path.as_ref())?;

        Self::from_json(data)
    }

Construct an instance from a JSON file.

Examples found in repository?
src/lib.rs (line 38)
37
38
39
40
    pub fn from_json_path(path: &Path) -> Result<Self> {
        let key = UnifiedApiKey::from_json_path(path)?;
        AppStoreConnectClient::new(key.try_into()?)
    }

Serialize this instance to a JSON object.

Examples found in repository?
src/api_key.rs (line 108)
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
    pub fn write_json_file(&self, path: impl AsRef<Path>) -> Result<()> {
        let path = path.as_ref();

        if let Some(parent) = path.parent() {
            std::fs::create_dir_all(parent)?;
        }

        let data = self.to_json_string()?;

        let mut fh = std::fs::File::create(path)?;
        let mut permissions = fh.metadata()?.permissions();
        set_permissions_private(&mut permissions);
        fh.set_permissions(permissions)?;
        fh.write_all(data.as_bytes())?;

        Ok(())
    }

Write this instance to a JSON file.

Since the file contains sensitive data, it will have limited read permissions on platforms where this is implemented. Parent directories will be created if missing using default permissions for created directories.

Permissions on the resulting file may not be as restrictive as desired. It is up to callers to additionally harden as desired.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Serialize this value into the given Serde serializer. Read more
The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more