github.com/newrelic/newrelic-client-go@v1.1.0/pkg/workflows/workflows_api.go (about)

     1  // Code generated by tutone: DO NOT EDIT
     2  package workflows
     3  
     4  import (
     5  	"context"
     6  
     7  	"github.com/newrelic/newrelic-client-go/pkg/ai"
     8  )
     9  
    10  // Create a new Workflow with issues filter, enrichments and destinations
    11  func (a *Workflows) AiWorkflowsCreateWorkflow(
    12  	accountID int,
    13  	createWorkflowData AiWorkflowsCreateWorkflowInput,
    14  ) (*AiWorkflowsCreateWorkflowResponse, error) {
    15  	return a.AiWorkflowsCreateWorkflowWithContext(context.Background(),
    16  		accountID,
    17  		createWorkflowData,
    18  	)
    19  }
    20  
    21  // Create a new Workflow with issues filter, enrichments and destinations
    22  func (a *Workflows) AiWorkflowsCreateWorkflowWithContext(
    23  	ctx context.Context,
    24  	accountID int,
    25  	createWorkflowData AiWorkflowsCreateWorkflowInput,
    26  ) (*AiWorkflowsCreateWorkflowResponse, error) {
    27  
    28  	resp := AiWorkflowsCreateWorkflowQueryResponse{}
    29  	vars := map[string]interface{}{
    30  		"accountId":          accountID,
    31  		"createWorkflowData": createWorkflowData,
    32  	}
    33  
    34  	if err := a.client.NerdGraphQueryWithContext(ctx, AiWorkflowsCreateWorkflowMutation, vars, &resp); err != nil {
    35  		return nil, err
    36  	}
    37  
    38  	return &resp.AiWorkflowsCreateWorkflowResponse, nil
    39  }
    40  
    41  type AiWorkflowsCreateWorkflowQueryResponse struct {
    42  	AiWorkflowsCreateWorkflowResponse AiWorkflowsCreateWorkflowResponse `json:"AiWorkflowsCreateWorkflow"`
    43  }
    44  
    45  const AiWorkflowsCreateWorkflowMutation = `mutation(
    46  	$accountId: Int!,
    47  	$createWorkflowData: AiWorkflowsCreateWorkflowInput!,
    48  ) { aiWorkflowsCreateWorkflow(
    49  	accountId: $accountId,
    50  	createWorkflowData: $createWorkflowData,
    51  ) {
    52  	errors {
    53  		description
    54  		type
    55  	}
    56  	workflow {
    57  		accountId
    58  		createdAt
    59  		destinationConfigurations {
    60  			channelId
    61  			name
    62  			type
    63  		}
    64  		destinationsEnabled
    65  		enrichments {
    66  			accountId
    67  			configurations {
    68                  ... on AiWorkflowsNrqlConfiguration {
    69                    query
    70                  }
    71  		  	}
    72  			createdAt
    73  			id
    74  			name
    75  			type
    76  			updatedAt
    77  		}
    78  		enrichmentsEnabled
    79  		id
    80  		issuesFilter {
    81  			accountId
    82  			id
    83  			name
    84  			predicates {
    85  				attribute
    86  				operator
    87  				values
    88  			}
    89  			type
    90  		}
    91  		lastRun
    92  		mutingRulesHandling
    93  		name
    94  		updatedAt
    95  		workflowEnabled
    96  	}
    97  } }`
    98  
    99  // Delete a workflow and all it's sub entities: filter, enrichments and destinations
   100  func (a *Workflows) AiWorkflowsDeleteWorkflow(
   101  	accountID int,
   102  	iD string,
   103  ) (*AiWorkflowsDeleteWorkflowResponse, error) {
   104  	return a.AiWorkflowsDeleteWorkflowWithContext(context.Background(),
   105  		accountID,
   106  		iD,
   107  	)
   108  }
   109  
   110  // Delete a workflow and all it's sub entities: filter, enrichments and destinations
   111  func (a *Workflows) AiWorkflowsDeleteWorkflowWithContext(
   112  	ctx context.Context,
   113  	accountID int,
   114  	iD string,
   115  ) (*AiWorkflowsDeleteWorkflowResponse, error) {
   116  
   117  	resp := AiWorkflowsDeleteWorkflowQueryResponse{}
   118  	vars := map[string]interface{}{
   119  		"accountId": accountID,
   120  		"id":        iD,
   121  	}
   122  
   123  	if err := a.client.NerdGraphQueryWithContext(ctx, AiWorkflowsDeleteWorkflowMutation, vars, &resp); err != nil {
   124  		return nil, err
   125  	}
   126  
   127  	return &resp.AiWorkflowsDeleteWorkflowResponse, nil
   128  }
   129  
   130  type AiWorkflowsDeleteWorkflowQueryResponse struct {
   131  	AiWorkflowsDeleteWorkflowResponse AiWorkflowsDeleteWorkflowResponse `json:"AiWorkflowsDeleteWorkflow"`
   132  }
   133  
   134  const AiWorkflowsDeleteWorkflowMutation = `mutation(
   135  	$accountId: Int!,
   136  	$id: ID!,
   137  ) { aiWorkflowsDeleteWorkflow(
   138  	accountId: $accountId,
   139  	id: $id,
   140  ) {
   141  	errors {
   142  		description
   143  		type
   144  	}
   145  	id
   146  } }`
   147  
   148  // Update Workflow with issues filter, enrichments and destinations
   149  func (a *Workflows) AiWorkflowsUpdateWorkflow(
   150  	accountID int,
   151  	updateWorkflowData AiWorkflowsUpdateWorkflowInput,
   152  ) (*AiWorkflowsUpdateWorkflowResponse, error) {
   153  	return a.AiWorkflowsUpdateWorkflowWithContext(context.Background(),
   154  		accountID,
   155  		updateWorkflowData,
   156  	)
   157  }
   158  
   159  // Update Workflow with issues filter, enrichments and destinations
   160  func (a *Workflows) AiWorkflowsUpdateWorkflowWithContext(
   161  	ctx context.Context,
   162  	accountID int,
   163  	updateWorkflowData AiWorkflowsUpdateWorkflowInput,
   164  ) (*AiWorkflowsUpdateWorkflowResponse, error) {
   165  
   166  	resp := AiWorkflowsUpdateWorkflowQueryResponse{}
   167  	vars := map[string]interface{}{
   168  		"accountId":          accountID,
   169  		"updateWorkflowData": updateWorkflowData,
   170  	}
   171  
   172  	if err := a.client.NerdGraphQueryWithContext(ctx, AiWorkflowsUpdateWorkflowMutation, vars, &resp); err != nil {
   173  		return nil, err
   174  	}
   175  
   176  	return &resp.AiWorkflowsUpdateWorkflowResponse, nil
   177  }
   178  
   179  type AiWorkflowsUpdateWorkflowQueryResponse struct {
   180  	AiWorkflowsUpdateWorkflowResponse AiWorkflowsUpdateWorkflowResponse `json:"AiWorkflowsUpdateWorkflow"`
   181  }
   182  
   183  const AiWorkflowsUpdateWorkflowMutation = `mutation(
   184  	$accountId: Int!,
   185  	$updateWorkflowData: AiWorkflowsUpdateWorkflowInput!,
   186  ) { aiWorkflowsUpdateWorkflow(
   187  	accountId: $accountId,
   188  	updateWorkflowData: $updateWorkflowData,
   189  ) {
   190  	errors {
   191  		description
   192  		type
   193  	}
   194  	workflow {
   195  		accountId
   196  		createdAt
   197  		destinationConfigurations {
   198  			channelId
   199  			name
   200  			type
   201  		}
   202  		destinationsEnabled
   203  		enrichments {
   204  			accountId
   205  			configurations {
   206                  ... on AiWorkflowsNrqlConfiguration {
   207                    query
   208                  }
   209  		  	}
   210  			createdAt
   211  			id
   212  			name
   213  			type
   214  			updatedAt
   215  		}
   216  		enrichmentsEnabled
   217  		id
   218  		issuesFilter {
   219  			accountId
   220  			id
   221  			name
   222  			predicates {
   223  				attribute
   224  				operator
   225  				values
   226  			}
   227  			type
   228  		}
   229  		lastRun
   230  		mutingRulesHandling
   231  		name
   232  		updatedAt
   233  		workflowEnabled
   234  	}
   235  } }`
   236  
   237  // Returns a list of workflows with pagination cursor according to account id and filters
   238  func (a *Workflows) GetWorkflows(
   239  	accountID int,
   240  	cursor string,
   241  	filters ai.AiWorkflowsFilters,
   242  ) (*AiWorkflowsWorkflows, error) {
   243  	return a.GetWorkflowsWithContext(context.Background(),
   244  		accountID,
   245  		cursor,
   246  		filters,
   247  	)
   248  }
   249  
   250  // Returns a list of workflows with pagination cursor according to account id and filters
   251  func (a *Workflows) GetWorkflowsWithContext(
   252  	ctx context.Context,
   253  	accountID int,
   254  	cursor string,
   255  	filters ai.AiWorkflowsFilters,
   256  ) (*AiWorkflowsWorkflows, error) {
   257  
   258  	resp := workflowsResponse{}
   259  	vars := map[string]interface{}{
   260  		"accountID": accountID,
   261  		"cursor":    cursor,
   262  		"filters":   filters,
   263  	}
   264  
   265  	if err := a.client.NerdGraphQueryWithContext(ctx, getWorkflowsQuery, vars, &resp); err != nil {
   266  		return nil, err
   267  	}
   268  
   269  	return &resp.Actor.Account.AiWorkflows.Workflows, nil
   270  }
   271  
   272  const getWorkflowsQuery = `query(
   273  	$accountID: Int!, $filters: AiWorkflowsFilters,
   274  ) { actor { account(id: $accountID) { aiWorkflows { workflows(filters: $filters) {
   275  	entities {
   276  		accountId
   277  		createdAt
   278  		destinationConfigurations {
   279  			channelId
   280  			name
   281  			type
   282  		}
   283  		destinationsEnabled
   284  		enrichments {
   285  			accountId
   286  			configurations {
   287                  ... on AiWorkflowsNrqlConfiguration {
   288                    query
   289                  }
   290  		  	}
   291  			createdAt
   292  			id
   293  			name
   294  			type
   295  			updatedAt
   296  		}
   297  		enrichmentsEnabled
   298  		id
   299  		issuesFilter {
   300  			accountId
   301  			id
   302  			name
   303  			predicates {
   304  				attribute
   305  				operator
   306  				values
   307  			}
   308  			type
   309  		}
   310  		lastRun
   311  		mutingRulesHandling
   312  		name
   313  		updatedAt
   314  		workflowEnabled
   315  	}
   316  	nextCursor
   317  	totalCount
   318  } } } } }`