github.com/anthropics/anthropic-sdk-go@v1.70.1/betaorganizationfederationruleworkspace_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  
    11  	"github.com/anthropics/anthropic-sdk-go"
    12  	"github.com/anthropics/anthropic-sdk-go/internal/testutil"
    13  	"github.com/anthropics/anthropic-sdk-go/option"
    14  )
    15  
    16  func TestBetaOrganizationFederationRuleWorkspaceListWithOptionalParams(t *testing.T) {
    17  	baseURL := "http://localhost:4010"
    18  	if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
    19  		baseURL = envURL
    20  	}
    21  	if !testutil.CheckTestServer(t, baseURL) {
    22  		return
    23  	}
    24  	client := anthropic.NewClient(
    25  		option.WithBaseURL(baseURL),
    26  		option.WithAPIKey("my-anthropic-api-key"),
    27  	)
    28  	_, err := client.Beta.Organization.Federation.Rules.Workspaces.List(
    29  		context.TODO(),
    30  		"federation_rule_id",
    31  		anthropic.BetaOrganizationFederationRuleWorkspaceListParams{
    32  			Limit: anthropic.Int(1),
    33  			Page:  anthropic.String("page"),
    34  			Betas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},
    35  		},
    36  	)
    37  	if err != nil {
    38  		var apierr *anthropic.Error
    39  		if errors.As(err, &apierr) {
    40  			t.Log(string(apierr.DumpRequest(true)))
    41  		}
    42  		t.Fatalf("err should be nil: %s", err.Error())
    43  	}
    44  }
    45  
    46  func TestBetaOrganizationFederationRuleWorkspaceAddWithOptionalParams(t *testing.T) {
    47  	baseURL := "http://localhost:4010"
    48  	if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
    49  		baseURL = envURL
    50  	}
    51  	if !testutil.CheckTestServer(t, baseURL) {
    52  		return
    53  	}
    54  	client := anthropic.NewClient(
    55  		option.WithBaseURL(baseURL),
    56  		option.WithAPIKey("my-anthropic-api-key"),
    57  	)
    58  	_, err := client.Beta.Organization.Federation.Rules.Workspaces.Add(
    59  		context.TODO(),
    60  		"federation_rule_id",
    61  		anthropic.BetaOrganizationFederationRuleWorkspaceAddParams{
    62  			WorkspaceID: "workspace_id",
    63  			Betas:       []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},
    64  		},
    65  	)
    66  	if err != nil {
    67  		var apierr *anthropic.Error
    68  		if errors.As(err, &apierr) {
    69  			t.Log(string(apierr.DumpRequest(true)))
    70  		}
    71  		t.Fatalf("err should be nil: %s", err.Error())
    72  	}
    73  }
    74  
    75  func TestBetaOrganizationFederationRuleWorkspaceRemoveWithOptionalParams(t *testing.T) {
    76  	baseURL := "http://localhost:4010"
    77  	if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
    78  		baseURL = envURL
    79  	}
    80  	if !testutil.CheckTestServer(t, baseURL) {
    81  		return
    82  	}
    83  	client := anthropic.NewClient(
    84  		option.WithBaseURL(baseURL),
    85  		option.WithAPIKey("my-anthropic-api-key"),
    86  	)
    87  	_, err := client.Beta.Organization.Federation.Rules.Workspaces.Remove(
    88  		context.TODO(),
    89  		"workspace_id",
    90  		anthropic.BetaOrganizationFederationRuleWorkspaceRemoveParams{
    91  			FederationRuleID: "federation_rule_id",
    92  			Betas:            []anthropic.AnthropicBeta{anthropic.AnthropicBetaMessageBatches2024_09_24},
    93  		},
    94  	)
    95  	if err != nil {
    96  		var apierr *anthropic.Error
    97  		if errors.As(err, &apierr) {
    98  			t.Log(string(apierr.DumpRequest(true)))
    99  		}
   100  		t.Fatalf("err should be nil: %s", err.Error())
   101  	}
   102  }