MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / new_refresh_state

Function new_refresh_state

crates/openshell-server/src/provider_refresh.rs:182–220  ·  view source on GitHub ↗
(
    provider: &Provider,
    credential_key: &str,
    config: NewRefreshStateConfig,
)

Source from the content-addressed store, hash-verified

180
181#[allow(clippy::unnecessary_wraps)]
182pub fn new_refresh_state(
183 provider: &Provider,
184 credential_key: &str,
185 config: NewRefreshStateConfig,
186) -> Result<StoredProviderCredentialRefreshState, Status> {
187 let provider_id = provider.object_id().to_string();
188 let provider_name = provider.object_name().to_string();
189 let now_ms = current_time_ms();
190 let next_refresh_at_ms = next_refresh_at_ms(
191 config.expires_at_ms,
192 config.refresh_before_seconds,
193 config.max_lifetime_seconds,
194 now_ms,
195 );
196 Ok(StoredProviderCredentialRefreshState {
197 metadata: Some(openshell_core::proto::datamodel::v1::ObjectMeta {
198 id: uuid::Uuid::new_v4().to_string(),
199 name: refresh_state_name(&provider_id, credential_key),
200 created_at_ms: now_ms,
201 labels: HashMap::new(),
202 resource_version: 0,
203 }),
204 provider_id,
205 provider_name,
206 credential_key: credential_key.to_string(),
207 strategy: config.strategy as i32,
208 material: config.material,
209 secret_material_keys: config.secret_material_keys,
210 expires_at_ms: config.expires_at_ms,
211 next_refresh_at_ms,
212 last_refresh_at_ms: 0,
213 status: "configured".to_string(),
214 last_error: String::new(),
215 token_url: config.token_url,
216 scopes: config.scopes,
217 refresh_before_seconds: config.refresh_before_seconds,
218 max_lifetime_seconds: config.max_lifetime_seconds,
219 })
220}
221
222use openshell_core::{ObjectId, ObjectName};
223

Calls 5

next_refresh_at_msFunction · 0.85
refresh_state_nameFunction · 0.85
object_idMethod · 0.80
object_nameMethod · 0.80
current_time_msFunction · 0.50

Tested by

no test coverage detected