pkg/database/cosmosdb/zz_generated_openshiftclusterdocument.go (247 lines of code) (raw):

// Code generated by github.com/bennerv/go-cosmosdb, DO NOT EDIT. package cosmosdb import ( "context" "net/http" "strconv" "strings" pkg "github.com/Azure/ARO-RP/pkg/api" ) type openShiftClusterDocumentClient struct { *databaseClient path string } // OpenShiftClusterDocumentClient is a openShiftClusterDocument client type OpenShiftClusterDocumentClient interface { Create(context.Context, string, *pkg.OpenShiftClusterDocument, *Options) (*pkg.OpenShiftClusterDocument, error) List(*Options) OpenShiftClusterDocumentIterator ListAll(context.Context, *Options) (*pkg.OpenShiftClusterDocuments, error) Get(context.Context, string, string, *Options) (*pkg.OpenShiftClusterDocument, error) Replace(context.Context, string, *pkg.OpenShiftClusterDocument, *Options) (*pkg.OpenShiftClusterDocument, error) Delete(context.Context, string, *pkg.OpenShiftClusterDocument, *Options) error Query(string, *Query, *Options) OpenShiftClusterDocumentRawIterator QueryAll(context.Context, string, *Query, *Options) (*pkg.OpenShiftClusterDocuments, error) ChangeFeed(*Options) OpenShiftClusterDocumentIterator } type openShiftClusterDocumentChangeFeedIterator struct { *openShiftClusterDocumentClient continuation string options *Options } type openShiftClusterDocumentListIterator struct { *openShiftClusterDocumentClient continuation string done bool options *Options } type openShiftClusterDocumentQueryIterator struct { *openShiftClusterDocumentClient partitionkey string query *Query continuation string done bool options *Options } // OpenShiftClusterDocumentIterator is a openShiftClusterDocument iterator type OpenShiftClusterDocumentIterator interface { Next(context.Context, int) (*pkg.OpenShiftClusterDocuments, error) Continuation() string } // OpenShiftClusterDocumentRawIterator is a openShiftClusterDocument raw iterator type OpenShiftClusterDocumentRawIterator interface { OpenShiftClusterDocumentIterator NextRaw(context.Context, int, interface{}) error } // NewOpenShiftClusterDocumentClient returns a new openShiftClusterDocument client func NewOpenShiftClusterDocumentClient(collc CollectionClient, collid string) OpenShiftClusterDocumentClient { return &openShiftClusterDocumentClient{ databaseClient: collc.(*collectionClient).databaseClient, path: collc.(*collectionClient).path + "/colls/" + collid, } } func (c *openShiftClusterDocumentClient) all(ctx context.Context, i OpenShiftClusterDocumentIterator) (*pkg.OpenShiftClusterDocuments, error) { allopenShiftClusterDocuments := &pkg.OpenShiftClusterDocuments{} for { openShiftClusterDocuments, err := i.Next(ctx, -1) if err != nil { return nil, err } if openShiftClusterDocuments == nil { break } allopenShiftClusterDocuments.Count += openShiftClusterDocuments.Count allopenShiftClusterDocuments.ResourceID = openShiftClusterDocuments.ResourceID allopenShiftClusterDocuments.OpenShiftClusterDocuments = append(allopenShiftClusterDocuments.OpenShiftClusterDocuments, openShiftClusterDocuments.OpenShiftClusterDocuments...) } return allopenShiftClusterDocuments, nil } func (c *openShiftClusterDocumentClient) Create(ctx context.Context, partitionkey string, newopenShiftClusterDocument *pkg.OpenShiftClusterDocument, options *Options) (openShiftClusterDocument *pkg.OpenShiftClusterDocument, err error) { headers := http.Header{} headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`) if options == nil { options = &Options{} } options.NoETag = true err = c.setOptions(options, newopenShiftClusterDocument, headers) if err != nil { return } err = c.do(ctx, http.MethodPost, c.path+"/docs", "docs", c.path, http.StatusCreated, &newopenShiftClusterDocument, &openShiftClusterDocument, headers) return } func (c *openShiftClusterDocumentClient) List(options *Options) OpenShiftClusterDocumentIterator { continuation := "" if options != nil { continuation = options.Continuation } return &openShiftClusterDocumentListIterator{openShiftClusterDocumentClient: c, options: options, continuation: continuation} } func (c *openShiftClusterDocumentClient) ListAll(ctx context.Context, options *Options) (*pkg.OpenShiftClusterDocuments, error) { return c.all(ctx, c.List(options)) } func (c *openShiftClusterDocumentClient) Get(ctx context.Context, partitionkey, openShiftClusterDocumentid string, options *Options) (openShiftClusterDocument *pkg.OpenShiftClusterDocument, err error) { headers := http.Header{} headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`) err = c.setOptions(options, nil, headers) if err != nil { return } err = c.do(ctx, http.MethodGet, c.path+"/docs/"+openShiftClusterDocumentid, "docs", c.path+"/docs/"+openShiftClusterDocumentid, http.StatusOK, nil, &openShiftClusterDocument, headers) return } func (c *openShiftClusterDocumentClient) Replace(ctx context.Context, partitionkey string, newopenShiftClusterDocument *pkg.OpenShiftClusterDocument, options *Options) (openShiftClusterDocument *pkg.OpenShiftClusterDocument, err error) { headers := http.Header{} headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`) err = c.setOptions(options, newopenShiftClusterDocument, headers) if err != nil { return } err = c.do(ctx, http.MethodPut, c.path+"/docs/"+newopenShiftClusterDocument.ID, "docs", c.path+"/docs/"+newopenShiftClusterDocument.ID, http.StatusOK, &newopenShiftClusterDocument, &openShiftClusterDocument, headers) return } func (c *openShiftClusterDocumentClient) Delete(ctx context.Context, partitionkey string, openShiftClusterDocument *pkg.OpenShiftClusterDocument, options *Options) (err error) { headers := http.Header{} headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`) err = c.setOptions(options, openShiftClusterDocument, headers) if err != nil { return } err = c.do(ctx, http.MethodDelete, c.path+"/docs/"+openShiftClusterDocument.ID, "docs", c.path+"/docs/"+openShiftClusterDocument.ID, http.StatusNoContent, nil, nil, headers) return } func (c *openShiftClusterDocumentClient) Query(partitionkey string, query *Query, options *Options) OpenShiftClusterDocumentRawIterator { continuation := "" if options != nil { continuation = options.Continuation } return &openShiftClusterDocumentQueryIterator{openShiftClusterDocumentClient: c, partitionkey: partitionkey, query: query, options: options, continuation: continuation} } func (c *openShiftClusterDocumentClient) QueryAll(ctx context.Context, partitionkey string, query *Query, options *Options) (*pkg.OpenShiftClusterDocuments, error) { return c.all(ctx, c.Query(partitionkey, query, options)) } func (c *openShiftClusterDocumentClient) ChangeFeed(options *Options) OpenShiftClusterDocumentIterator { continuation := "" if options != nil { continuation = options.Continuation } return &openShiftClusterDocumentChangeFeedIterator{openShiftClusterDocumentClient: c, options: options, continuation: continuation} } func (c *openShiftClusterDocumentClient) setOptions(options *Options, openShiftClusterDocument *pkg.OpenShiftClusterDocument, headers http.Header) error { if options == nil { return nil } if openShiftClusterDocument != nil && !options.NoETag { if openShiftClusterDocument.ETag == "" { return ErrETagRequired } headers.Set("If-Match", openShiftClusterDocument.ETag) } if len(options.PreTriggers) > 0 { headers.Set("X-Ms-Documentdb-Pre-Trigger-Include", strings.Join(options.PreTriggers, ",")) } if len(options.PostTriggers) > 0 { headers.Set("X-Ms-Documentdb-Post-Trigger-Include", strings.Join(options.PostTriggers, ",")) } if len(options.PartitionKeyRangeID) > 0 { headers.Set("X-Ms-Documentdb-PartitionKeyRangeID", options.PartitionKeyRangeID) } return nil } func (i *openShiftClusterDocumentChangeFeedIterator) Next(ctx context.Context, maxItemCount int) (openShiftClusterDocuments *pkg.OpenShiftClusterDocuments, err error) { headers := http.Header{} headers.Set("A-IM", "Incremental feed") headers.Set("X-Ms-Max-Item-Count", strconv.Itoa(maxItemCount)) if i.continuation != "" { headers.Set("If-None-Match", i.continuation) } err = i.setOptions(i.options, nil, headers) if err != nil { return } err = i.do(ctx, http.MethodGet, i.path+"/docs", "docs", i.path, http.StatusOK, nil, &openShiftClusterDocuments, headers) if IsErrorStatusCode(err, http.StatusNotModified) { err = nil } if err != nil { return } i.continuation = headers.Get("Etag") return } func (i *openShiftClusterDocumentChangeFeedIterator) Continuation() string { return i.continuation } func (i *openShiftClusterDocumentListIterator) Next(ctx context.Context, maxItemCount int) (openShiftClusterDocuments *pkg.OpenShiftClusterDocuments, err error) { if i.done { return } headers := http.Header{} headers.Set("X-Ms-Max-Item-Count", strconv.Itoa(maxItemCount)) if i.continuation != "" { headers.Set("X-Ms-Continuation", i.continuation) } err = i.setOptions(i.options, nil, headers) if err != nil { return } err = i.do(ctx, http.MethodGet, i.path+"/docs", "docs", i.path, http.StatusOK, nil, &openShiftClusterDocuments, headers) if err != nil { return } i.continuation = headers.Get("X-Ms-Continuation") i.done = i.continuation == "" return } func (i *openShiftClusterDocumentListIterator) Continuation() string { return i.continuation } func (i *openShiftClusterDocumentQueryIterator) Next(ctx context.Context, maxItemCount int) (openShiftClusterDocuments *pkg.OpenShiftClusterDocuments, err error) { err = i.NextRaw(ctx, maxItemCount, &openShiftClusterDocuments) return } func (i *openShiftClusterDocumentQueryIterator) NextRaw(ctx context.Context, maxItemCount int, raw interface{}) (err error) { if i.done { return } headers := http.Header{} headers.Set("X-Ms-Max-Item-Count", strconv.Itoa(maxItemCount)) headers.Set("X-Ms-Documentdb-Isquery", "True") headers.Set("Content-Type", "application/query+json") if i.partitionkey != "" { headers.Set("X-Ms-Documentdb-Partitionkey", `["`+i.partitionkey+`"]`) } else { headers.Set("X-Ms-Documentdb-Query-Enablecrosspartition", "True") } if i.continuation != "" { headers.Set("X-Ms-Continuation", i.continuation) } err = i.setOptions(i.options, nil, headers) if err != nil { return } err = i.do(ctx, http.MethodPost, i.path+"/docs", "docs", i.path, http.StatusOK, &i.query, &raw, headers) if err != nil { return } i.continuation = headers.Get("X-Ms-Continuation") i.done = i.continuation == "" return } func (i *openShiftClusterDocumentQueryIterator) Continuation() string { return i.continuation }