github.com/newrelic/newrelic-client-go@v1.1.0/pkg/synthetics/secure_credentials.go (about) 1 package synthetics 2 3 import "context" 4 5 // SecureCredential represents a Synthetics secure credential. 6 type SecureCredential struct { 7 Key string `json:"key"` 8 Description string `json:"description"` 9 Value string `json:"value"` 10 CreatedAt *Time `json:"createdAt"` 11 LastUpdated *Time `json:"lastUpdated"` 12 } 13 14 // GetSecureCredentials is used to retrieve all secure credentials from your New Relic account. 15 16 // Deprecated: Use entities.GetEntitySearch instead. 17 func (s *Synthetics) GetSecureCredentials() ([]*SecureCredential, error) { 18 return s.GetSecureCredentialsWithContext(context.Background()) 19 } 20 21 // GetSecureCredentialsWithContext is used to retrieve all secure credentials from your New Relic account. 22 23 // Deprecated: Use entities.GetEntitySearchWithContext instead. 24 func (s *Synthetics) GetSecureCredentialsWithContext(ctx context.Context) ([]*SecureCredential, error) { 25 resp := getSecureCredentialsResponse{} 26 27 _, err := s.client.GetWithContext(ctx, s.config.Region().SyntheticsURL("/v1/secure-credentials"), nil, &resp) 28 if err != nil { 29 return nil, err 30 } 31 32 return resp.SecureCredentials, nil 33 } 34 35 // GetSecureCredential is used to retrieve a specific secure credential from your New Relic account. 36 37 // Deprecated: Use entities.GetEntitySearch instead. 38 func (s *Synthetics) GetSecureCredential(key string) (*SecureCredential, error) { 39 return s.GetSecureCredentialWithContext(context.Background(), key) 40 } 41 42 // GetSecureCredentialWithContext is used to retrieve a specific secure credential from your New Relic account. 43 44 // Deprecated: Use entities.GetEntitySearchWithContext instead. 45 func (s *Synthetics) GetSecureCredentialWithContext(ctx context.Context, key string) (*SecureCredential, error) { 46 var sc SecureCredential 47 48 _, err := s.client.GetWithContext(ctx, s.config.Region().SyntheticsURL("/v1/secure-credentials", key), nil, &sc) 49 if err != nil { 50 return nil, err 51 } 52 53 return &sc, nil 54 } 55 56 // AddSecureCredential is used to add a secure credential to your New Relic account. 57 58 // Deprecated: Use synthetics.SyntheticsCreateSecureCredential instead. 59 func (s *Synthetics) AddSecureCredential(key, value, description string) (*SecureCredential, error) { 60 return s.AddSecureCredentialWithContext(context.Background(), key, value, description) 61 } 62 63 // AddSecureCredentialWithContext is used to add a secure credential to your New Relic account. 64 65 // Deprecated: Use synthetics.SyntheticsCreateSecureCredentialWithContext instead. 66 func (s *Synthetics) AddSecureCredentialWithContext(ctx context.Context, key, value, description string) (*SecureCredential, error) { 67 sc := &SecureCredential{ 68 Key: key, 69 Value: value, 70 Description: description, 71 } 72 73 _, err := s.client.PostWithContext(ctx, s.config.Region().SyntheticsURL("/v1/secure-credentials"), nil, sc, nil) 74 if err != nil { 75 return nil, err 76 } 77 78 return sc, nil 79 } 80 81 // UpdateSecureCredential is used to update a secure credential in your New Relic account. 82 83 // Deprecated: Use synthetics.SyntheticsUpdateSecureCredential instead 84 func (s *Synthetics) UpdateSecureCredential(key, value, description string) (*SecureCredential, error) { 85 return s.UpdateSecureCredentialWithContext(context.Background(), key, value, description) 86 } 87 88 // UpdateSecureCredentialWithContext is used to update a secure credential in your New Relic account. 89 90 // Deprecated: Use synthetics.SyntheticsUpdateSecureCredentialWithContext instead 91 func (s *Synthetics) UpdateSecureCredentialWithContext(ctx context.Context, key, value, description string) (*SecureCredential, error) { 92 sc := &SecureCredential{ 93 Key: key, 94 Value: value, 95 Description: description, 96 } 97 98 _, err := s.client.PutWithContext(ctx, s.config.Region().SyntheticsURL("/v1/secure-credentials", key), nil, sc, nil) 99 100 if err != nil { 101 return nil, err 102 } 103 104 return sc, nil 105 } 106 107 // DeleteSecureCredential deletes a secure credential from your New Relic account. 108 109 // Deprecated: Use synthetics.SyntheticsDeleteSecureCredential instead 110 func (s *Synthetics) DeleteSecureCredential(key string) error { 111 return s.DeleteSecureCredentialWithContext(context.Background(), key) 112 } 113 114 // DeleteSecureCredentialWithContext deletes a secure credential from your New Relic account. 115 116 // Deprecated: Use synthetics.SyntheticsDeleteSecureCredentialWithContext instead 117 func (s *Synthetics) DeleteSecureCredentialWithContext(ctx context.Context, key string) error { 118 _, err := s.client.DeleteWithContext(ctx, s.config.Region().SyntheticsURL("/v1/secure-credentials", key), nil, nil) 119 if err != nil { 120 return err 121 } 122 123 return nil 124 } 125 126 type getSecureCredentialsResponse struct { 127 SecureCredentials []*SecureCredential `json:"secureCredentials"` 128 Count int `json:"count"` 129 }