Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add service doc for gcs #2930

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 2 additions & 59 deletions core/src/services/gcs/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,65 +42,8 @@ const DEFAULT_GCS_ENDPOINT: &str = "https://storage.googleapis.com";
const DEFAULT_GCS_SCOPE: &str = "https://www.googleapis.com/auth/devstorage.read_write";
/// It's recommended that you use at least 8 MiB for the chunk size.
const DEFAULT_WRITE_FIXED_SIZE: usize = 8 * 1024 * 1024;
/// Google Cloud Storage service.
///
/// # Capabilities
///
/// This service can be used to:
///
/// - [x] stat
/// - [x] read
/// - [x] write
/// - [x] create_dir
/// - [x] delete
/// - [x] copy
/// - [ ] rename
/// - [x] list
/// - [x] scan
/// - [x] presign
/// - [ ] blocking
///
/// # Configuration
///
/// - `root`: Set the work directory for backend
/// - `bucket`: Set the container name for backend
/// - `endpoint`: Customizable endpoint setting
/// - `credentials`: Credential string for GCS OAuth2
/// - `predefined_acl`: Predefined ACL for GCS
/// - `default_storage_class`: Default storage class for GCS
///
/// You can refer to [`GcsBuilder`]'s docs for more information
///
/// # Example
///
/// ## Via Builder
///
/// ```no_run
/// use anyhow::Result;
/// use opendal::services::Gcs;
/// use opendal::Operator;
///
/// #[tokio::main]
/// async fn main() -> Result<()> {
/// // create backend builder
/// let mut builder = Gcs::default();
///
/// // set the storage bucket for OpenDAL
/// builder.bucket("test");
/// // set the working directory root for GCS
/// // all operations will happen within it
/// builder.root("/path/to/dir");
/// // set the credentials for GCS OAUTH2 authentication
/// builder.credential("authentication token");
/// // set the predefined ACL for GCS
/// builder.predefined_acl("publicRead");
/// // set the default storage class for GCS
/// builder.default_storage_class("STANDARD");
///
/// let op: Operator = Operator::new(builder)?.finish();
/// Ok(())
/// }
/// ```

/// [Google Cloud Storage](https://cloud.google.com/storage) services support.
#[derive(Default)]
pub struct GcsBuilder {
/// root URI, all operations happens under `root`
Expand Down
57 changes: 57 additions & 0 deletions core/src/services/gcs/docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
## Capabilities

This service can be used to:

- [x] stat
- [x] read
- [x] write
- [x] create_dir
- [x] delete
- [x] copy
- [ ] rename
- [x] list
- [x] scan
- [x] presign
- [ ] blocking

## Configuration

- `root`: Set the work directory for backend
- `bucket`: Set the container name for backend
- `endpoint`: Customizable endpoint setting
- `credentials`: Credential string for GCS OAuth2
- `predefined_acl`: Predefined ACL for GCS
- `default_storage_class`: Default storage class for GCS

Refer to public API docs for more information.

## Example

### Via Builder

```rust
use anyhow::Result;
use opendal::services::Gcs;
use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
// create backend builder
let mut builder = Gcs::default();

// set the storage bucket for OpenDAL
builder.bucket("test");
// set the working directory root for GCS
// all operations will happen within it
builder.root("/path/to/dir");
// set the credentials for GCS OAUTH2 authentication
builder.credential("authentication token");
// set the predefined ACL for GCS
builder.predefined_acl("publicRead");
// set the default storage class for GCS
builder.default_storage_class("STANDARD");

let op: Operator = Operator::new(builder)?.finish();
Ok(())
}
```
5 changes: 2 additions & 3 deletions website/docs/services/azblob.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions website/docs/services/azdfs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions website/docs/services/cos.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions website/docs/services/fs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions website/docs/services/ftp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
69 changes: 69 additions & 0 deletions website/docs/services/gcs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: Gcs
---

Google Cloud Storage Support

import Docs from '../../../core/src/services/gcs/docs.md'

<Docs components={props.components} />

### Via Config

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs>
<TabItem value="rust" label="Rust" default>

```rust
use anyhow::Result;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
let mut map = HashMap::new();
map.insert("bucket".to_string(), "test".to_string());
map.insert("root".to_string(), "/path/to/dir".to_string());
map.insert("credential".to_string(), "authentication token".to_string());
map.insert("predefined_acl".to_string(), "publicRead".to_string());
map.insert("default_storage_class".to_string(), "STANDARD".to_string());
let op: Operator = Operator::via_map(Scheme::Gcs, map)?;
Ok(())
}
```

</TabItem>
<TabItem value="node.js" label="Node.js">

```javascript
import { Operator } from "opendal";
async function main() {
const op = new Operator("gcs", {
bucket: "test",
root: "/path/to/dir",
credential: "authentication token",
predefined_acl: "publicRead",
default_storage_class: "STANDARD",
});
}
```

</TabItem>
<TabItem value="python" label="Python">

```python
import opendal
op = opendal.Operator("gcs",
bucket="test",
root="/path/to/dir",
credential="authentication token",
predefined_acl="publicRead",
default_storage_class="STANDARD",
)
```

</TabItem>
</Tabs>
5 changes: 2 additions & 3 deletions website/docs/services/hdfs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions website/docs/services/ipfs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions website/docs/services/memory.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions website/docs/services/oss.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions website/docs/services/redis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions website/docs/services/rocksdb.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions website/docs/services/s3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions website/docs/services/sftp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions website/docs/services/sled.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="rust" label="Rust" default>

```rust
use std::sync::Arc;

use anyhow::Result;
use opendal::Scheme;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
Loading