github.com/newrelic/newrelic-client-go@v1.1.0/pkg/ai/types_ai.go (about)

     1  //nolint:revive
     2  package ai
     3  
     4  import (
     5  	"encoding/json"
     6  	"fmt"
     7  )
     8  
     9  // AiWorkflowsNRQLConfiguration - Enrichment configuration for NRQL type
    10  type AiWorkflowsNRQLConfiguration struct {
    11  	// The NRQL query
    12  	Query string `json:"query"`
    13  }
    14  
    15  func (x *AiWorkflowsNRQLConfiguration) ImplementsAiWorkflowsConfiguration() {}
    16  
    17  // UnmarshalAiWorkflowsConfigurationInterface unmarshals the interface into the correct type
    18  // based on __typename provided by GraphQL
    19  func UnmarshalAiWorkflowsConfigurationInterface(b []byte) (*AiWorkflowsConfigurationInterface, error) {
    20  	var err error
    21  
    22  	var rawMessageAiWorkflowsConfiguration map[string]*json.RawMessage
    23  	err = json.Unmarshal(b, &rawMessageAiWorkflowsConfiguration)
    24  	if err != nil {
    25  		return nil, err
    26  	}
    27  
    28  	// Nothing to unmarshal
    29  	if len(rawMessageAiWorkflowsConfiguration) < 1 {
    30  		return nil, nil
    31  	}
    32  
    33  	var typeName string
    34  
    35  	if rawTypeName, ok := rawMessageAiWorkflowsConfiguration["__typename"]; ok {
    36  		err = json.Unmarshal(*rawTypeName, &typeName)
    37  		if err != nil {
    38  			return nil, err
    39  		}
    40  
    41  		switch typeName {
    42  		case "AiWorkflowsNRQLConfiguration":
    43  			var interfaceType AiWorkflowsNRQLConfiguration
    44  			err = json.Unmarshal(b, &interfaceType)
    45  			if err != nil {
    46  				return nil, err
    47  			}
    48  
    49  			var xxx AiWorkflowsConfigurationInterface = &interfaceType
    50  
    51  			return &xxx, nil
    52  		}
    53  	} else {
    54  		keys := []string{}
    55  		for k := range rawMessageAiWorkflowsConfiguration {
    56  			keys = append(keys, k)
    57  		}
    58  		return nil, fmt.Errorf("interface AiWorkflowsConfiguration did not include a __typename field for inspection: %s", keys)
    59  	}
    60  
    61  	return nil, fmt.Errorf("interface AiWorkflowsConfiguration was not matched against all PossibleTypes: %s", typeName)
    62  }
    63  
    64  // AiNotificationsSuggestionError - Object for suggestion errors
    65  type AiNotificationsSuggestionError struct {
    66  	// SuggestionError description
    67  	Description string `json:"description"`
    68  	// SuggestionError details
    69  	Details string `json:"details"`
    70  	// SuggestionError type
    71  	Type AiNotificationsErrorType `json:"type"`
    72  }
    73  
    74  // AiNotificationsErrorType - Error types
    75  type AiNotificationsErrorType string
    76  
    77  func (x *AiNotificationsSuggestionError) ImplementsAiNotificationsError() {}
    78  
    79  // AiNotificationsDataValidationError - Object for validation errors
    80  type AiNotificationsDataValidationError struct {
    81  	// Top level error details
    82  	Details string `json:"details"`
    83  	// List of invalid fields
    84  	Fields []AiNotificationsFieldError `json:"fields"`
    85  }
    86  
    87  // AiNotificationsFieldError - Invalid field object
    88  type AiNotificationsFieldError struct {
    89  	// Field name
    90  	Field string `json:"field"`
    91  	// Validation error
    92  	Message string `json:"message"`
    93  }
    94  
    95  func (x *AiNotificationsDataValidationError) ImplementsAiNotificationsError() {}
    96  
    97  // AiNotificationsConstraintError - Missing constraint error. Constraints can be retrieved using suggestion api
    98  type AiNotificationsConstraintError struct {
    99  	// Names of other constraints this constraint is dependent on
   100  	Dependencies []string `json:"dependencies"`
   101  	// Name of the missing constraint
   102  	Name string `json:"name"`
   103  }
   104  
   105  func (x *AiNotificationsConstraintError) ImplementsAiNotificationsError() {}
   106  
   107  // AiNotificationsResponseError - Response error object
   108  type AiNotificationsResponseError struct {
   109  	// Error description
   110  	Description string `json:"description"`
   111  	// Error details
   112  	Details string `json:"details"`
   113  	// Error type
   114  	Type AiNotificationsErrorType `json:"type"`
   115  }
   116  
   117  func (x *AiNotificationsResponseError) ImplementsAiNotificationsError() {}
   118  
   119  // UnmarshalAiNotificationsErrorInterface unmarshals the interface into the correct type
   120  // based on __typename provided by GraphQL
   121  func UnmarshalAiNotificationsErrorInterface(b []byte) (*AiNotificationsErrorInterface, error) {
   122  	var err error
   123  
   124  	var rawMessageAiNotificationsError map[string]*json.RawMessage
   125  	err = json.Unmarshal(b, &rawMessageAiNotificationsError)
   126  	if err != nil {
   127  		return nil, err
   128  	}
   129  
   130  	// Nothing to unmarshal
   131  	if len(rawMessageAiNotificationsError) < 1 {
   132  		return nil, nil
   133  	}
   134  
   135  	var typeName string
   136  
   137  	if rawTypeName, ok := rawMessageAiNotificationsError["__typename"]; ok {
   138  		err = json.Unmarshal(*rawTypeName, &typeName)
   139  		if err != nil {
   140  			return nil, err
   141  		}
   142  
   143  		switch typeName {
   144  		case "AiNotificationsSuggestionError":
   145  			var interfaceType AiNotificationsSuggestionError
   146  			err = json.Unmarshal(b, &interfaceType)
   147  			if err != nil {
   148  				return nil, err
   149  			}
   150  
   151  			var xxx AiNotificationsErrorInterface = &interfaceType
   152  
   153  			return &xxx, nil
   154  		case "AiNotificationsDataValidationError":
   155  			var interfaceType AiNotificationsDataValidationError
   156  			err = json.Unmarshal(b, &interfaceType)
   157  			if err != nil {
   158  				return nil, err
   159  			}
   160  
   161  			var xxx AiNotificationsErrorInterface = &interfaceType
   162  
   163  			return &xxx, nil
   164  		case "AiNotificationsConstraintError":
   165  			var interfaceType AiNotificationsConstraintError
   166  			err = json.Unmarshal(b, &interfaceType)
   167  			if err != nil {
   168  				return nil, err
   169  			}
   170  
   171  			var xxx AiNotificationsErrorInterface = &interfaceType
   172  
   173  			return &xxx, nil
   174  		case "AiNotificationsResponseError":
   175  			var interfaceType AiNotificationsResponseError
   176  			err = json.Unmarshal(b, &interfaceType)
   177  			if err != nil {
   178  				return nil, err
   179  			}
   180  
   181  			var xxx AiNotificationsErrorInterface = &interfaceType
   182  
   183  			return &xxx, nil
   184  		}
   185  	} else {
   186  		keys := []string{}
   187  		for k := range rawMessageAiNotificationsError {
   188  			keys = append(keys, k)
   189  		}
   190  		return nil, fmt.Errorf("interface AiNotificationsError did not include a __typename field for inspection: %s", keys)
   191  	}
   192  
   193  	return nil, fmt.Errorf("interface AiNotificationsError was not matched against all PossibleTypes: %s", typeName)
   194  }
   195  
   196  // AiNotificationsDestinationFilter - Filter destination object
   197  type AiNotificationsDestinationFilter struct {
   198  	// id
   199  	ID string `json:"id,omitempty"`
   200  }
   201  
   202  // SecureValue - The `SecureValue` scalar represents a secure value, ie a password, an API key, etc.
   203  type SecureValue string
   204  
   205  // AiNotificationsAuthType - Authentication types
   206  type AiNotificationsAuthType string
   207  
   208  // AiNotificationsTokenAuth - Token based authentication
   209  type AiNotificationsTokenAuth struct {
   210  	// Authentication Type - Token or Oauth2
   211  	AuthType AiNotificationsAuthType `json:"authType"`
   212  	// Token Prefix
   213  	Prefix string `json:"prefix"`
   214  }
   215  
   216  func (x AiNotificationsTokenAuth) GetAccessTokenURL() string {
   217  	return ""
   218  }
   219  
   220  // GetAuthType returns a pointer to the value of AuthType from AiNotificationsTokenAuth
   221  func (x AiNotificationsTokenAuth) GetAuthType() AiNotificationsAuthType {
   222  	return x.AuthType
   223  }
   224  
   225  // GetPrefix returns a pointer to the value of Prefix from AiNotificationsTokenAuth
   226  func (x AiNotificationsTokenAuth) GetPrefix() string {
   227  	return x.Prefix
   228  }
   229  
   230  func (x AiNotificationsTokenAuth) GetUser() string {
   231  	return ""
   232  }
   233  
   234  // GetAuthorizationURL returns a pointer to the value of AuthorizationURL from AiNotificationsOAuth2Auth
   235  func (x AiNotificationsTokenAuth) GetAuthorizationURL() string {
   236  	return ""
   237  }
   238  
   239  // GetClientId returns a pointer to the value of ClientId from AiNotificationsOAuth2Auth
   240  func (x AiNotificationsTokenAuth) GetClientId() string {
   241  	return ""
   242  }
   243  
   244  // GetRefreshInterval returns a pointer to the value of RefreshInterval from AiNotificationsOAuth2Auth
   245  func (x AiNotificationsTokenAuth) GetRefreshInterval() int {
   246  	return 0
   247  }
   248  
   249  // GetRefreshable returns a pointer to the value of Refreshable from AiNotificationsOAuth2Auth
   250  func (x AiNotificationsTokenAuth) GetRefreshable() bool {
   251  	return false
   252  }
   253  
   254  // GetScope returns a pointer to the value of Scope from AiNotificationsOAuth2Auth
   255  func (x AiNotificationsTokenAuth) GetScope() string {
   256  	return ""
   257  }
   258  
   259  func (x AiNotificationsTokenAuth) ImplementsAiNotificationsAuth() {}
   260  
   261  // AiNotificationsBasicAuth - Basic user and password authentication
   262  type AiNotificationsBasicAuth struct {
   263  	// Authentication Type - Basic
   264  	AuthType AiNotificationsAuthType `json:"authType"`
   265  	// Username
   266  	User string `json:"user"`
   267  }
   268  
   269  // GetAuthType returns a pointer to the value of AuthType from AiNotificationsBasicAuth
   270  func (x AiNotificationsBasicAuth) GetAuthType() AiNotificationsAuthType {
   271  	return x.AuthType
   272  }
   273  
   274  // GetUser returns a pointer to the value of User from AiNotificationsBasicAuth
   275  func (x AiNotificationsBasicAuth) GetUser() string {
   276  	return x.User
   277  }
   278  
   279  func (x AiNotificationsBasicAuth) GetPrefix() string {
   280  	return ""
   281  }
   282  
   283  func (x AiNotificationsBasicAuth) GetAccessTokenURL() string {
   284  	return ""
   285  }
   286  
   287  func (x AiNotificationsBasicAuth) GetAuthorizationURL() string {
   288  	return ""
   289  }
   290  
   291  func (x AiNotificationsBasicAuth) GetClientId() string {
   292  	return ""
   293  }
   294  
   295  func (x AiNotificationsBasicAuth) GetRefreshInterval() int {
   296  	return 0
   297  }
   298  
   299  func (x AiNotificationsBasicAuth) GetRefreshable() bool {
   300  	return false
   301  }
   302  
   303  func (x AiNotificationsBasicAuth) GetScope() string {
   304  	return ""
   305  }
   306  
   307  func (x AiNotificationsBasicAuth) ImplementsAiNotificationsAuth() {}
   308  
   309  // AiNotificationsOAuth2Auth - OAuth2 based authentication
   310  type AiNotificationsOAuth2Auth struct {
   311  	// OAuth2 access token url
   312  	AccessTokenURL string `json:"accessTokenUrl"`
   313  	// Authentication Type - Token or Oauth2
   314  	AuthType AiNotificationsAuthType `json:"authType"`
   315  	// OAuth2 authorization url
   316  	AuthorizationURL string `json:"authorizationUrl"`
   317  	// OAuth2 clientId
   318  	ClientId string `json:"clientId"`
   319  	// Token prefix
   320  	Prefix string `json:"prefix"`
   321  	// Interval of how often should the access token be refreshed
   322  	RefreshInterval int `json:"refreshInterval,omitempty"`
   323  	// Is the OAuth2 access token refreshable
   324  	Refreshable bool `json:"refreshable"`
   325  	// OAuth2 token's scope
   326  	Scope string `json:"scope,omitempty"`
   327  }
   328  
   329  // GetAccessTokenURL returns a pointer to the value of AccessTokenURL from AiNotificationsOAuth2Auth
   330  func (x AiNotificationsOAuth2Auth) GetAccessTokenURL() string {
   331  	return x.AccessTokenURL
   332  }
   333  
   334  // GetAuthType returns a pointer to the value of AuthType from AiNotificationsOAuth2Auth
   335  func (x AiNotificationsOAuth2Auth) GetAuthType() AiNotificationsAuthType {
   336  	return x.AuthType
   337  }
   338  
   339  // GetAuthorizationURL returns a pointer to the value of AuthorizationURL from AiNotificationsOAuth2Auth
   340  func (x AiNotificationsOAuth2Auth) GetAuthorizationURL() string {
   341  	return x.AuthorizationURL
   342  }
   343  
   344  // GetClientId returns a pointer to the value of ClientId from AiNotificationsOAuth2Auth
   345  func (x AiNotificationsOAuth2Auth) GetClientId() string {
   346  	return x.ClientId
   347  }
   348  
   349  // GetPrefix returns a pointer to the value of Prefix from AiNotificationsOAuth2Auth
   350  func (x AiNotificationsOAuth2Auth) GetPrefix() string {
   351  	return x.Prefix
   352  }
   353  
   354  // GetRefreshInterval returns a pointer to the value of RefreshInterval from AiNotificationsOAuth2Auth
   355  func (x AiNotificationsOAuth2Auth) GetRefreshInterval() int {
   356  	return x.RefreshInterval
   357  }
   358  
   359  // GetRefreshable returns a pointer to the value of Refreshable from AiNotificationsOAuth2Auth
   360  func (x AiNotificationsOAuth2Auth) GetRefreshable() bool {
   361  	return x.Refreshable
   362  }
   363  
   364  // GetScope returns a pointer to the value of Scope from AiNotificationsOAuth2Auth
   365  func (x AiNotificationsOAuth2Auth) GetScope() string {
   366  	return x.Scope
   367  }
   368  
   369  // AiNotificationsAuth - Authentication interface
   370  type AiNotificationsAuth struct {
   371  	// OAuth2 access token url
   372  	AccessTokenURL string `json:"accessTokenUrl,omitempty"`
   373  	// Authentication Type - Token, Oauth2, or Basic
   374  	AuthType AiNotificationsAuthType `json:"authType,omitempty"`
   375  	// OAuth2 authorization url
   376  	AuthorizationURL string `json:"authorizationUrl,omitempty"`
   377  	// OAuth2 clientId
   378  	ClientId string `json:"clientId,omitempty"`
   379  	// Token prefix
   380  	Prefix string `json:"prefix,omitempty"`
   381  	// Interval of how often should the OAuth2 access token be refreshed
   382  	RefreshInterval int `json:"refreshInterval,omitempty"`
   383  	// Is the OAuth2 access token refreshable
   384  	Refreshable bool `json:"refreshable,omitempty"`
   385  	// OAuth2 token's scope
   386  	Scope string `json:"scope,omitempty"`
   387  	// Basic auth password
   388  	Password SecureValue `json:"password,omitempty"`
   389  	// Basic auth user
   390  	User string `json:"user,omitempty"`
   391  }
   392  
   393  func (x *AiNotificationsAuth) ImplementsAiNotificationsAuth() {}
   394  
   395  // AiNotificationsAuth - Authentication interface
   396  type AiNotificationsAuthInterface interface {
   397  	ImplementsAiNotificationsAuth()
   398  	GetAccessTokenURL() string
   399  	GetAuthType() AiNotificationsAuthType
   400  	GetAuthorizationURL() string
   401  	GetClientId() string
   402  	GetPrefix() string
   403  	GetRefreshInterval() int
   404  	GetRefreshable() bool
   405  	GetScope() string
   406  }
   407  
   408  // UnmarshalAiNotificationsAuthInterface unmarshals the interface into the correct type
   409  // based on __typename provided by GraphQL
   410  func UnmarshalAiNotificationsAuthInterface(b []byte) (*AiNotificationsAuthInterface, error) {
   411  	var err error
   412  
   413  	var rawMessageAiNotificationsAuth map[string]*json.RawMessage
   414  	err = json.Unmarshal(b, &rawMessageAiNotificationsAuth)
   415  	if err != nil {
   416  		return nil, err
   417  	}
   418  
   419  	// Nothing to unmarshal
   420  	if len(rawMessageAiNotificationsAuth) < 1 {
   421  		return nil, nil
   422  	}
   423  
   424  	var typeName string
   425  
   426  	if rawTypeName, ok := rawMessageAiNotificationsAuth["__typename"]; ok {
   427  		err = json.Unmarshal(*rawTypeName, &typeName)
   428  		if err != nil {
   429  			return nil, err
   430  		}
   431  
   432  		switch typeName {
   433  		case "AiNotificationsBasicAuth":
   434  			var interfaceType AiNotificationsBasicAuth
   435  			err = json.Unmarshal(b, &interfaceType)
   436  			if err != nil {
   437  				return nil, err
   438  			}
   439  
   440  			var xxx AiNotificationsAuthInterface = &interfaceType
   441  
   442  			return &xxx, nil
   443  		case "AiNotificationsTokenAuth":
   444  			var interfaceType AiNotificationsTokenAuth
   445  			err = json.Unmarshal(b, &interfaceType)
   446  			if err != nil {
   447  				return nil, err
   448  			}
   449  
   450  			var xxx AiNotificationsAuthInterface = &interfaceType
   451  
   452  			return &xxx, nil
   453  		}
   454  	} else {
   455  		keys := []string{}
   456  		for k := range rawMessageAiNotificationsAuth {
   457  			keys = append(keys, k)
   458  		}
   459  		return nil, fmt.Errorf("interface AiNotificationsAuth did not include a __typename field for inspection: %s", keys)
   460  	}
   461  
   462  	return nil, fmt.Errorf("interface AiNotificationsAuth was not matched against all PossibleTypes: %s", typeName)
   463  }
   464  
   465  // AiNotificationsChannelFilter - Filter channel object
   466  type AiNotificationsChannelFilter struct {
   467  	// id
   468  	ID string `json:"id,omitempty"`
   469  }
   470  
   471  // AiWorkflowsFilters - Filter workflows object
   472  type AiWorkflowsFilters struct {
   473  	// id
   474  	ID string `json:"id,omitempty"`
   475  }