Skip to content

Commit b6db07e

Browse files
authored
Merge pull request #212 from RachelTucker/tape-type-to-string
Updated tape type to be string instead of enum
2 parents 1300c19 + 0552064 commit b6db07e

File tree

4 files changed

+64
-117
lines changed

4 files changed

+64
-117
lines changed

src/ds3.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ void ds3_storage_domain_member_response_free(ds3_storage_domain_member_response*
772772
ds3_str_free(response->pool_partition_id);
773773
ds3_str_free(response->storage_domain_id);
774774
ds3_str_free(response->tape_partition_id);
775+
ds3_str_free(response->tape_type);
775776

776777
g_free(response);
777778
}
@@ -1110,6 +1111,7 @@ void ds3_tape_response_free(ds3_tape_response* response) {
11101111
ds3_str_free(response->partition_id);
11111112
ds3_str_free(response->serial_number);
11121113
ds3_str_free(response->storage_domain_id);
1114+
ds3_str_free(response->type);
11131115

11141116
g_free(response);
11151117
}
@@ -1120,6 +1122,7 @@ void ds3_tape_density_directive_response_free(ds3_tape_density_directive_respons
11201122

11211123
ds3_str_free(response->id);
11221124
ds3_str_free(response->partition_id);
1125+
ds3_str_free(response->tape_type);
11231126

11241127
g_free(response);
11251128
}
@@ -1628,13 +1631,17 @@ void ds3_detailed_tape_partition_response_free(ds3_detailed_tape_partition_respo
16281631
return;
16291632
}
16301633

1634+
size_t index;
16311635
g_free(response->drive_types);
16321636
ds3_str_free(response->error_message);
16331637
ds3_str_free(response->id);
16341638
ds3_str_free(response->library_id);
16351639
ds3_str_free(response->name);
16361640
ds3_str_free(response->serial_id);
16371641
ds3_str_free(response->serial_number);
1642+
for (index = 0; index < response->num_tape_types; index++) {
1643+
ds3_str_free(response->tape_types[index]);
1644+
}
16381645
g_free(response->tape_types);
16391646

16401647
g_free(response);
@@ -1725,13 +1732,17 @@ void ds3_named_detailed_tape_partition_response_free(ds3_named_detailed_tape_par
17251732
return;
17261733
}
17271734

1735+
size_t index;
17281736
g_free(response->drive_types);
17291737
ds3_str_free(response->error_message);
17301738
ds3_str_free(response->id);
17311739
ds3_str_free(response->library_id);
17321740
ds3_str_free(response->name);
17331741
ds3_str_free(response->serial_id);
17341742
ds3_str_free(response->serial_number);
1743+
for (index = 0; index < response->num_tape_types; index++) {
1744+
ds3_str_free(response->tape_types[index]);
1745+
}
17351746
g_free(response->tape_types);
17361747

17371748
g_free(response);

