1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
use anyhow::Result;

use crate::Client;

pub struct ContactsApiCustomFields {
    pub client: Client,
}

impl ContactsApiCustomFields {
    #[doc(hidden)]
    pub fn new(client: Client) -> Self {
        ContactsApiCustomFields { client }
    }

    /**
     * Retrieve all custom fields.
     *
     * This function performs a `GET` to the `/contactdb/custom_fields` endpoint.
     *
     * **This endpoint allows you to retrieve all custom fields.**
     *
     * **Parameters:**
     *
     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
     */
    pub async fn get_contactdb_custom_fields(
        &self,
    ) -> Result<crate::types::ListAllCustomFieldsResponse> {
        let url = "/contactdb/custom_fields".to_string();
        self.client.get(&url, None).await
    }

    /**
     * Create a Custom Field.
     *
     * This function performs a `POST` to the `/contactdb/custom_fields` endpoint.
     *
     * **This endpoint allows you to create a custom field.**
     *
     * **You can create up to 120 custom fields.**
     *
     * **Parameters:**
     *
     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
     */
    pub async fn post_contactdb_custom_field(
        &self,
        body: &crate::types::PostContactdbCustomFieldsRequest,
    ) -> Result<crate::types::ContactdbCustomFieldWithAllOf> {
        let url = "/contactdb/custom_fields".to_string();
        self.client
            .post(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
            .await
    }

    /**
     * Retrieve a Custom Field.
     *
     * This function performs a `GET` to the `/contactdb/custom_fields/{custom_field_id}` endpoint.
     *
     * **This endpoint allows you to retrieve a custom field by ID.**
     *
     * **Parameters:**
     *
     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
     */
    pub async fn get_contactdb_custom_fields_field(
        &self,
        custom_field_id: i64,
    ) -> Result<crate::types::ContactdbCustomFieldWithAllOf> {
        let url = format!(
            "/contactdb/custom_fields/{}",
            crate::progenitor_support::encode_path(&custom_field_id.to_string()),
        );

        self.client.get(&url, None).await
    }

    /**
     * Delete a Custom Field.
     *
     * This function performs a `DELETE` to the `/contactdb/custom_fields/{custom_field_id}` endpoint.
     *
     * **This endpoint allows you to delete a custom field by ID.**
     *
     * **Parameters:**
     *
     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
     */
    pub async fn delete_contactdb_custom_fields_field(
        &self,
        custom_field_id: i64,
    ) -> Result<crate::types::GlobalErrorResponseSchema> {
        let url = format!(
            "/contactdb/custom_fields/{}",
            crate::progenitor_support::encode_path(&custom_field_id.to_string()),
        );

        self.client.delete(&url, None).await
    }

    /**
     * Retrieve reserved fields.
     *
     * This function performs a `GET` to the `/contactdb/reserved_fields` endpoint.
     *
     * **This endpoint allows you to list all fields that are reserved and can't be used for custom field names.**
     *
     * **Parameters:**
     *
     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
     */
    pub async fn get_contactdb_reserved_fields(
        &self,
    ) -> Result<crate::types::GetContactdbReservedFieldsResponse> {
        let url = "/contactdb/reserved_fields".to_string();
        self.client.get(&url, None).await
    }
}