github.com/minio/madmin-go@v1.7.5/examples/create-job.go (about)

     1  //go:build ignore
     2  // +build ignore
     3  
     4  //
     5  // MinIO Object Storage (c) 2022 MinIO, Inc.
     6  //
     7  // Licensed under the Apache License, Version 2.0 (the "License");
     8  // you may not use this file except in compliance with the License.
     9  // You may obtain a copy of the License at
    10  //
    11  //      http://www.apache.org/licenses/LICENSE-2.0
    12  //
    13  // Unless required by applicable law or agreed to in writing, software
    14  // distributed under the License is distributed on an "AS IS" BASIS,
    15  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    16  // See the License for the specific language governing permissions and
    17  // limitations under the License.
    18  //
    19  
    20  package main
    21  
    22  import (
    23  	"context"
    24  	"log"
    25  	"os"
    26  
    27  	"github.com/minio/madmin-go"
    28  )
    29  
    30  func main() {
    31  	// Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
    32  	// dummy values, please replace them with original values.
    33  
    34  	// API requests are secure (HTTPS) if secure=true and insecure (HTTP) otherwise.
    35  	// New returns an MinIO Admin client object.
    36  	madmClnt, err := madmin.New("your-minio.example.com:9000", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
    37  	if err != nil {
    38  		log.Fatalln(err)
    39  	}
    40  	madmClnt.TraceOn(os.Stderr)
    41  
    42  	job := `
    43  replicate:
    44    flags:
    45      # (optional)
    46      name: "weekly-replication-job"
    47    
    48    target:
    49      type: "minio"
    50      bucket: "testbucket"
    51      endpoint: "https://play.min.io"
    52      credentials:
    53        accessKey: "minioadmin"
    54        secretKey: "minioadmin"
    55        sessionToken: ""
    56        
    57    source:
    58      type: "minio"
    59      bucket: "testbucket"
    60      prefix: ""
    61  `
    62  	if err = madmClnt.StartBatchJob(context.Background(), job); err != nil {
    63  		log.Fatalln(err)
    64  	}
    65  }