golift.io/starr@v1.0.0/lidarr/metadataprofile.go (about)

     1  package lidarr
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"golift.io/starr"
     8  )
     9  
    10  const bpMetadataProfile = APIver + "/metadataprofile"
    11  
    12  // MetadataProfile is the /api/v1/metadataprofile endpoint.
    13  type MetadataProfile struct {
    14  	Name                string           `json:"name"`
    15  	ID                  int64            `json:"id"`
    16  	PrimaryAlbumTypes   []*AlbumType     `json:"primaryAlbumTypes"`
    17  	SecondaryAlbumTypes []*AlbumType     `json:"secondaryAlbumTypes"`
    18  	ReleaseStatuses     []*ReleaseStatus `json:"releaseStatuses"`
    19  }
    20  
    21  // AlbumType is part of MetadataProfile.
    22  type AlbumType struct {
    23  	AlbumType *starr.Value `json:"albumType"`
    24  	Allowed   bool         `json:"allowed"`
    25  }
    26  
    27  // ReleaseStatus is part of MetadataProfile.
    28  type ReleaseStatus struct {
    29  	ReleaseStatus *starr.Value `json:"releaseStatus"`
    30  	Allowed       bool         `json:"allowed"`
    31  }
    32  
    33  // GetMetadataProfiles returns the metadata profiles.
    34  func (l *Lidarr) GetMetadataProfiles() ([]*MetadataProfile, error) {
    35  	return l.GetMetadataProfilesContext(context.Background())
    36  }
    37  
    38  // GetMetadataProfilesContext returns the metadata profiles.
    39  func (l *Lidarr) GetMetadataProfilesContext(ctx context.Context) ([]*MetadataProfile, error) {
    40  	var output []*MetadataProfile
    41  
    42  	req := starr.Request{URI: bpMetadataProfile}
    43  	if err := l.GetInto(ctx, req, &output); err != nil {
    44  		return nil, fmt.Errorf("api.Get(%s): %w", &req, err)
    45  	}
    46  
    47  	return output, nil
    48  }