github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/api/apc/provider.go (about)

     1  // Package apc: API control messages and constants
     2  /*
     3   * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
     4   */
     5  package apc
     6  
     7  import (
     8  	"github.com/NVIDIA/aistore/cmn/cos"
     9  )
    10  
    11  // Backend Provider enum
    12  const (
    13  	AIS   = "ais"
    14  	AWS   = "aws"
    15  	Azure = "azure"
    16  	GCP   = "gcp"
    17  	HTTP  = "ht"
    18  
    19  	AllProviders = "ais, aws (s3://), gcp (gs://), azure (az://), ht://" // NOTE: must include all
    20  
    21  	NsUUIDPrefix = '@' // BEWARE: used by on-disk layout
    22  	NsNamePrefix = '#' // BEWARE: used by on-disk layout
    23  
    24  	// consistent with rfc2396.txt "Uniform Resource Identifiers (URI): Generic Syntax"
    25  	BckProviderSeparator = "://"
    26  
    27  	// scheme://
    28  	DefaultScheme = "https"
    29  	GSScheme      = "gs"
    30  	S3Scheme      = "s3"
    31  	AZScheme      = "az"
    32  	AISScheme     = "ais"
    33  )
    34  
    35  var Providers = cos.NewStrSet(AIS, GCP, AWS, Azure, HTTP)
    36  
    37  func IsProvider(p string) bool { return Providers.Contains(p) }
    38  
    39  func IsCloudProvider(p string) bool {
    40  	return p == AWS || p == GCP || p == Azure
    41  }
    42  
    43  // not to confuse w/ bck.IsRemote()
    44  func IsRemoteProvider(p string) bool {
    45  	return IsCloudProvider(p) || p == HTTP
    46  }
    47  
    48  func ToScheme(p string) string {
    49  	switch p {
    50  	case AWS:
    51  		return S3Scheme
    52  	case Azure:
    53  		return AZScheme
    54  	case GCP:
    55  		return GSScheme
    56  	default:
    57  		return p
    58  	}
    59  }
    60  
    61  func NormalizeProvider(p string) string {
    62  	if IsProvider(p) {
    63  		return p
    64  	}
    65  	switch p {
    66  	case "":
    67  		return AIS // NOTE: ais is the default provider
    68  	case S3Scheme:
    69  		return AWS
    70  	case AZScheme:
    71  		return Azure
    72  	case GSScheme:
    73  		return GCP
    74  	default:
    75  		return ""
    76  	}
    77  }
    78  
    79  func DisplayProvider(p string) string {
    80  	switch p {
    81  	case AIS:
    82  		return "AIS"
    83  	case AWS, S3Scheme:
    84  		return "AWS"
    85  	case Azure, AZScheme:
    86  		return "Azure"
    87  	case GCP, GSScheme:
    88  		return "GCP"
    89  	case HTTP:
    90  		return "HTTP(S)"
    91  	default:
    92  		return p
    93  	}
    94  }