setSecretMetadata
Syntax
Description
setSecretMetadata(
adds the metadata in the dictionary secretname
,secretMetadata
)secretMetadata
to the specified
secret in your MATLAB® vault. Your MATLAB vault is accessible only from the exact combination of your operating system
account and local machine.
setSecretMetadata(
specifies whether to add, merge, or replace existing secret metadata.secretname
,secretMetadata
,WriteMode=mode
)
Examples
Add Secret Metadata
Create a dictionary that contains metadata for an existing secret. Specify dictionary keys as strings, and specify dictionary values as cells.
m = dictionary(["Description","TeamMembers", ... "Phone","CreationDate"], ... [{"This is an example of metadata"}, ... {"Maria Silva, Akane Saito"}, ... {"123-456-7890"},{datetime("now")}])
m = dictionary (string ⟼ cell) with 4 entries: "Description" ⟼ {["This is an example of metadata"]} "TeamMembers" ⟼ {["Maria Silva, Akane Saito"]} "Phone" ⟼ {["123-456-7890"]} "CreationDate" ⟼ {[01-Nov-2023 12:34:06]}
Add the metadata to an existing secret in your vault.
setSecretMetadata("SFTPpassword",m);
Add additional elements to your metadata using additional dictionaries. View your updated metadata.
version = dictionary(["version"],[{"5.1"}]); setSecretMetadata("SFTPpassword",version); getSecretMetadata("SFTPpassword")
dictionary (string ⟼ cell) with 5 entries: "CreationDate" ⟼ {[01-Nov-2023 12:34:06]} "Description" ⟼ {["This is an example of metadata"]} "Phone" ⟼ {["123-456-7890"]} "TeamMembers" ⟼ {["Maria Silva, Akane Saito"]} "version" ⟼ {["5.1"]}
Overwrite Secret Metadata Element
Add metadata to an existing secret in your vault.
m = dictionary(["Description","TeamMembers", ... "Phone","CreationDate"], ... [{"This is an example of metadata"}, ... {"Maria Silva, Akane Saito"}, ... {"123-456-7890"},{datetime("now")}]); setSecretMetadata("SFTPpassword",m);
Overwrite the value of TeamMembers
by merging a new dictionary
with the existing metadata dictionary. Then view the updated metadata of the
secret.
m2 = dictionary(["TeamMembers"],[{"John Doe, Omar Ali"}]); setSecretMetadata("SFTPpassword",m2,WriteMode="merge"); getSecretMetadata("SFTPpassword")
dictionary (string ⟼ cell) with 4 entries: "CreationDate" ⟼ {[01-Nov-2023 12:41:12]} "Description" ⟼ {["This is an example of metadata"]} "Phone" ⟼ {["123-456-7890"]} "TeamMembers" ⟼ {["John Doe, Omar Ali"]}
Replace Secret Metadata
Add metadata to an existing secret in your vault.
m = dictionary(["Description","TeamMembers", ... "Phone","CreationDate"], ... [{"This is an example of metadata"}, ... {"Maria Silva, Akane Saito"}, ... {"123-456-7890"},{datetime("now")}]); setSecretMetadata("SFTPpassword",m);
Replace the existing metadata dictionary of the secret with a new dictionary. Then view the updated metadata.
m2 = dictionary(["Description","CreationDate"], ... [{"Another example of metadata"},{datetime("now")}]); setSecretMetadata("SFTPpassword",m2,WriteMode="replace"); getSecretMetadata("SFTPpassword")
dictionary (string ⟼ cell) with 2 entries: "CreationDate" ⟼ {[01-Nov-2023 12:51:17]} "Description" ⟼ {["Another example of metadata"]}
Clear Secret Metadata
Add metadata to an existing secret in your vault.
m = dictionary(["Description","TeamMembers", ... "Phone","CreationDate"], ... [{"This is an example of metadata"}, ... {"Maria Silva, Akane Saito"}, ... {"123-456-7890"},{datetime("now")}]); setSecretMetadata("SFTPpassword",m);
Clear the metadata of the secret by replacing it with an empty dictionary. Then view the cleared metadata.
m2 = configureDictionary("string","cell"); setSecretMetadata("SFTPpassword",m2,WriteMode="replace"); getSecretMetadata("SFTPpassword")
dictionary (string ⟼ cell) with no entries.
Input Arguments
secretname
— Unique case-sensitive text identifier for secret
string scalar | character vector
Unique case-sensitive text identifier for the secret, specified as a string scalar or character vector. You can use a secret to hold sensitive information, such as passwords, certificates, credentials, OAuth tokens, and other configuration data for:
SFTP and FTP servers
Password-protected files, such as PDFs
Password-protected archives, such as zip files
Cloud providers, such as Amazon S3™ and Windows Azure® Blob Storage
API keys, SSH keys, and encryption keys
Databases and applications
The forward slash character (/
) is not supported in
secretname
.
secretMetadata
— Metadata for secret
dictionary
Metadata for the secret, specified as a dictionary whose keys are strings and values
are cells. For more information on dictionaries, see dictionary
.
You can use metadata to store information, such as:
Description
Creation time
URL
Geolocation
Email address
Phone number
mode
— Mode for modifying secret metadata dictionary
"add"
(default) | "merge"
| "replace"
Mode for modifying secret metadata dictionary, specified as one of these values:
"add"
– Add elements to the metadata dictionary of a secret. Existing metadata is not modified and matching keys cause an error."merge"
– Merge a new metadata dictionary with the existing metadata dictionary of a secret. If any keys match existing keys, the new values overwrite the existing values."replace"
– Replace the entire metadata dictionary. Use this mode with an empty dictionary to clear the metadata.
For more information on dictionaries, see dictionary
.
Data Types: string
| char
More About
MATLAB Vault
Your secrets are stored in your MATLAB vault, which is accessible only from the exact combination of your operating system account and local machine. Your vault and secrets, which do not leave your local machine, persist across MATLAB sessions. Each secret consists of a name, value, and optional metadata.
Secret name – A unique case-sensitive text identifier for the secret. The secret name is stored unencrypted in your vault as a string scalar.
Secret value – A text value associated with the secret. The Secret Prompt dialog box, where you enter the secret value, supports copy-paste functionality. The secret value is stored encrypted in your vault using industry standard AES-256 encryption. The secret value is returned as a string scalar.
Secret metadata – A dictionary containing additional information associated with the secret. The optional secret metadata is stored unencrypted in your vault.
To set a secret, use setSecret
.
Version History
Introduced in R2024a
See Also
getSecretMetadata
| setSecret
| getSecret
| isSecret
| listSecrets
| removeSecret
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)