JulesClient

Struct JulesClient 

Source
pub struct JulesClient { /* private fields */ }
Expand description

The main client for interacting with the Jules API.

JulesClient provides methods for all Jules API operations including managing sessions, activities, and sources.

§Example

use jules_rs::JulesClient;

let client = JulesClient::new("YOUR_OAUTH_TOKEN")?;

// List sessions
let response = client.list_sessions(Some(10), None).await?;
println!("Found {} sessions", response.sessions.len());

Implementations§

Source§

impl JulesClient

Source

pub fn new(token: impl Into<String>) -> Result<Self>

Creates a new Jules API client.

§Arguments
§Errors

Returns an error if the base URL cannot be parsed (should not happen under normal circumstances).

§Example
use jules_rs::JulesClient;

let client = JulesClient::new("YOUR_API_KEY").unwrap();
Source

pub async fn create_session(&self, session: &Session) -> Result<Session>

Creates a new coding session.

§Arguments
  • session - The session configuration including prompt and source context.
§Returns

The created session with server-generated fields populated (name, id, etc.).

§Example
use jules_rs::{JulesClient, Session, SourceContext, GitHubRepoContext};

let client = JulesClient::new("TOKEN")?;
let session = Session {
    prompt: "Fix the bug".to_string(),
    source_context: SourceContext {
        source: "sources/repo-id".to_string(),
        github_repo_context: Some(GitHubRepoContext {
            starting_branch: "main".to_string(),
        }),
    },
    // ... other fields set to None/default
};
let created = client.create_session(&session).await?;
Source

pub async fn get_session(&self, name: &str) -> Result<Session>

Gets a session by its resource name.

§Arguments
  • name - The full resource name (e.g., sessions/abc123).
Source

pub async fn delete_session(&self, name: &str) -> Result<()>

Deletes a session.

§Arguments
  • name - The full resource name of the session to delete.
Source

pub async fn list_sessions( &self, page_size: Option<i32>, page_token: Option<String>, ) -> Result<ListSessionsResponse>

Lists sessions with pagination.

§Arguments
  • page_size - Maximum number of sessions to return (1-100, default 30).
  • page_token - Token from a previous response for pagination.
§Returns

A response containing sessions and optionally a token for the next page.

Source

pub fn stream_sessions( &self, ) -> Pin<Box<dyn Stream<Item = Result<Session>> + '_>>

Returns an async stream over all sessions.

This method automatically handles pagination, yielding sessions one at a time until all sessions have been retrieved.

§Example
use jules_rs::JulesClient;
use futures_util::StreamExt;

let client = JulesClient::new("TOKEN")?;
let mut stream = client.stream_sessions();

while let Some(result) = stream.next().await {
    let session = result?;
    println!("Session: {:?}", session.title);
}
Source

pub async fn send_message(&self, session_name: &str, prompt: &str) -> Result<()>

Sends a message to an active session.

Use this to provide additional context or respond to the agent’s questions during a session.

§Arguments
  • session_name - The full resource name of the session.
  • prompt - The message to send.
Source

pub async fn approve_plan(&self, session_name: &str) -> Result<()>

Approves the current plan for a session.

When a session is in the AWAITING_PLAN_APPROVAL state, call this method to approve the plan and allow the agent to proceed.

§Arguments
  • session_name - The full resource name of the session.
Source

pub async fn get_activity(&self, name: &str) -> Result<Activity>

Gets an activity by its resource name.

§Arguments
  • name - The full resource name (e.g., sessions/123/activities/456).
Source

pub async fn list_activities( &self, session_name: &str, page_size: Option<i32>, page_token: Option<String>, ) -> Result<ListActivitiesResponse>

Lists activities for a session with pagination.

§Arguments
  • session_name - The full resource name of the session.
  • page_size - Maximum number of activities to return.
  • page_token - Token from a previous response for pagination.
Source

pub async fn get_source(&self, name: &str) -> Result<Source>

Gets a source by its resource name.

§Arguments
  • name - The full resource name (e.g., sources/abc123).
Source

pub async fn list_sources( &self, filter: Option<String>, page_size: Option<i32>, page_token: Option<String>, ) -> Result<ListSourcesResponse>

Lists available sources (connected repositories) with pagination.

§Arguments
  • filter - Optional filter expression.
  • page_size - Maximum number of sources to return.
  • page_token - Token from a previous response for pagination.

Auto Trait Implementations§

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, 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