# RustFsBuilderExtensions Methods

- Package: [CommunityToolkit.Aspire.Hosting.RustFs](/reference/api/csharp/communitytoolkit.aspire.hosting.rustfs.md)
- Type: [RustFsBuilderExtensions](/reference/api/csharp/communitytoolkit.aspire.hosting.rustfs/rustfsbuilderextensions.md)
- Kind: `Methods`
- Members: `6`

Provides extension methods for adding RustFs resources to an `Hosting.IDistributedApplicationBuilder`.

<a id="addbucket"></a>
<a id="addbucket-iresourcebuilder-rustfsresource-string"></a>

## AddBucket(IResourceBuilder<RustFsResource>, string)

- Name: `AddBucket(IResourceBuilder<RustFsResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RustFsBucketResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d479e13473b1d29d06b974f144a0049289a3cb5c/src/CommunityToolkit.Aspire.Hosting.RustFs/RustFsBuilderExtensions.cs#L163-L168)

Adds a bucket to the RustFs resource. The bucket is created by issuing a signed `PUT` request to the RustFs S3 API after the server resource becomes ready.

```csharp
public static class RustFsBuilderExtensions
{
    public static IResourceBuilder<RustFsBucketResource> AddBucket(
        this IResourceBuilder<RustFsResource> builder,
        string bucketName)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<RustFsResource>`)
  The resource builder.
- `bucketName` (`string`)
  The name of the bucket to create.

## Returns

`IResourceBuilder<RustFsBucketResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1` for the bucket resource.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="addbucket-iresourcebuilder-rustfsresource-ireadonlylist-string"></a>

## AddBucket(IResourceBuilder<RustFsResource>, IReadOnlyList<string>)

- Name: `AddBucket(IResourceBuilder<RustFsResource>, IReadOnlyList<string>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RustFsResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d479e13473b1d29d06b974f144a0049289a3cb5c/src/CommunityToolkit.Aspire.Hosting.RustFs/RustFsBuilderExtensions.cs#L182-L199)

Adds multiple buckets to the RustFs resource. Each bucket is registered as its own [RustFsBucketResource](/reference/api/csharp/communitytoolkit.aspire.hosting.rustfs/rustfsbucketresource.md) child resource and created via the RustFs S3 API once the server resource becomes ready.

```csharp
public static class RustFsBuilderExtensions
{
    public static IResourceBuilder<RustFsResource> AddBucket(
        this IResourceBuilder<RustFsResource> builder,
        IReadOnlyList<string> bucketNames)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<RustFsResource>`)
  The resource builder.
- `bucketNames` (`IReadOnlyList<string>`)
  The names of the buckets to create.

## Returns

`IResourceBuilder<RustFsResource>` -- The original `ApplicationModel.IResourceBuilder`1` for further chaining.

## ATS metadata

### ATS export

- Capability ID: `CommunityToolkit.Aspire.Hosting.RustFs/addBuckets`

<a id="addrustfs"></a>
<a id="addrustfs-idistributedapplicationbuilder-string-iresourcebuilder-parameterresource-iresourcebuilder-parameterresource-int-int"></a>

## AddRustFs(IDistributedApplicationBuilder, string, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>, int?, int?)

- Name: `AddRustFs(IDistributedApplicationBuilder, string, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>, int?, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RustFsResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d479e13473b1d29d06b974f144a0049289a3cb5c/src/CommunityToolkit.Aspire.Hosting.RustFs/RustFsBuilderExtensions.cs#L38-L72)

Adds a RustFs container to the application model. The default image is "rustfs/rustfs".

```csharp
public static class RustFsBuilderExtensions
{
    public static IResourceBuilder<RustFsResource> AddRustFs(
        this IDistributedApplicationBuilder builder,
        string name,
        IResourceBuilder<ParameterResource>? accessKey = null,
        IResourceBuilder<ParameterResource>? secretKey = null,
        int? port = null,
        int? consolePort = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder`.
- `name` (`string`)
  The name of the resource. This name will be used as the connection string name when referenced in a dependency.
- `accessKey` (`IResourceBuilder<ParameterResource>`) `optional`
  The parameter used to provide the access key for the RustFs resource. If `null` a random key will be generated.
- `secretKey` (`IResourceBuilder<ParameterResource>`) `optional`
  The parameter used to provide the secret key for the RustFs resource. If `null` a random key will be generated.
- `port` (`int?`) `optional`
  The host port for the RustFs S3-compatible API endpoint.
- `consolePort` (`int?`) `optional`
  The host port for the RustFs console endpoint.

## Returns

`IResourceBuilder<RustFsResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withdatabindmount"></a>
<a id="withdatabindmount-iresourcebuilder-rustfsresource-string"></a>

## WithDataBindMount(IResourceBuilder<RustFsResource>, string)

- Name: `WithDataBindMount(IResourceBuilder<RustFsResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RustFsResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d479e13473b1d29d06b974f144a0049289a3cb5c/src/CommunityToolkit.Aspire.Hosting.RustFs/RustFsBuilderExtensions.cs#L130-L133)

Adds a bind mount for the data folder to a RustFs container resource.

```csharp
public static class RustFsBuilderExtensions
{
    public static IResourceBuilder<RustFsResource> WithDataBindMount(
        this IResourceBuilder<RustFsResource> builder,
        string source)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<RustFsResource>`)
  The resource builder.
- `source` (`string`)
  The source directory on the host to mount into the container.

## Returns

`IResourceBuilder<RustFsResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## Remarks

Add a RustFs container to the application model and reference it in a .NET project. Additionally, in this example a bind mount is added to the container to allow data to be persisted across container restarts.

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var rustfs = builder.AddRustFs("rustfs")
    .WithDataBindMount("./data/rustfs/data");
var api = builder.AddProject<Projects.Api>("api")
    .WithReference(rustfs);

builder.Build().Run();
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withdatavolume"></a>
<a id="withdatavolume-iresourcebuilder-rustfsresource-string"></a>

## WithDataVolume(IResourceBuilder<RustFsResource>, string?)

- Name: `WithDataVolume(IResourceBuilder<RustFsResource>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RustFsResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d479e13473b1d29d06b974f144a0049289a3cb5c/src/CommunityToolkit.Aspire.Hosting.RustFs/RustFsBuilderExtensions.cs#L100-L102)

Adds a named volume for the data folder to a RustFs container resource.

```csharp
public static class RustFsBuilderExtensions
{
    public static IResourceBuilder<RustFsResource> WithDataVolume(
        this IResourceBuilder<RustFsResource> builder,
        string? name = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<RustFsResource>`)
  The resource builder.
- `name` (`string?`) `optional`
  The name of the volume. Defaults to an auto-generated name based on the application and resource names.

## Returns

`IResourceBuilder<RustFsResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## Remarks

Add a RustFs container to the application model and reference it in a .NET project. Additionally, in this example a data volume is added to the container to allow data to be persisted across container restarts.

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var rustfs = builder.AddRustFs("rustfs")
    .WithDataVolume();
var api = builder.AddProject<Projects.Api>("api")
    .WithReference(rustfs);

builder.Build().Run();
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withsigningregion"></a>
<a id="withsigningregion-iresourcebuilder-rustfsresource-string"></a>

## WithSigningRegion(IResourceBuilder<RustFsResource>, string)

- Name: `WithSigningRegion(IResourceBuilder<RustFsResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RustFsResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d479e13473b1d29d06b974f144a0049289a3cb5c/src/CommunityToolkit.Aspire.Hosting.RustFs/RustFsBuilderExtensions.cs#L146-L150)

Sets the AWS signing region used when creating buckets via the S3 API. Defaults to `us-east-1` if not specified.

```csharp
public static class RustFsBuilderExtensions
{
    public static IResourceBuilder<RustFsResource> WithSigningRegion(
        this IResourceBuilder<RustFsResource> builder,
        string region)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<RustFsResource>`)
  The resource builder.
- `region` (`string`)
  The AWS signing region (e.g. `us-east-1`, `ap-northeast-1`).

## Returns

`IResourceBuilder<RustFsResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
