github.com/m3db/m3@v1.5.0/src/ctl/service/r2/store/store.go (about)

     1  // Copyright (c) 2018 Uber Technologies, Inc.
     2  //
     3  // Permission is hereby granted, free of charge, to any person obtaining a copy
     4  // of this software and associated documentation files (the "Software"), to deal
     5  // in the Software without restriction, including without limitation the rights
     6  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     7  // copies of the Software, and to permit persons to whom the Software is
     8  // furnished to do so, subject to the following conditions:
     9  //
    10  // The above copyright notice and this permission notice shall be included in
    11  // all copies or substantial portions of the Software.
    12  //
    13  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    14  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    15  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    16  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    17  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    18  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    19  // THE SOFTWARE
    20  
    21  package store
    22  
    23  import (
    24  	"github.com/m3db/m3/src/metrics/rules/view"
    25  	"github.com/m3db/m3/src/metrics/rules/view/changes"
    26  )
    27  
    28  // Store is a construct that can perform operations against a backing rule store.
    29  type Store interface {
    30  	// FetchNamespaces fetches namespaces.
    31  	FetchNamespaces() (view.Namespaces, error)
    32  
    33  	// CreateNamespace creates a namespace for the given namespace ID.
    34  	CreateNamespace(namespaceID string, uOpts UpdateOptions) (view.Namespace, error)
    35  
    36  	// DeleteNamespace deletes the namespace for the given namespace ID.
    37  	DeleteNamespace(namespaceID string, uOpts UpdateOptions) error
    38  
    39  	// FetchRuleSetSnapshot fetches the latest ruleset snapshot for the given namespace ID.
    40  	FetchRuleSetSnapshot(namespaceID string) (view.RuleSet, error)
    41  
    42  	// ValidateRuleSet validates a namespace's ruleset.
    43  	ValidateRuleSet(rs view.RuleSet) error
    44  
    45  	// UpdateRuleSet updates a ruleset with a given namespace.
    46  	UpdateRuleSet(rsChanges changes.RuleSetChanges, version int, uOpts UpdateOptions) (view.RuleSet, error)
    47  
    48  	// FetchMappingRule fetches the mapping rule for the given namespace ID and rule ID.
    49  	FetchMappingRule(namespaceID, mappingRuleID string) (view.MappingRule, error)
    50  
    51  	// CreateMappingRule creates a mapping rule for the given namespace ID and rule data.
    52  	CreateMappingRule(namespaceID string, mrv view.MappingRule, uOpts UpdateOptions) (view.MappingRule, error)
    53  
    54  	// UpdateMappingRule updates a mapping rule for the given namespace ID and rule data.
    55  	UpdateMappingRule(namespaceID, mappingRuleID string, mrv view.MappingRule, uOpts UpdateOptions) (view.MappingRule, error)
    56  
    57  	// DeleteMappingRule deletes the mapping rule for the given namespace ID and rule ID.
    58  	DeleteMappingRule(namespaceID, mappingRuleID string, uOpts UpdateOptions) error
    59  
    60  	// FetchMappingRuleHistory fetches the history of the mapping rule for the given namespace ID
    61  	// and rule ID.
    62  	FetchMappingRuleHistory(namespaceID, mappingRuleID string) ([]view.MappingRule, error)
    63  
    64  	// FetchRollupRule fetches the rollup rule for the given namespace ID and rule ID.
    65  	FetchRollupRule(namespaceID, rollupRuleID string) (view.RollupRule, error)
    66  
    67  	// CreateRollupRule creates a rollup rule for the given namespace ID and rule data.
    68  	CreateRollupRule(namespaceID string, rrv view.RollupRule, uOpts UpdateOptions) (view.RollupRule, error)
    69  
    70  	// UpdateRollupRule updates a rollup rule for the given namespace ID and rule data.
    71  	UpdateRollupRule(namespaceID, rollupRuleID string, rrv view.RollupRule, uOpts UpdateOptions) (view.RollupRule, error)
    72  
    73  	// DeleteRollupRule deletes the rollup rule for the given namespace ID and rule ID.
    74  	DeleteRollupRule(namespaceID, rollupRuleID string, uOpts UpdateOptions) error
    75  
    76  	// FetchRollupRuleHistory fetches the history of the rollup rule for the given namespace ID
    77  	// and rule ID.
    78  	FetchRollupRuleHistory(namespaceID, rollupRuleID string) ([]view.RollupRule, error)
    79  
    80  	// Close closes the store.
    81  	Close()
    82  }