github.com/anthropics/anthropic-sdk-go@v1.70.1/betamemorystorememoryversion_test.go (about)

     1  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
     2  
     3  package anthropic_test
     4  
     5  import (
     6  	"context"
     7  	"errors"
     8  	"os"
     9  	"testing"
    10  	"time"
    11  
    12  	"github.com/anthropics/anthropic-sdk-go"
    13  	"github.com/anthropics/anthropic-sdk-go/internal/testutil"
    14  	"github.com/anthropics/anthropic-sdk-go/option"
    15  )
    16  
    17  func TestBetaMemoryStoreMemoryVersionGetWithOptionalParams(t *testing.T) {
    18  	baseURL := "http://localhost:4010"
    19  	if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
    20  		baseURL = envURL
    21  	}
    22  	if !testutil.CheckTestServer(t, baseURL) {
    23  		return
    24  	}
    25  	client := anthropic.NewClient(
    26  		option.WithBaseURL(baseURL),
    27  		option.WithAPIKey("my-anthropic-api-key"),
    28  	)
    29  	_, err := client.Beta.MemoryStores.MemoryVersions.Get(
    30  		context.TODO(),
    31  		"memory_version_id",
    32  		anthropic.BetaMemoryStoreMemoryVersionGetParams{
    33  			MemoryStoreID: "memory_store_id",
    34  			View:          anthropic.BetaManagedAgentsMemoryViewBasic,
    35  			Betas:         []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},
    36  			WorkspaceID:   anthropic.String("wrkspc_011CZkZaBF1tNoB5wlCeusgy"),
    37  		},
    38  	)
    39  	if err != nil {
    40  		var apierr *anthropic.Error
    41  		if errors.As(err, &apierr) {
    42  			t.Log(string(apierr.DumpRequest(true)))
    43  		}
    44  		t.Fatalf("err should be nil: %s", err.Error())
    45  	}
    46  }
    47  
    48  func TestBetaMemoryStoreMemoryVersionListWithOptionalParams(t *testing.T) {
    49  	t.Skip("buildURL drops path-level query params (SDK-4349)")
    50  	baseURL := "http://localhost:4010"
    51  	if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
    52  		baseURL = envURL
    53  	}
    54  	if !testutil.CheckTestServer(t, baseURL) {
    55  		return
    56  	}
    57  	client := anthropic.NewClient(
    58  		option.WithBaseURL(baseURL),
    59  		option.WithAPIKey("my-anthropic-api-key"),
    60  	)
    61  	_, err := client.Beta.MemoryStores.MemoryVersions.List(
    62  		context.TODO(),
    63  		"memory_store_id",
    64  		anthropic.BetaMemoryStoreMemoryVersionListParams{
    65  			APIKeyID:         anthropic.String("api_key_id"),
    66  			CreatedAtGte:     anthropic.Time(time.Now()),
    67  			CreatedAtLte:     anthropic.Time(time.Now()),
    68  			Limit:            anthropic.Int(0),
    69  			MemoryID:         anthropic.String("memory_id"),
    70  			Operation:        anthropic.BetaManagedAgentsMemoryVersionOperationCreated,
    71  			Page:             anthropic.String("page"),
    72  			ServiceAccountID: anthropic.String("service_account_id"),
    73  			SessionID:        anthropic.String("session_id"),
    74  			View:             anthropic.BetaManagedAgentsMemoryViewBasic,
    75  			Betas:            []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},
    76  			WorkspaceID:      anthropic.String("wrkspc_011CZkZaBF1tNoB5wlCeusgy"),
    77  		},
    78  	)
    79  	if err != nil {
    80  		var apierr *anthropic.Error
    81  		if errors.As(err, &apierr) {
    82  			t.Log(string(apierr.DumpRequest(true)))
    83  		}
    84  		t.Fatalf("err should be nil: %s", err.Error())
    85  	}
    86  }
    87  
    88  func TestBetaMemoryStoreMemoryVersionRedactWithOptionalParams(t *testing.T) {
    89  	baseURL := "http://localhost:4010"
    90  	if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
    91  		baseURL = envURL
    92  	}
    93  	if !testutil.CheckTestServer(t, baseURL) {
    94  		return
    95  	}
    96  	client := anthropic.NewClient(
    97  		option.WithBaseURL(baseURL),
    98  		option.WithAPIKey("my-anthropic-api-key"),
    99  	)
   100  	_, err := client.Beta.MemoryStores.MemoryVersions.Redact(
   101  		context.TODO(),
   102  		"memory_version_id",
   103  		anthropic.BetaMemoryStoreMemoryVersionRedactParams{
   104  			MemoryStoreID: "memory_store_id",
   105  			Betas:         []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},
   106  			WorkspaceID:   anthropic.String("wrkspc_011CZkZaBF1tNoB5wlCeusgy"),
   107  		},
   108  	)
   109  	if err != nil {
   110  		var apierr *anthropic.Error
   111  		if errors.As(err, &apierr) {
   112  			t.Log(string(apierr.DumpRequest(true)))
   113  		}
   114  		t.Fatalf("err should be nil: %s", err.Error())
   115  	}
   116  }