src/ds3.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ typedef struct {
879879
ds3_storage_domain_member_state state;
880880
ds3_str* storage_domain_id;
881881
ds3_str* tape_partition_id;
882-
ds3_tape_type tape_type;
882+
ds3_str* tape_type;
883883
ds3_write_preference_level write_preference;
884884
}ds3_storage_domain_member_response;
885885
typedef struct {
@@ -1176,15 +1176,15 @@ typedef struct {
11761176
ds3_str* storage_domain_id;
11771177
ds3_bool take_ownership_pending;
11781178
uint64_t total_raw_capacity;
1179-
ds3_tape_type type;
1179+
ds3_str* type;
11801180
ds3_priority verify_pending;
11811181
ds3_bool write_protected;
11821182
}ds3_tape_response;
11831183
typedef struct {
11841184
ds3_tape_drive_type density;
11851185
ds3_str* id;
11861186
ds3_str* partition_id;
1187-
ds3_tape_type tape_type;
1187+
ds3_str* tape_type;
11881188
}ds3_tape_density_directive_response;
11891189
typedef struct {
11901190
ds3_bool cleaning_required;
@@ -1499,7 +1499,7 @@ typedef struct {
14991499
ds3_str* serial_id;
15001500
ds3_str* serial_number;
15011501
ds3_tape_partition_state state;
1502-
ds3_tape_type* tape_types;
1502+
ds3_str** tape_types;
15031503
size_t num_tape_types;
15041504
}ds3_detailed_tape_partition_response;
15051505
typedef struct {
@@ -1557,7 +1557,7 @@ typedef struct {
15571557
ds3_str* serial_id;
15581558
ds3_str* serial_number;
15591559
ds3_tape_partition_state state;
1560-
ds3_tape_type* tape_types;
1560+
ds3_str** tape_types;
15611561
size_t num_tape_types;
15621562
}ds3_named_detailed_tape_partition_response;
15631563
typedef struct {
@@ -2514,7 +2514,7 @@ LIBRARY_API void ds3_request_set_tape_drive_id(const ds3_request* request, const
25142514
LIBRARY_API void ds3_request_set_tape_id(const ds3_request* request, const char * const value);
25152515
LIBRARY_API void ds3_request_set_tape_partition_id(const ds3_request* request, const char * const value);
25162516
LIBRARY_API void ds3_request_set_tape_state_ds3_tape_state(const ds3_request* request, const ds3_tape_state value);
2517-
LIBRARY_API void ds3_request_set_tape_type_ds3_tape_type(const ds3_request* request, const ds3_tape_type value);
2517+
LIBRARY_API void ds3_request_set_tape_type(const ds3_request* request, const char * const value);
25182518
LIBRARY_API void ds3_request_set_target_data_policy(const ds3_request* request, const char * const value);
25192519
LIBRARY_API void ds3_request_set_target_id(const ds3_request* request, const char * const value);
25202520
LIBRARY_API void ds3_request_set_task_priority_ds3_priority(const ds3_request* request, const ds3_priority value);
@@ -2529,7 +2529,7 @@ LIBRARY_API void ds3_request_set_type_ds3_system_failure_type(const ds3_request*
25292529
LIBRARY_API void ds3_request_set_type_ds3_tape_drive_type(const ds3_request* request, const ds3_tape_drive_type value);
25302530
LIBRARY_API void ds3_request_set_type_ds3_tape_failure_type(const ds3_request* request, const ds3_tape_failure_type value);
25312531
LIBRARY_API void ds3_request_set_type_ds3_tape_partition_failure_type(const ds3_request* request, const ds3_tape_partition_failure_type value);
2532-
LIBRARY_API void ds3_request_set_type_ds3_tape_type(const ds3_request* request, const ds3_tape_type value);
2532+
LIBRARY_API void ds3_request_set_type(const ds3_request* request, const char * const value);
25332533
LIBRARY_API void ds3_request_set_type_ds3_target_failure_type(const ds3_request* request, const ds3_target_failure_type value);
25342534
LIBRARY_API void ds3_request_set_unavailable_media_policy_ds3_unavailable_media_usage_policy(const ds3_request* request, const ds3_unavailable_media_usage_policy value);
25352535
LIBRARY_API void ds3_request_set_unavailable_pool_max_job_retry_in_mins(const ds3_request* request, const int value);
@@ -2767,7 +2767,7 @@ LIBRARY_API ds3_error* ds3_modify_cache_filesystem_spectra_s3_request(const ds3_
27672767
* void ds3_request_set_pool_state_ds3_pool_state(const ds3_request* request, const ds3_pool_state value)
27682768
* void ds3_request_set_pool_type_ds3_pool_type(const ds3_request* request, const ds3_pool_type value)
27692769
* void ds3_request_set_tape_state_ds3_tape_state(const ds3_request* request, const ds3_tape_state value)
2770-
* void ds3_request_set_tape_type_ds3_tape_type(const ds3_request* request, const ds3_tape_type value)
2770+
* void ds3_request_set_tape_type(const ds3_request* request, const char * const value)
27712771
*/
27722772
LIBRARY_API ds3_request* ds3_init_get_bucket_capacity_summary_spectra_s3_request(const char* bucket_id, const char* storage_domain_id);
27732773
LIBRARY_API ds3_error* ds3_get_bucket_capacity_summary_spectra_s3_request(const ds3_client* client, const ds3_request* request, ds3_capacity_summary_container_response** response);
@@ -2778,7 +2778,7 @@ LIBRARY_API ds3_error* ds3_get_bucket_capacity_summary_spectra_s3_request(const
27782778
* void ds3_request_set_pool_state_ds3_pool_state(const ds3_request* request, const ds3_pool_state value)
27792779
* void ds3_request_set_pool_type_ds3_pool_type(const ds3_request* request, const ds3_pool_type value)
27802780
* void ds3_request_set_tape_state_ds3_tape_state(const ds3_request* request, const ds3_tape_state value)
2781-
* void ds3_request_set_tape_type_ds3_tape_type(const ds3_request* request, const ds3_tape_type value)
2781+
* void ds3_request_set_tape_type(const ds3_request* request, const char * const value)
27822782
*/
27832783
LIBRARY_API ds3_request* ds3_init_get_storage_domain_capacity_summary_spectra_s3_request(const char* storage_domain_id);
27842784
LIBRARY_API ds3_error* ds3_get_storage_domain_capacity_summary_spectra_s3_request(const ds3_client* client, const ds3_request* request, ds3_capacity_summary_container_response** response);
@@ -2789,7 +2789,7 @@ LIBRARY_API ds3_error* ds3_get_storage_domain_capacity_summary_spectra_s3_reques
27892789
* void ds3_request_set_pool_state_ds3_pool_state(const ds3_request* request, const ds3_pool_state value)
27902790
* void ds3_request_set_pool_type_ds3_pool_type(const ds3_request* request, const ds3_pool_type value)
27912791
* void ds3_request_set_tape_state_ds3_tape_state(const ds3_request* request, const ds3_tape_state value)
2792-
* void ds3_request_set_tape_type_ds3_tape_type(const ds3_request* request, const ds3_tape_type value)
2792+
* void ds3_request_set_tape_type(const ds3_request* request, const char * const value)
27932793
*/
27942794
LIBRARY_API ds3_request* ds3_init_get_system_capacity_summary_spectra_s3_request(void);
27952795
LIBRARY_API ds3_error* ds3_get_system_capacity_summary_spectra_s3_request(const ds3_client* client, const ds3_request* request, ds3_capacity_summary_container_response** response);
@@ -4123,7 +4123,7 @@ LIBRARY_API ds3_error* ds3_put_storage_domain_spectra_s3_request(const ds3_clien
41234123
*
41244124
* void ds3_request_set_write_preference_ds3_write_preference_level(const ds3_request* request, const ds3_write_preference_level value)
41254125
*/
4126-
LIBRARY_API ds3_request* ds3_init_put_tape_storage_domain_member_spectra_s3_request(const char* storage_domain_id, const char* tape_partition_id, const ds3_tape_type tape_type);
4126+
LIBRARY_API ds3_request* ds3_init_put_tape_storage_domain_member_spectra_s3_request(const char* storage_domain_id, const char* tape_partition_id, const char* tape_type);
41274127
LIBRARY_API ds3_error* ds3_put_tape_storage_domain_member_spectra_s3_request(const ds3_client* client, const ds3_request* request, ds3_storage_domain_member_response** response);
41284128
LIBRARY_API ds3_request* ds3_init_delete_storage_domain_failure_spectra_s3_request(const char *const resource_id);
41294129
LIBRARY_API ds3_error* ds3_delete_storage_domain_failure_spectra_s3_request(const ds3_client* client, const ds3_request* request);
@@ -4157,7 +4157,7 @@ LIBRARY_API ds3_error* ds3_get_storage_domain_member_spectra_s3_request(const ds
41574157
* void ds3_request_set_state_ds3_storage_domain_member_state(const ds3_request* request, const ds3_storage_domain_member_state value)
41584158
* void ds3_request_set_storage_domain_id(const ds3_request* request, const char * const value)
41594159
* void ds3_request_set_tape_partition_id(const ds3_request* request, const char * const value)
4160-
* void ds3_request_set_tape_type_ds3_tape_type(const ds3_request* request, const ds3_tape_type value)
4160+
* void ds3_request_set_tape_type(const ds3_request* request, const char * const value)
41614161
* void ds3_request_set_write_preference_ds3_write_preference_level(const ds3_request* request, const ds3_write_preference_level value)
41624162
*/
41634163
LIBRARY_API ds3_request* ds3_init_get_storage_domain_members_spectra_s3_request(void);
@@ -4263,7 +4263,7 @@ LIBRARY_API ds3_request* ds3_init_cancel_verify_tape_spectra_s3_request(const ch
42634263
LIBRARY_API ds3_error* ds3_cancel_verify_tape_spectra_s3_request(const ds3_client* client, const ds3_request* request, ds3_tape_response** response);
42644264
LIBRARY_API ds3_request* ds3_init_clean_tape_drive_spectra_s3_request(const char *const resource_id);
42654265
LIBRARY_API ds3_error* ds3_clean_tape_drive_spectra_s3_request(const ds3_client* client, const ds3_request* request, ds3_tape_drive_response** response);
4266-
LIBRARY_API ds3_request* ds3_init_put_tape_density_directive_spectra_s3_request(const ds3_tape_drive_type density, const char* partition_id, const ds3_tape_type tape_type);
4266+
LIBRARY_API ds3_request* ds3_init_put_tape_density_directive_spectra_s3_request(const ds3_tape_drive_type density, const char* partition_id, const char* tape_type);
42674267
LIBRARY_API ds3_error* ds3_put_tape_density_directive_spectra_s3_request(const ds3_client* client, const ds3_request* request, ds3_tape_density_directive_response** response);
42684268
LIBRARY_API ds3_request* ds3_init_delete_permanently_lost_tape_spectra_s3_request(const char *const resource_id);
42694269
LIBRARY_API ds3_error* ds3_delete_permanently_lost_tape_spectra_s3_request(const ds3_client* client, const ds3_request* request);
@@ -4339,7 +4339,7 @@ LIBRARY_API ds3_error* ds3_get_tape_density_directive_spectra_s3_request(const d
43394339
* void ds3_request_set_page_offset(const ds3_request* request, const int value)
43404340
* void ds3_request_set_page_start_marker(const ds3_request* request, const char * const value)
43414341
* void ds3_request_set_partition_id(const ds3_request* request, const char * const value)
4342-
* void ds3_request_set_tape_type_ds3_tape_type(const ds3_request* request, const ds3_tape_type value)
4342+
* void ds3_request_set_tape_type(const ds3_request* request, const char * const value)
43434343
*/
43444344
LIBRARY_API ds3_request* ds3_init_get_tape_density_directives_spectra_s3_request(void);
43454345
LIBRARY_API ds3_error* ds3_get_tape_density_directives_spectra_s3_request(const ds3_client* client, const ds3_request* request, ds3_tape_density_directive_list_response** response);
@@ -4461,7 +4461,7 @@ LIBRARY_API ds3_error* ds3_get_tape_spectra_s3_request(const ds3_client* client,
44614461
* void ds3_request_set_sort_by(const ds3_request* request, const char * const value)
44624462
* void ds3_request_set_state_ds3_tape_state(const ds3_request* request, const ds3_tape_state value)
44634463
* void ds3_request_set_storage_domain_id(const ds3_request* request, const char * const value)
4464-
* void ds3_request_set_type_ds3_tape_type(const ds3_request* request, const ds3_tape_type value)
4464+
* void ds3_request_set_type(const ds3_request* request, const char * const value)
44654465
* void ds3_request_set_verify_pending_ds3_priority(const ds3_request* request, const ds3_priority value)
44664466
* void ds3_request_set_write_protected(const ds3_request* request, ds3_bool value)
44674467
*/

src/ds3_init_requests.c

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -152,40 +152,6 @@ static char* _get_ds3_tape_state_str(ds3_tape_state input) {
152152
return "";
153153
}
154154

155-
}
156-
static char* _get_ds3_tape_type_str(ds3_tape_type input) {
157-
if (input == DS3_TAPE_TYPE_LTO5) {
158-
return "LTO5";
159-
} else if (input == DS3_TAPE_TYPE_LTO6) {
160-
return "LTO6";
161-
} else if (input == DS3_TAPE_TYPE_LTO7) {
162-
return "LTO7";
163-
} else if (input == DS3_TAPE_TYPE_LTO8) {
164-
return "LTO8";
165-
} else if (input == DS3_TAPE_TYPE_LTO_CLEANING_TAPE) {
166-
return "LTO_CLEANING_TAPE";
167-
} else if (input == DS3_TAPE_TYPE_TS_JC) {
168-
return "TS_JC";
169-
} else if (input == DS3_TAPE_TYPE_TS_JY) {
170-
return "TS_JY";
171-
} else if (input == DS3_TAPE_TYPE_TS_JK) {
172-
return "TS_JK";
173-
} else if (input == DS3_TAPE_TYPE_TS_JD) {
174-
return "TS_JD";
175-
} else if (input == DS3_TAPE_TYPE_TS_JZ) {
176-
return "TS_JZ";
177-
} else if (input == DS3_TAPE_TYPE_TS_JL) {
178-
return "TS_JL";
179-
} else if (input == DS3_TAPE_TYPE_TS_CLEANING_TAPE) {
180-
return "TS_CLEANING_TAPE";
181-
} else if (input == DS3_TAPE_TYPE_UNKNOWN) {
182-
return "UNKNOWN";
183-
} else if (input == DS3_TAPE_TYPE_FORBIDDEN) {
184-
return "FORBIDDEN";
185-
} else {
186-
return "";
187-
}
188-
189155
}
190156
static char* _get_ds3_auto_inspect_mode_str(ds3_auto_inspect_mode input) {
191157
if (input == DS3_AUTO_INSPECT_MODE_NEVER) {
@@ -1517,8 +1483,8 @@ void ds3_request_set_tape_state_ds3_tape_state(const ds3_request* request, const
15171483
_set_query_param(request, "tape_state", (const char*)_get_ds3_tape_state_str(value));
15181484

15191485
}
1520-
void ds3_request_set_tape_type_ds3_tape_type(const ds3_request* request, const ds3_tape_type value) {
1521-
_set_query_param(request, "tape_type", (const char*)_get_ds3_tape_type_str(value));
1486+
void ds3_request_set_tape_type(const ds3_request* request, const char * const value) {
1487+
_set_query_param(request, "tape_type", value);
15221488

15231489
}
15241490
void ds3_request_set_target_data_policy(const ds3_request* request, const char * const value) {
@@ -1577,8 +1543,8 @@ void ds3_request_set_type_ds3_tape_partition_failure_type(const ds3_request* req
15771543
_set_query_param(request, "type", (const char*)_get_ds3_tape_partition_failure_type_str(value));
15781544

15791545
}
1580-
void ds3_request_set_type_ds3_tape_type(const ds3_request* request, const ds3_tape_type value) {
1581-
_set_query_param(request, "type", (const char*)_get_ds3_tape_type_str(value));
1546+
void ds3_request_set_type(const ds3_request* request, const char * const value) {
1547+
_set_query_param(request, "type", value);
15821548

15831549
}
15841550
void ds3_request_set_type_ds3_target_failure_type(const ds3_request* request, const ds3_target_failure_type value) {
@@ -2946,16 +2912,17 @@ ds3_request* ds3_init_put_storage_domain_spectra_s3_request(const char* name) {
29462912
}
29472913
return (ds3_request*) request;
29482914
}
2949-
ds3_request* ds3_init_put_tape_storage_domain_member_spectra_s3_request(const char* storage_domain_id, const char* tape_partition_id, const ds3_tape_type tape_type) {
2915+
ds3_request* ds3_init_put_tape_storage_domain_member_spectra_s3_request(const char* storage_domain_id, const char* tape_partition_id, const char* tape_type) {
29502916
struct _ds3_request* request = _common_request_init(HTTP_POST, _build_path("/_rest_/storage_domain_member/", NULL, NULL));
29512917
if (storage_domain_id != NULL) {
29522918
_set_query_param((ds3_request*) request, "storage_domain_id", storage_domain_id);
29532919
}
29542920
if (tape_partition_id != NULL) {
29552921
_set_query_param((ds3_request*) request, "tape_partition_id", tape_partition_id);
29562922
}
2957-
_set_query_param((ds3_request*) request, "tape_type", _get_ds3_tape_type_str(tape_type));
2958-
2923+
if (tape_type != NULL) {
2924+
_set_query_param((ds3_request*) request, "tape_type", tape_type);
2925+
}
29592926
return (ds3_request*) request;
29602927
}
29612928
ds3_request* ds3_init_delete_storage_domain_failure_spectra_s3_request(const char *const resource_id) {
@@ -3088,15 +3055,16 @@ ds3_request* ds3_init_clean_tape_drive_spectra_s3_request(const char *const reso
30883055

30893056
return (ds3_request*) request;
30903057
}
3091-
ds3_request* ds3_init_put_tape_density_directive_spectra_s3_request(const ds3_tape_drive_type density, const char* partition_id, const ds3_tape_type tape_type) {
3058+
ds3_request* ds3_init_put_tape_density_directive_spectra_s3_request(const ds3_tape_drive_type density, const char* partition_id, const char* tape_type) {
30923059
struct _ds3_request* request = _common_request_init(HTTP_POST, _build_path("/_rest_/tape_density_directive/", NULL, NULL));
30933060
_set_query_param((ds3_request*) request, "density", _get_ds3_tape_drive_type_str(density));
30943061

30953062
if (partition_id != NULL) {
30963063
_set_query_param((ds3_request*) request, "partition_id", partition_id);
30973064
}
3098-
_set_query_param((ds3_request*) request, "tape_type", _get_ds3_tape_type_str(tape_type));
3099-
3065+
if (tape_type != NULL) {
3066+
_set_query_param((ds3_request*) request, "tape_type", tape_type);
3067+
}
31003068
return (ds3_request*) request;
31013069
}
31023070
ds3_request* ds3_init_delete_permanently_lost_tape_spectra_s3_request(const char *const resource_id) {

0 commit comments

Comments
 (0)